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

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