details.pcss.css

Same filename in this branch
  1. 10 core/misc/dialog/off-canvas/css/details.pcss.css
  2. 10 core/themes/olivero/css/components/details.pcss.css
Same filename in other branches
  1. 9 core/themes/olivero/css/components/details.pcss.css
  2. 9 core/themes/claro/css/components/details.pcss.css
  3. 8.9.x core/themes/claro/css/components/details.pcss.css
  4. 11.x core/misc/dialog/off-canvas/css/details.pcss.css
  5. 11.x core/themes/olivero/css/components/details.pcss.css
  6. 11.x core/themes/claro/css/components/details.pcss.css

Collapsible details.

See also

collapse.js

File

core/themes/claro/css/components/details.pcss.css

View source
  1. /**
  2. * @file
  3. * Collapsible details.
  4. *
  5. * @see collapse.js
  6. */
  7. /**
  8. * Available modifiers are:
  9. * - .claro-details--accordion
  10. * - .claro-details--accordion-item
  11. *
  12. * Despite the fact that 'accordion' isn't used anywhere right now, we
  13. * implemented it (since the design defines that).
  14. * This variant can be used by setting the '#accordion' to TRUE for a
  15. * Details render element:
  16. * @code
  17. * $build['detail_accordion'] = [
  18. * '#type' => 'details',
  19. * '#accordion' => TRUE,
  20. * ];
  21. *
  22. * 'Accordion item' is used for the details of the node edit sidebar. For
  23. * creating accordion item list from a set of details, set the surrounding
  24. * Container render element's '#accordion' key to TRUE.
  25. *
  26. * 'Vertical tabs item' is used for the children of the VerticalTabs render
  27. * element.
  28. */
  29. :root {
  30. --size-summary-border-radius: calc(var(--details-border-size-radius) - var(--details-border-size));
  31. --summary-accordion-padding-vertical: calc(var(--space-l) + ((var(--space-m) - var(--space-l)) / 2));
  32. --summary-accordion-line-height: var(--space-l);
  33. }
  34. .claro-details {
  35. display: block;
  36. margin-block: var(--space-m);
  37. color: var(--color-text);
  38. border: var(--details-border-size) solid var(--details-border-color);
  39. border-radius: var(--details-border-size-radius);
  40. background-color: var(--color-white);
  41. box-shadow: var(--details-box-shadow);
  42. /*
  43. * The following width and min-width values ensure that the
    element
  44. * does not shift widths when opening, in the event that a parent table
  45. * element constrains the width. This can happen when toggling the
  46. * "lazy-load" option within an image field.
  47. */
  48. @nest td
  49. }
  50. .claro-details--accordion-item,
  51. .claro-details--vertical-tabs-item {
  52. margin-block: 0;
  53. border-radius: 0;
  54. box-shadow: none;
  55. }
  56. .claro-details--accordion-item:first-of-type {
  57. border-top-left-radius: var(--details-border-size-radius);
  58. border-top-right-radius: var(--details-border-size-radius);
  59. }
  60. .claro-details--accordion-item:last-of-type {
  61. border-bottom-right-radius: var(--details-border-size-radius);
  62. border-bottom-left-radius: var(--details-border-size-radius);
  63. }
  64. /**
  65. * Details summary styles.
  66. */
  67. .claro-details__summary {
  68. position: relative;
  69. box-sizing: border-box;
  70. padding-block: var(--space-m);
  71. padding-inline: var(--details-desktop-wrapper-padding-start) var(--space-m);
  72. list-style: none;
  73. cursor: pointer;
  74. transition: background-color var(--details-bg-color-transition-duration) ease-in-out;
  75. color: var(--color-gray-800);
  76. border-radius: var(--size-summary-border-radius);
  77. background-color: transparent;
  78. line-height: var(--space-m);
  79. }
  80. /* Modifiers */
  81. .claro-details__summary--accordion,
  82. .claro-details__summary--accordion-item,
  83. .claro-details__summary--vertical-tabs-item {
  84. padding-block: var(--summary-accordion-padding-vertical);
  85. padding-inline: var(--details-desktop-wrapper-padding-start) var(--space-l);
  86. background: var(--color-white);
  87. line-height: var(--summary-accordion-line-height);
  88. }
  89. /**
  90. * Accordion list items must not have border radius except they are the first
  91. * or the last ones.
  92. */
  93. .claro-details__summary--accordion-item {
  94. border-radius: 0;
  95. }
  96. .claro-details--accordion-item:first-child .claro-details__summary--accordion-item {
  97. border-top-left-radius: var(--details-border-size-radius);
  98. border-top-right-radius: var(--details-border-size-radius);
  99. }
  100. .claro-details--accordion-item:last-child .claro-details__summary--accordion-item {
  101. border-bottom-right-radius: var(--details-border-size-radius);
  102. border-bottom-left-radius: var(--details-border-size-radius);
  103. }
  104. /**
  105. * Details marker styles.
  106. */
  107. /* Remove the marker on Chrome */
  108. .claro-details__summary::-webkit-details-marker {
  109. display: none;
  110. }
  111. .claro-details__summary::before {
  112. position: absolute;
  113. inset-block-start: 50%;
  114. inset-inline-start: var(--space-s);
  115. display: inline-block;
  116. width: var(--space-m);
  117. height: var(--space-m);
  118. margin-block-start: calc(var(--space-m) / -2);
  119. content: "";
  120. transition: transform var(--details-transform-transition-duration) ease-in 0s;
  121. transform: rotate(90deg);
  122. text-align: center;
  123. background-image: url(../../images/icons/545560/chevron-right.svg);
  124. background-size: contain;
  125. @nest [dir="rtl"]
  126. }
  127. @media (prefers-reduced-motion: reduce) {
  128. .claro-details__summary::before {
  129. transition: none;
  130. }
  131. }
  132. @media (forced-colors: active) {
  133. .claro-details__summary::before {
  134. width: 0.5625rem;
  135. height: 0.5625rem;
  136. transition:
  137. transform var(--details-transform-transition-duration) ease-in 0s,
  138. margin var(--details-transform-transition-duration) ease-in 0s;
  139. transform: rotate(135deg); /* LTR */
  140. border-block-start: 0.125rem solid;
  141. border-inline-end: 0.125rem solid;
  142. background: none;
  143. @nest [dir="rtl"]
  144. }
  145. }
  146. /**
  147. * Safari (at least version 12.1) cannot handle our details marker
  148. * transition properly.
  149. *
  150. * Every additional pointer triggered toggle event freezes the transition,
  151. * and the transition is continued and finished after the pointer leaves
  152. * the Detail elements' summary.
  153. *
  154. * Even that it is possible to provide a JavaScript workaround for it (by
  155. * adding/removing a helper class with JavaScript if the Details is
  156. * toggled), that hack will make RTL details worse than without the hack.
  157. *
  158. * This weird query was found in
  159. * https://stackoverflow.com/questions/16348489#25975282 (based on the
  160. * answer it works for Safari 10.1+)
  161. */
  162. /* stylelint-disable-next-line unit-allowed-list */
  163. @media not all and (min-resolution: 0.001dpcm) {
  164. @supports (-webkit-appearance: none) {
  165. .claro-details__summary::before {
  166. transition: none;
  167. }
  168. }
  169. }
  170. /**
  171. * Details summary focus.
  172. */
  173. .claro-details__summary::after {
  174. position: absolute;
  175. inset: -1px;
  176. content: "";
  177. transition: opacity var(--details-box-shadow-transition-duration) ease-in-out;
  178. pointer-events: none;
  179. opacity: 0;
  180. border-radius: var(--details-border-size-radius);
  181. box-shadow: inset 0 0 0 var(--details-summary-focus-border-size) var(--details-summary-shadow-color);
  182. }
  183. .claro-details > .claro-details__summary--accordion-item::after,
  184. .vertical-tabs__item > .claro-details__summary--vertical-tabs-item::after {
  185. border-radius: 0;
  186. }
  187. .claro-details:first-child > .claro-details__summary--accordion-item::after,
  188. .vertical-tabs__item--first > .claro-details__summary--vertical-tabs-item::after {
  189. border-top-left-radius: var(--details-border-size-radius);
  190. border-top-right-radius: var(--details-border-size-radius);
  191. }
  192. .claro-details:last-child > .claro-details__summary--accordion-item::after,
  193. .vertical-tabs__item--last > .claro-details__summary--vertical-tabs-item::after {
  194. border-bottom-right-radius: var(--details-border-size-radius);
  195. border-bottom-left-radius: var(--details-border-size-radius);
  196. }
  197. /**
  198. * Focus box of accordions and accordion items must not have bottom border
  199. * radius if their accordion is expanded.
  200. */
  201. .claro-details[open] > .claro-details__summary--accordion::after,
  202. .claro-details[open] > .claro-details__summary--accordion-item::after,
  203. .vertical-tabs__item--last[open] > .claro-details__summary--vertical-tabs-item::after {
  204. border-bottom-right-radius: 0;
  205. border-bottom-left-radius: 0;
  206. }
  207. /**
  208. * Details summary states.
  209. */
  210. .claro-details__summary:focus {
  211. box-shadow: none;
  212. }
  213. [open] .claro-details__summary--accordion,
  214. [open] .claro-details__summary--accordion-item,
  215. [open] .claro-details__summary--vertical-tabs-item {
  216. color: var(--color-absolutezero);
  217. }
  218. .claro-details__summary:hover::before,
  219. .claro-details__summary:hover:focus::before,
  220. .claro-details[open] > .claro-details__summary:focus::before,
  221. .claro-details[open] > .claro-details__summary--accordion::before,
  222. .claro-details[open] > .claro-details__summary--accordion-item::before,
  223. .claro-details[open] > .claro-details__summary--vertical-tabs-item::before {
  224. background-image: url(../../images/icons/0036b1/chevron-right.svg);
  225. }
  226. .claro-details[open] > .claro-details__summary {
  227. border-radius: var(--size-summary-border-radius) var(--size-summary-border-radius) 0 0;
  228. }
  229. .claro-details[open] > .claro-details__summary::before {
  230. transform: rotate(-90deg); /* for LTR and RTL */
  231. }
  232. @media (forced-colors: active) {
  233. .claro-details__summary:hover::before,
  234. .claro-details__summary:hover:focus::before,
  235. .claro-details[open] > .claro-details__summary:focus::before {
  236. background: none;
  237. }
  238. .claro-details[open] > .claro-details__summary::before,
  239. [dir="rtl"] .claro-details[open] > .claro-details__summary::before {
  240. margin-block-start: -0.125rem;
  241. margin-inline-end: 0.125rem;
  242. transform: rotate(-45deg); /* for LTR and RTL */
  243. background: none;
  244. }
  245. }
  246. .claro-details[open] > .claro-details__summary--accordion,
  247. .claro-details[open] > .claro-details__summary--accordion-item,
  248. .claro-details[open] > .claro-details__summary--vertical-tabs-item {
  249. box-shadow: var(--details-box-shadow);
  250. }
  251. .claro-details__summary:hover {
  252. color: var(--color-absolutezero);
  253. background-color: var(--color-bgblue-hover);
  254. }
  255. /**
  256. * Focus styles.
  257. */
  258. /**
  259. * Active has to be here for Firefox.
  260. */
  261. [open] > .claro-details__summary--accordion:not(:focus, :active)::after,
  262. [open] > .claro-details__summary--accordion-item:not(:focus, :active)::after,
  263. [open] > .claro-details__summary--vertical-tabs-item:not(:focus, :active)::after {
  264. opacity: 1;
  265. border: var(--details-summary-focus-border-size) solid var(--color-absolutezero);
  266. border-width: 0 0 0 var(--details-summary-focus-border-size); /* LTR */
  267. box-shadow: none;
  268. @nest [dir="rtl"]
  269. }
  270. .claro-details__summary:focus::after,
  271. .claro-details__summary:active::after {
  272. opacity: 1;
  273. }
  274. /**
  275. * Safari workaround.
  276. */
  277. /* stylelint-disable-next-line unit-allowed-list */
  278. @media not all and (min-resolution: 0.001dpcm) {
  279. @supports (-webkit-appearance: none) {
  280. .claro-details__summary::after {
  281. transition: none;
  282. }
  283. }
  284. }
  285. .claro-details[open] > .claro-details__summary:focus {
  286. color: var(--color-absolutezero);
  287. }
  288. /**
  289. * Details wrapper and content.
  290. *
  291. * Accordion and accordion-item variants should have an extra background.
  292. * In that case, we render an additional wrapper 'claro-details__content' that
  293. * creates the visual margins around the content, and use the original
  294. * wrapper for setting the background color.
  295. *
  296. * If there is no border or padding defined, margins of parent-child elements
  297. * collapse to the highest value. We want to take benefit of this behavior,
  298. * because the elements inside the details content won't cause too big
  299. * vertical spacing.
  300. */
  301. .claro-details__wrapper,
  302. .claro-details__content {
  303. margin: var(--space-m);
  304. }
  305. .claro-details__wrapper--accordion,
  306. .claro-details__wrapper--accordion-item,
  307. .claro-details__wrapper--vertical-tabs-item {
  308. margin: 0;
  309. }
  310. .claro-details__wrapper--accordion::before,
  311. .claro-details__wrapper--accordion::after,
  312. .claro-details__wrapper--accordion-item::before,
  313. .claro-details__wrapper--accordion-item::after,
  314. .claro-details__wrapper--vertical-tabs-item::before,
  315. .claro-details__wrapper--vertical-tabs-item::after {
  316. display: table;
  317. clear: both;
  318. content: "";
  319. }
  320. .claro-details__wrapper--accordion,
  321. .claro-details__wrapper--accordion-item,
  322. .claro-details__wrapper--vertical-tabs-item {
  323. border-top: var(--details-border-size) solid var(--details-border-color);
  324. background-color: var(--color-gray-050-o-40);
  325. }
  326. /* @see Drupal.behaviors.verticalTabs */
  327. @media screen and (min-width: 641px) {
  328. .claro-details__wrapper {
  329. margin: var(--space-l) var(--details-desktop-wrapper-padding-start);
  330. }
  331. .claro-details__wrapper--accordion,
  332. .claro-details__wrapper--accordion-item,
  333. .claro-details__wrapper--vertical-tabs-item {
  334. margin: 0;
  335. }
  336. .js .claro-details__wrapper--vertical-tabs-item {
  337. margin: 0;
  338. border-top: 0;
  339. background-color: transparent;
  340. }
  341. }
  342. .claro-details__content--accordion,
  343. .claro-details__content--accordion-item,
  344. .claro-details__content--vertical-tabs-item {
  345. margin: var(--space-m) var(--space-m) var(--space-l);
  346. }
  347. @media screen and (min-width: 85em) {
  348. .vertical-tabs .claro-details__content--vertical-tabs-item {
  349. margin: var(--space-l);
  350. }
  351. }
  352. /* Description. */
  353. .claro-details__description {
  354. margin-block-end: var(--space-m);
  355. color: var(--input-fg-color--description);
  356. font-size: var(--font-size-xs); /* ~13px */
  357. line-height: calc(17rem / 16); /* 17px */
  358. }
  359. .claro-details__description.is-disabled {
  360. color: var(--input--disabled-fg-color);
  361. }
  362. .claro-details__summary-summary {
  363. display: block;
  364. color: var(--color-gray-800);
  365. font-size: var(--font-size-s);
  366. font-weight: normal;
  367. }
  368. .required-mark::after {
  369. display: inline-block;
  370. width: 0.4375rem;
  371. height: 0.4375rem;
  372. margin-inline: 0.3em;
  373. content: "";
  374. vertical-align: super;
  375. background-image: url(../../images/core/ee0000/required.svg);
  376. background-repeat: no-repeat;
  377. background-size: 0.4375rem 0.4375rem;
  378. }

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.