dropbutton.pcss.css

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

Dropbutton styles.

1. Transparent border is needed for high contrast mode. The border-width has to be set with !important to render borders with the defined width in high contrast mode Firefox.

File

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

View source
  1. /**
  2. * @file
  3. * Dropbutton styles.
  4. *
  5. * 1. Transparent border is needed for high contrast mode. The border-width has
  6. * to be set with !important to render borders with the defined width in high
  7. * contrast mode Firefox.
  8. */
  9. :root {
  10. /**
  11. * Dropbutton
  12. */
  13. --dropbutton-spacing-size: var(--space-m);
  14. --dropbutton-font-size: var(--font-size-base);
  15. --dropbutton-line-height: var(--space-m);
  16. --dropbutton-toggle-size: 3rem;
  17. --dropbutton-border-size: 1px;
  18. --dropbutton-toggle-size-spacing: var(--dropbutton-border-size);
  19. --dropbutton-border-radius-size: 2px;
  20. --dropbutton-item-max-width: 12.5rem;
  21. /* Variant variables: small. */
  22. --dropbutton-small-spacing-size: 0.625rem;
  23. --dropbutton-small-font-size: var(--font-size-xs);
  24. --dropbutton-small-line-height: 0.75rem;
  25. --dropbutton-small-toggle-size: calc((2 * var(--dropbutton-small-spacing-size)) + var(--dropbutton-small-line-height));
  26. /* Variant variables: extra small. */
  27. --dropbutton-extrasmall-spacing-size: 0.375rem;
  28. --dropbutton-extrasmall-font-size: var(--font-size-xs);
  29. --dropbutton-extrasmall-line-height: 0.75rem;
  30. --dropbutton-extrasmall-toggle-size: calc((2 * var(--dropbutton-extrasmall-spacing-size)) + var(--dropbutton-extrasmall-line-height));
  31. }
  32. .dropbutton-wrapper {
  33. display: inline-flex;
  34. border-radius: var(--button-border-radius-size);
  35. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  36. }
  37. .form-actions .dropbutton-wrapper,
  38. .field-actions .dropbutton-wrapper {
  39. margin-block: var(--space-xs);
  40. margin-inline: 0 var(--space-m);
  41. }
  42. .dropbutton-widget {
  43. position: relative;
  44. flex: 1 1 auto;
  45. .js .dropbutton-wrapper.open
  46. }
  47. /**
  48. * Dropbutton list.
  49. */
  50. .dropbutton {
  51. display: block;
  52. overflow: visible;
  53. min-width: 6rem; /* Help mitigate long dropbutton text from obscuring other dropbuttons. */
  54. height: var(--dropbutton-toggle-size);
  55. margin: 0;
  56. list-style: none;
  57. }
  58. .dropbutton-widget {
  59. border-radius: var(--button-border-radius-size);
  60. background-color: var(--button-bg-color);
  61. }
  62. /* Variants. */
  63. .dropbutton--small {
  64. height: var(--dropbutton-small-toggle-size);
  65. }
  66. .dropbutton--extrasmall {
  67. height: var(--dropbutton-extrasmall-toggle-size);
  68. }
  69. /**
  70. * First dropbutton list item.
  71. */
  72. .dropbutton--multiple .dropbutton__item:first-of-type {
  73. margin-right: calc(var(--dropbutton-toggle-size) + var(--dropbutton-toggle-size-spacing)); /* LTR */
  74. white-space: nowrap;
  75. [dir="rtl"]
  76. }
  77. /* First dropbutton list item variants */
  78. .no-touchevents .dropbutton--multiple.dropbutton--small .dropbutton__item:first-of-type {
  79. margin-right: calc(var(--dropbutton-small-toggle-size) + var(--dropbutton-toggle-size-spacing)); /* LTR */
  80. white-space: nowrap;
  81. [dir="rtl"]
  82. }
  83. .no-touchevents .dropbutton--multiple.dropbutton--extrasmall .dropbutton__item:first-of-type {
  84. margin-right: calc(var(--dropbutton-extrasmall-toggle-size) + var(--dropbutton-toggle-size-spacing)); /* LTR */
  85. white-space: nowrap;
  86. [dir="rtl"]
  87. }
  88. /**
  89. * Dropbutton toggler.
  90. */
  91. .dropbutton__toggle {
  92. position: absolute;
  93. z-index: 3;
  94. top: 0;
  95. right: 0; /* LTR */
  96. bottom: 0;
  97. width: var(--dropbutton-toggle-size);
  98. height: var(--dropbutton-toggle-size);
  99. border: var(--dropbutton-border-size) solid transparent !important; /* 1 */
  100. border-inline-start: var(--dropbutton-border-size) solid white !important;
  101. border-radius: 0 var(--button-border-radius-size) var(--button-border-radius-size) 0; /* LTR */
  102. background: var(--button-bg-color);
  103. font-size: 1px; /* iOS Safari sets a minimum button-width based on font-size. */
  104. appearance: none;
  105. [dir="rtl"]
  106. &::before {
  107. position: absolute;
  108. top: 50%;
  109. right: 50%;
  110. width: 0.875rem;
  111. height: 0.5625rem;
  112. content: "";
  113. transform: translate(50%, -50%) rotate(0);
  114. background: url(../../images/icons/000f33/chevron-down.svg) no-repeat center;
  115. background-size: contain;
  116. }
  117. /* Toggler states. */
  118. &:hover {
  119. color: var(--button-fg-color);
  120. background-color: var(--button--hover-bg-color);
  121. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  122. }
  123. &:focus {
  124. z-index: 2;
  125. }
  126. &:active {
  127. color: var(--button-fg-color);
  128. background-color: var(--button--active-bg-color);
  129. }
  130. }
  131. .dropbutton-wrapper.open .dropbutton__toggle::before {
  132. transform: translate(50%, -50%) rotate(180deg);
  133. [dir="rtl"]
  134. }
  135. /* Toggler variants */
  136. .no-touchevents .dropbutton--small .dropbutton__toggle {
  137. width: var(--dropbutton-small-toggle-size);
  138. height: var(--dropbutton-small-toggle-size);
  139. }
  140. .no-touchevents .dropbutton--extrasmall .dropbutton__toggle {
  141. width: var(--dropbutton-extrasmall-toggle-size);
  142. height: var(--dropbutton-extrasmall-toggle-size);
  143. }
  144. .no-touchevents .dropbutton--small .dropbutton__toggle::before,
  145. .no-touchevents .dropbutton--extrasmall .dropbutton__toggle::before {
  146. width: 0.75rem; /* 12px */
  147. }
  148. /* High contrast. */
  149. @media (forced-colors: active) {
  150. /* Default. */
  151. .dropbutton__toggle::before {
  152. width: 0.5625rem;
  153. height: 0.5625rem;
  154. margin-top: calc(0.5625rem / (2 * -1.41429));
  155. transform: translate(50%, -50%) rotate(135deg); /* LTR */
  156. border-width: 0.125rem 0.125rem 0 0;
  157. border-style: solid;
  158. background: none;
  159. .dropbutton-wrapper.open
  160. [dir="rtl"] .dropbutton-wrapper.open
  161. }
  162. /* Variants */
  163. .no-touchevents .dropbutton--small .dropbutton__toggle::before,
  164. .no-touchevents .dropbutton--extrasmall .dropbutton__toggle::before {
  165. width: 0.4375rem;
  166. height: 0.4375rem;
  167. margin-top: calc(0.4375rem / (2 * -1.41429));
  168. }
  169. .dropbutton-wrapper.open .dropbutton__toggle::before {
  170. margin-top: calc(0.4375rem / (2 * 1.41429));
  171. }
  172. }
  173. /**
  174. * Item in the first dropbutton list item (that looks like a button).
  175. *
  176. * Duplicates base button styles.
  177. */
  178. .dropbutton__item:first-of-type {
  179. & > * {
  180. display: inline-block;
  181. margin: 0;
  182. padding: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size)) calc(var(--space-l) - var(--dropbutton-border-size));
  183. cursor: pointer;
  184. text-align: center;
  185. text-decoration: none;
  186. color: var(--button-fg-color);
  187. border: var(--dropbutton-border-size) solid transparent !important; /* 1 */
  188. border-radius: var(--button-border-radius-size);
  189. background-color: var(--button-bg-color);
  190. font-size: var(--dropbutton-font-size);
  191. font-weight: 700;
  192. line-height: var(--dropbutton-line-height);
  193. appearance: none;
  194. -webkit-font-smoothing: antialiased;
  195. }
  196. .dropbutton--multiple & > * {
  197. padding-inline: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size));
  198. }
  199. /* Variants */
  200. .no-touchevents .dropbutton--small & > * {
  201. padding-block: calc(var(--dropbutton-small-spacing-size) - var(--dropbutton-border-size));
  202. font-size: var(--dropbutton-small-font-size);
  203. line-height: var(--dropbutton-small-line-height);
  204. }
  205. .no-touchevents .dropbutton--extrasmall & > * {
  206. padding-top: calc(var(--dropbutton-extrasmall-spacing-size) - var(--dropbutton-border-size));
  207. padding-bottom: calc(var(--dropbutton-extrasmall-spacing-size) - var(--dropbutton-border-size));
  208. font-size: var(--dropbutton-extrasmall-font-size);
  209. line-height: var(--dropbutton-extrasmall-line-height);
  210. }
  211. & > *:hover,
  212. & > .button:hover {
  213. text-decoration: none;
  214. color: var(--button-fg-color);
  215. background-color: var(--button--hover-bg-color);
  216. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  217. }
  218. & > *:focus:hover,
  219. & > .button:focus:hover {
  220. box-shadow:
  221. 0 0 0 2px var(--color-white),
  222. 0 0 0 5px var(--color-focus);
  223. }
  224. & > *:focus {
  225. text-decoration: none;
  226. }
  227. & > *:active {
  228. color: var(--button-fg-color);
  229. background-color: var(--button--active-bg-color);
  230. }
  231. .dropbutton--multiple & > * {
  232. position: relative;
  233. z-index: 3;
  234. }
  235. .dropbutton--multiple & > *:focus {
  236. z-index: 2;
  237. }
  238. .dropbutton--multiple & > * {
  239. border-radius: var(--button-border-radius-size) 0 0 var(--button-border-radius-size); /* LTR */
  240. }
  241. [dir="rtl"] .dropbutton--multiple & > * {
  242. border-radius: 0 var(--button-border-radius-size) var(--button-border-radius-size) 0;
  243. }
  244. }
  245. .dropbutton > .dropbutton__item > a,
  246. .dropbutton > .dropbutton__item > .button {
  247. display: block;
  248. box-sizing: border-box;
  249. width: 100%;
  250. margin: 0;
  251. text-align: left; /* LTR */
  252. }
  253. [dir="rtl"] .dropbutton > .dropbutton__item > a,
  254. [dir="rtl"] .dropbutton > .dropbutton__item > .button {
  255. text-align: right;
  256. }
  257. .dropbutton-wrapper:not(.open) .dropbutton__item:first-of-type ~ .dropbutton__item {
  258. visibility: hidden;
  259. /**
  260. * By setting a height of 1px, the dropbutton items are hidden
  261. * from view while still occupying minimal space, ensuring the layout remains intact.
  262. */
  263. height: 1px;
  264. }
  265. /**
  266. * Non-first dropbutton list elements.
  267. */
  268. .dropbutton__item:first-of-type ~ .dropbutton__item {
  269. border: var(--dropbutton-border-size) solid var(--color-gray-200);
  270. border-bottom: 0;
  271. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  272. & ~ .dropbutton__item {
  273. border-top: 0;
  274. }
  275. }
  276. .dropbutton__item ~ .dropbutton__item:last-child {
  277. border-bottom: var(--dropbutton-border-size) solid var(--color-gray-200);
  278. border-radius: 0 0 var(--dropbutton-border-radius-size) var(--dropbutton-border-radius-size);
  279. }
  280. /**
  281. * Dropbutton items of non-first dropbutton list elements.
  282. */
  283. .dropbutton__item:first-of-type ~ .dropbutton__item {
  284. max-width: var(--dropbutton-item-max-width);
  285. }
  286. .dropbutton__item:first-of-type ~ .dropbutton__item > a,
  287. .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
  288. position: relative;
  289. padding: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size));
  290. white-space: normal;
  291. text-decoration: none;
  292. color: var(--color-gray-800);
  293. border: var(--dropbutton-border-size) solid transparent !important; /* 1 */
  294. border-radius: var(--dropbutton-border-radius-size);
  295. background: var(--color-white);
  296. box-shadow: 0;
  297. font-size: var(--dropbutton-font-size);
  298. font-weight: normal;
  299. line-height: var(--dropbutton-line-height);
  300. -webkit-font-smoothing: antialiased;
  301. }
  302. .dropbutton__item:first-of-type ~ .dropbutton__item > a:not(:focus),
  303. .dropbutton__item:first-of-type ~ .dropbutton__item > .button:not(:focus) {
  304. z-index: 1;
  305. }
  306. /* Variants. */
  307. .no-touchevents .dropbutton--small .dropbutton__item:first-of-type ~ .dropbutton__item > a,
  308. .no-touchevents .dropbutton--small .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
  309. padding-top: var(--dropbutton-small-spacing-size);
  310. padding-bottom: var(--dropbutton-small-spacing-size);
  311. font-size: var(--dropbutton-small-font-size);
  312. line-height: var(--dropbutton-small-line-height);
  313. }
  314. .no-touchevents .dropbutton--extrasmall .dropbutton__item:first-of-type ~ .dropbutton__item > a,
  315. .no-touchevents .dropbutton--extrasmall .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
  316. padding-top: var(--dropbutton-extrasmall-spacing-size);
  317. padding-bottom: var(--dropbutton-extrasmall-spacing-size);
  318. font-size: var(--dropbutton-extrasmall-font-size);
  319. line-height: var(--dropbutton-extrasmall-line-height);
  320. }
  321. /* States. */
  322. .dropbutton__item {
  323. & > *:focus {
  324. position: relative;
  325. z-index: 3;
  326. }
  327. &:first-of-type ~ & > *:hover {
  328. color: var(--color-text);
  329. background: var(--color-gray-050);
  330. }
  331. & > .button:not(:focus) {
  332. box-shadow: none;
  333. }
  334. &:first-of-type ~ & > *:focus {
  335. border-color: var(--color-focus) !important; /* 1 */
  336. box-shadow:
  337. inset 0 0 0 1px var(--color-focus),
  338. 0 0 0 1px var(--color-focus);
  339. }
  340. }

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