details.pcss.css

Same filename in this branch
  1. 9 core/themes/olivero/css/components/details.pcss.css
Same filename in other branches
  1. 8.9.x core/themes/claro/css/components/details.pcss.css
  2. 10 core/misc/dialog/off-canvas/css/details.pcss.css
  3. 10 core/themes/olivero/css/components/details.pcss.css
  4. 10 core/themes/claro/css/components/details.pcss.css
  5. 11.x core/misc/dialog/off-canvas/css/details.pcss.css
  6. 11.x core/themes/olivero/css/components/details.pcss.css
  7. 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. @import "../base/variables.pcss.css";
  8. /**
  9. * Available modifiers are:
  10. * - .claro-details--accordion
  11. * - .claro-details--accordion-item
  12. *
  13. * Despite the fact that 'accordion' isn't used anywhere right now, we
  14. * implemented it (since the design defines that).
  15. * This variant can be used by setting the '#accordion' to TRUE for a
  16. * Details render element:
  17. * @code
  18. * $build['detail_accordion'] = [
  19. * '#type' => 'details',
  20. * '#accordion' => TRUE,
  21. * ];
  22. *
  23. * 'Accordion item' is used for the details of the node edit sidebar. For
  24. * creating accordion item list from a set of details, set the surrounding
  25. * Container render element's '#accordion' key to TRUE.
  26. *
  27. * 'Vertical tabs item' is used for the children of the VerticalTabs render
  28. * element.
  29. */
  30. :root {
  31. --size-summary-border-radius: calc(var(--details-border-size-radius) - var(--details-border-size));
  32. --summary-accordion-padding-vertical: calc(var(--space-l) + ((var(--space-m) - var(--space-l)) / 2));
  33. --summary-accordion-line-height: var(--space-l);
  34. }
  35. .claro-details {
  36. display: block;
  37. margin-top: var(--space-m);
  38. margin-bottom: var(--space-m);
  39. color: var(--color-text);
  40. border: var(--details-border-size) solid var(--details-border-color);
  41. border-radius: var(--details-border-size-radius);
  42. background-color: var(--color-white);
  43. box-shadow: var(--details-box-shadow);
  44. /*
  45. * The following width and min-width values ensure that the
    element
  46. * does not shift widths when opening, in the event that a parent table
  47. * element constrains the width. This can happen when toggling the
  48. * "lazy-load" option within an image field.
  49. */
  50. @nest td
  51. }
  52. .claro-details--accordion-item,
  53. .claro-details--vertical-tabs-item {
  54. margin-top: 0;
  55. margin-bottom: 0;
  56. border-radius: 0;
  57. box-shadow: none;
  58. }
  59. .claro-details--accordion-item:first-of-type {
  60. border-top-left-radius: var(--details-border-size-radius);
  61. border-top-right-radius: var(--details-border-size-radius);
  62. }
  63. .claro-details--accordion-item:last-of-type {
  64. border-bottom-right-radius: var(--details-border-size-radius);
  65. border-bottom-left-radius: var(--details-border-size-radius);
  66. }
  67. /**
  68. * Details summary styles.
  69. */
  70. .claro-details__summary {
  71. position: relative;
  72. box-sizing: border-box;
  73. padding: var(--space-m) var(--space-m) var(--space-m) var(--details-desktop-wrapper-padding-start); /* LTR */
  74. list-style: none;
  75. cursor: pointer;
  76. transition: background-color var(--details-bg-color-transition-duration) ease-in-out;
  77. word-wrap: break-word;
  78. hyphens: auto;
  79. color: var(--color-gray-800);
  80. border-radius: var(--size-summary-border-radius);
  81. background-color: transparent;
  82. line-height: var(--space-m);
  83. }
  84. [dir="rtl"] .claro-details__summary {
  85. padding-right: var(--details-desktop-wrapper-padding-start);
  86. padding-left: var(--space-m);
  87. }
  88. /* Modifiers */
  89. .claro-details__summary--accordion,
  90. .claro-details__summary--accordion-item,
  91. .claro-details__summary--vertical-tabs-item {
  92. padding: var(--summary-accordion-padding-vertical) var(--space-l) var(--summary-accordion-padding-vertical) var(--details-desktop-wrapper-padding-start); /* LTR */
  93. background: var(--color-white);
  94. line-height: var(--summary-accordion-line-height);
  95. }
  96. [dir="rtl"] .claro-details__summary--accordion,
  97. [dir="rtl"] .claro-details__summary--accordion-item,
  98. [dir="rtl"] .claro-details__summary--vertical-tabs-item {
  99. padding-right: var(--details-desktop-wrapper-padding-start);
  100. padding-left: var(--space-l);
  101. }
  102. /**
  103. * Accordion list items must not have border radius except they are the first
  104. * or the last ones.
  105. */
  106. .claro-details__summary--accordion-item {
  107. border-radius: 0;
  108. }
  109. .claro-details--accordion-item:first-child .claro-details__summary--accordion-item {
  110. border-top-left-radius: var(--details-border-size-radius);
  111. border-top-right-radius: var(--details-border-size-radius);
  112. }
  113. .claro-details--accordion-item:last-child .claro-details__summary--accordion-item {
  114. border-bottom-right-radius: var(--details-border-size-radius);
  115. border-bottom-left-radius: var(--details-border-size-radius);
  116. }
  117. /**
  118. * Details marker styles.
  119. */
  120. /* Remove the marker on Chrome */
  121. .claro-details__summary::-webkit-details-marker {
  122. display: none;
  123. }
  124. .claro-details__summary::before {
  125. position: absolute;
  126. top: 50%;
  127. left: var(--space-s); /* LTR */
  128. display: inline-block;
  129. width: var(--space-m);
  130. height: var(--space-m);
  131. margin-top: calc(var(--space-m) / -2);
  132. content: "";
  133. transition: transform var(--details-transform-transition-duration) ease-in 0s;
  134. transform: rotate(90deg); /* LTR */
  135. text-align: center;
  136. background-image: url(../../images/icons/545560/chevron-right.svg);
  137. background-size: contain;
  138. }
  139. [dir="rtl"] .claro-details__summary::before {
  140. right: var(--space-s);
  141. left: auto;
  142. transform: rotate(-270deg);
  143. }
  144. @media (prefers-reduced-motion: reduce) {
  145. .claro-details__summary::before {
  146. transition: none;
  147. }
  148. }
  149. @media (-ms-high-contrast: active), (forced-colors: active) {
  150. .claro-details__summary::before {
  151. width: 0.5625rem;
  152. height: 0.5625rem;
  153. transition: transform var(--details-transform-transition-duration) ease-in 0s, margin var(--details-transform-transition-duration) ease-in 0s;
  154. transform: rotate(135deg); /* LTR */
  155. border-top: 0.125rem solid;
  156. border-right: 0.125rem solid;
  157. background: none;
  158. }
  159. [dir="rtl"] .claro-details__summary::before {
  160. transform: rotate(-225deg);
  161. }
  162. }
  163. /**
  164. * Safari (at least version 12.1) cannot handle our details marker
  165. * transition properly.
  166. *
  167. * Every additional pointer triggered toggle event freezes the transition,
  168. * and the transition is continued and finished after the pointer leaves
  169. * the Detail elements' summary.
  170. *
  171. * Even that it is possible to provide a JavaScript workaround for it (by
  172. * adding/removing a helper class with JavaScript if the Details is
  173. * toggled), that hack will make RTL details worse than without the hack.
  174. *
  175. * This weird query was found in
  176. * https://stackoverflow.com/questions/16348489#25975282 (based on the
  177. * answer it works for Safari 10.1+)
  178. */
  179. /* stylelint-disable-next-line unit-allowed-list */
  180. @media not all and (min-resolution: 0.001dpcm) {
  181. @supports (-webkit-appearance: none) {
  182. .claro-details__summary::before {
  183. transition: none;
  184. }
  185. }
  186. }
  187. /**
  188. * Details summary focus.
  189. */
  190. .claro-details__summary::after {
  191. position: absolute;
  192. top: -1px;
  193. right: -1px;
  194. bottom: -1px;
  195. left: -1px;
  196. content: "";
  197. transition: opacity var(--details-box-shadow-transition-duration) ease-in-out;
  198. pointer-events: none;
  199. opacity: 0;
  200. border-radius: var(--details-border-size-radius);
  201. box-shadow: inset 0 0 0 var(--details-summary-focus-border-size) var(--details-summary-shadow-color);
  202. }
  203. .claro-details > .claro-details__summary--accordion-item::after,
  204. .vertical-tabs__item > .claro-details__summary--vertical-tabs-item::after {
  205. border-radius: 0;
  206. }
  207. .claro-details:first-child > .claro-details__summary--accordion-item::after,
  208. .vertical-tabs__item--first > .claro-details__summary--vertical-tabs-item::after {
  209. border-top-left-radius: var(--details-border-size-radius);
  210. border-top-right-radius: var(--details-border-size-radius);
  211. }
  212. .claro-details:last-child > .claro-details__summary--accordion-item::after,
  213. .vertical-tabs__item--last > .claro-details__summary--vertical-tabs-item::after {
  214. border-bottom-right-radius: var(--details-border-size-radius);
  215. border-bottom-left-radius: var(--details-border-size-radius);
  216. }
  217. /**
  218. * Focus box of accordions and accordion items must not have bottom border
  219. * radius if their accordion is expanded.
  220. */
  221. .claro-details[open] > .claro-details__summary--accordion::after,
  222. .claro-details[open] > .claro-details__summary--accordion-item::after,
  223. .vertical-tabs__item--last[open] > .claro-details__summary--vertical-tabs-item::after {
  224. border-bottom-right-radius: 0;
  225. border-bottom-left-radius: 0;
  226. }
  227. /**
  228. * Details summary states.
  229. */
  230. .claro-details__summary:focus {
  231. box-shadow: none;
  232. }
  233. [open] .claro-details__summary--accordion,
  234. [open] .claro-details__summary--accordion-item,
  235. [open] .claro-details__summary--vertical-tabs-item {
  236. color: var(--color-absolutezero);
  237. }
  238. .claro-details__summary:hover::before,
  239. .claro-details__summary:hover:focus::before,
  240. .claro-details[open] > .claro-details__summary:focus::before,
  241. .claro-details[open] > .claro-details__summary--accordion::before,
  242. .claro-details[open] > .claro-details__summary--accordion-item::before,
  243. .claro-details[open] > .claro-details__summary--vertical-tabs-item::before {
  244. background-image: url(../../images/icons/0036b1/chevron-right.svg);
  245. }
  246. .claro-details[open] > .claro-details__summary {
  247. border-radius: var(--size-summary-border-radius) var(--size-summary-border-radius) 0 0;
  248. }
  249. .claro-details[open] > .claro-details__summary::before {
  250. transform: rotate(-90deg); /* for LTR and RTL */
  251. }
  252. @media (-ms-high-contrast: active), (forced-colors: active) {
  253. .claro-details__summary:hover::before,
  254. .claro-details__summary:hover:focus::before {
  255. background: none;
  256. }
  257. .claro-details[open] > .claro-details__summary::before,
  258. [dir="rtl"] .claro-details[open] > .claro-details__summary::before {
  259. margin-top: calc(0.125rem / -2);
  260. margin-right: 0.125rem;
  261. transform: rotate(-45deg); /* for LTR and RTL */
  262. background: none;
  263. }
  264. }
  265. .claro-details[open] > .claro-details__summary--accordion,
  266. .claro-details[open] > .claro-details__summary--accordion-item,
  267. .claro-details[open] > .claro-details__summary--vertical-tabs-item {
  268. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  269. }
  270. .claro-details__summary:hover {
  271. color: var(--color-absolutezero);
  272. background-color: var(--color-bgblue-hover);
  273. }
  274. /**
  275. * Focus styles.
  276. */
  277. /**
  278. * Active has to be here for Firefox.
  279. * Merges standard collapse-processed selectors.
  280. */
  281. [open] > .claro-details__summary--accordion:not(:focus):not(:active)::after,
  282. [open] > .claro-details__summary--accordion-item:not(:focus):not(:active)::after,
  283. .collapse-processed[open] > .claro-details__summary--accordion .details-title:not(:focus)::after,
  284. .collapse-processed[open] > .claro-details__summary--accordion-item .details-title:not(:focus)::after,
  285. [open] > .claro-details__summary--vertical-tabs-item:not(:focus):not(:active)::after,
  286. .collapse-processed[open] > .claro-details__summary--vertical-tabs-item .details-title:not(:focus)::after {
  287. opacity: 1;
  288. border: var(--details-summary-focus-border-size) solid var(--color-absolutezero);
  289. border-width: 0 0 0 var(--details-summary-focus-border-size); /* LTR */
  290. box-shadow: none;
  291. }
  292. [dir="rtl"] [open] > .claro-details__summary--accordion:not(:focus)::after,
  293. [dir="rtl"] [open] > .claro-details__summary--accordion-item:not(:focus)::after,
  294. [dir="rtl"] .collapse-processed[open] > .claro-details__summary--accordion .details-title:not(:focus)::after,
  295. [dir="rtl"] .collapse-processed[open] > .claro-details__summary--accordion-item .details-title:not(:focus)::after,
  296. [dir="rtl"] [open] > .claro-details__summary--vertical-tabs-item:not(:focus)::after,
  297. [dir="rtl"] .collapse-processed[open] > .claro-details__summary--vertical-tabs-item .details-title:not(:focus)::after {
  298. border-width: 0 var(--details-summary-focus-border-size) 0 0;
  299. }
  300. .claro-details__summary:focus::after,
  301. .claro-details__summary:active::after,
  302. .collapse-processed > .claro-details__summary .details-title:focus::after {
  303. opacity: 1;
  304. }
  305. /**
  306. * Safari workaround.
  307. */
  308. /* stylelint-disable-next-line unit-allowed-list */
  309. @media not all and (min-resolution: 0.001dpcm) {
  310. @supports (-webkit-appearance: none) {
  311. .claro-details__summary::after {
  312. transition: none;
  313. }
  314. }
  315. }
  316. .claro-details[open] > .claro-details__summary:focus {
  317. color: var(--color-absolutezero);
  318. }
  319. /**
  320. * Details wrapper and content.
  321. *
  322. * Accordion and accordion-item variants should have an extra background.
  323. * In that case, we render an additional wrapper 'claro-details__content' that
  324. * creates the visual margins around the content, and use the original
  325. * wrapper for setting the background color.
  326. *
  327. * If there is no border or padding defined, margins of parent-child elements
  328. * collapse to the highest value. We want to take benefit of this behavior,
  329. * because the elements inside the details content won't cause too big
  330. * vertical spacing.
  331. */
  332. .claro-details__wrapper,
  333. .claro-details__content {
  334. margin: var(--space-m);
  335. }
  336. .claro-details__wrapper--accordion,
  337. .claro-details__wrapper--accordion-item,
  338. .claro-details__wrapper--vertical-tabs-item {
  339. margin: 0;
  340. }
  341. .claro-details__wrapper--accordion::before,
  342. .claro-details__wrapper--accordion::after,
  343. .claro-details__wrapper--accordion-item::before,
  344. .claro-details__wrapper--accordion-item::after,
  345. .claro-details__wrapper--vertical-tabs-item::before,
  346. .claro-details__wrapper--vertical-tabs-item::after {
  347. display: table;
  348. clear: both;
  349. content: "";
  350. }
  351. .claro-details__wrapper--accordion,
  352. .claro-details__wrapper--accordion-item,
  353. .claro-details__wrapper--vertical-tabs-item {
  354. border-top: var(--details-border-size) solid var(--details-border-color);
  355. background-color: var(--color-gray-050-o-40);
  356. }
  357. @media screen and (min-width: 48em) {
  358. .claro-details__wrapper {
  359. margin: var(--space-l) var(--details-desktop-wrapper-padding-start);
  360. }
  361. .claro-details__wrapper--accordion,
  362. .claro-details__wrapper--accordion-item,
  363. .claro-details__wrapper--vertical-tabs-item {
  364. margin: 0;
  365. }
  366. }
  367. @media screen and (min-width: 85em) {
  368. .js .claro-details__wrapper--vertical-tabs-item {
  369. margin: 0;
  370. border-top: 0;
  371. background-color: transparent;
  372. }
  373. }
  374. .claro-details__content--accordion,
  375. .claro-details__content--accordion-item,
  376. .claro-details__content--vertical-tabs-item {
  377. margin: var(--space-m) var(--space-m) var(--space-l);
  378. }
  379. @media screen and (min-width: 85em) {
  380. .vertical-tabs .claro-details__content--vertical-tabs-item {
  381. margin: var(--space-l);
  382. }
  383. }
  384. /* Description. */
  385. .claro-details__description {
  386. margin-bottom: var(--space-m);
  387. color: var(--input-fg-color--description);
  388. font-size: var(--font-size-xs); /* ~13px */
  389. line-height: calc(17rem / 16); /* 17px */
  390. }
  391. .claro-details__description.is-disabled {
  392. color: var(--input--disabled-fg-color);
  393. }
  394. /**
  395. * Collapse processed for non-supporting browsers like IE or Edge.
  396. */
  397. .collapse-processed > .claro-details__summary {
  398. padding: 0;
  399. }
  400. .collapse-processed > .claro-details__summary::after {
  401. content: none;
  402. }
  403. .collapse-processed > .claro-details__summary .details-title {
  404. position: relative;
  405. display: block;
  406. padding: var(--space-m) var(--space-m) var(--space-m) var(--details-desktop-wrapper-padding-start); /* LTR */
  407. text-decoration: none;
  408. color: inherit;
  409. border-radius: var(--size-summary-border-radius);
  410. }
  411. [dir="rtl"] .collapse-processed > .claro-details__summary .details-title {
  412. padding-right: var(--details-desktop-wrapper-padding-start);
  413. padding-left: var(--space-m);
  414. }
  415. .collapse-processed > .claro-details__summary--accordion .details-title,
  416. .collapse-processed > .claro-details__summary--accordion-item .details-title,
  417. .collapse-processed > .claro-details__summary--vertical-tabs-item .details-title {
  418. padding: var(--summary-accordion-padding-vertical) var(--space-l) var(--summary-accordion-padding-vertical) var(--details-desktop-wrapper-padding-start); /* LTR */
  419. }
  420. [dir="rtl"] .collapse-processed > .claro-details__summary--accordion .details-title,
  421. [dir="rtl"] .collapse-processed > .claro-details__summary--accordion-item .details-title,
  422. [dir="rtl"] .collapse-processed > .claro-details__summary--vertical-tabs-item .details-title {
  423. padding-right: var(--details-desktop-wrapper-padding-start);
  424. padding-left: var(--space-l);
  425. }
  426. /* Focus and hover states. */
  427. .collapse-processed > .claro-details__summary .details-title:focus,
  428. .collapse-processed > .claro-details__summary .details-title:hover {
  429. z-index: 1;
  430. text-decoration: none;
  431. outline: none;
  432. box-shadow: none;
  433. }
  434. .collapse-processed > .claro-details__summary .details-title::after {
  435. position: absolute;
  436. top: -1px;
  437. right: -1px;
  438. bottom: -1px;
  439. left: -1px;
  440. content: "";
  441. transition: opacity var(--details-box-shadow-transition-duration) ease-in-out;
  442. pointer-events: none;
  443. opacity: 0;
  444. border: var(--details-summary-focus-border-size) solid var(--color-focus);
  445. border-radius: var(--details-border-size-radius);
  446. }
  447. .collapse-processed > .claro-details__summary .details-title:focus::after {
  448. opacity: 1;
  449. }
  450. /* Accordion item modifiers for the focus box. */
  451. .collapse-processed > .claro-details__summary--accordion-item .details-title::after,
  452. .vertical-tabs__item > .claro-details__summary--vertical-tabs-item .details-title::after {
  453. border-radius: 0;
  454. }
  455. .collapse-processed:first-child > .claro-details__summary--accordion-item .details-title::after,
  456. .vertical-tabs__item--first > .claro-details__summary--vertical-tabs-item .details-title::after {
  457. border-top-left-radius: var(--details-border-size-radius);
  458. border-top-right-radius: var(--details-border-size-radius);
  459. }
  460. .collapse-processed:last-child > .claro-details__summary--accordion-item .details-title::after,
  461. .vertical-tabs__item--last > .claro-details__summary--vertical-tabs-item .details-title::after {
  462. border-bottom-right-radius: var(--details-border-size-radius);
  463. border-bottom-left-radius: var(--details-border-size-radius);
  464. }
  465. .collapse-processed[open] > .claro-details__summary--accordion .details-title::after,
  466. .collapse-processed[open] > .claro-details__summary--accordion-item .details-title::after,
  467. .vertical-tabs__item[open] > .claro-details__summary--vertical-tabs-item .details-title::after {
  468. border-bottom-right-radius: 0;
  469. border-bottom-left-radius: 0;
  470. }
  471. .claro-details__summary-summary {
  472. display: block;
  473. color: var(--color-gray-800);
  474. font-size: var(--font-size-s);
  475. font-weight: normal;
  476. }
  477. @media (-ms-high-contrast: active), (forced-colors: active) {
  478. .collapse-processed[open] > .claro-details__summary--accordion .details-title:not(:focus)::after,
  479. .collapse-processed[open] > .claro-details__summary--accordion-item .details-title:not(:focus)::after,
  480. .collapse-processed[open] > .claro-details__summary--vertical-tabs-item .details-title:not(:focus)::after {
  481. top: -1px;
  482. right: -1px;
  483. bottom: -1px;
  484. left: -1px;
  485. }
  486. .collapse-processed > .claro-details__summary .details-title::after {
  487. top: -5px;
  488. right: -5px;
  489. bottom: -5px;
  490. left: -5px;
  491. border: 2px dotted;
  492. }
  493. }
  494. .required-mark::after {
  495. display: inline-block;
  496. width: 0.4375rem;
  497. height: 0.4375rem;
  498. margin-right: 0.3em;
  499. margin-left: 0.3em;
  500. content: "";
  501. vertical-align: super;
  502. background-image: url(../../images/core/ee0000/required.svg);
  503. background-repeat: no-repeat;
  504. background-size: 0.4375rem 0.4375rem;
  505. }

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