dropbutton.pcss.css

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

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