dropbutton.pcss.css
Same filename in this branch
Same filename in other branches
- 9 core/themes/olivero/css/components/dropbutton.pcss.css
- 9 core/themes/claro/css/components/dropbutton.pcss.css
- 8.9.x core/themes/claro/css/components/dropbutton.pcss.css
- 10 core/misc/dialog/off-canvas/css/dropbutton.pcss.css
- 10 core/themes/olivero/css/components/dropbutton.pcss.css
- 10 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
- /**
- * @file
- * 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.
- */
-
- :root {
- /**
- * Dropbutton
- */
- --dropbutton-spacing-size: var(--space-m);
- --dropbutton-font-size: var(--font-size-base);
- --dropbutton-line-height: var(--space-m);
- --dropbutton-toggle-size: 3rem;
- --dropbutton-border-size: 1px;
- --dropbutton-toggle-size-spacing: var(--dropbutton-border-size);
- --dropbutton-border-radius-size: 2px;
- --dropbutton-item-max-width: 12.5rem;
- /* Variant variables: small. */
- --dropbutton-small-spacing-size: 0.625rem;
- --dropbutton-small-font-size: var(--font-size-xs);
- --dropbutton-small-line-height: 0.75rem;
- --dropbutton-small-toggle-size: calc((2 * var(--dropbutton-small-spacing-size)) + var(--dropbutton-small-line-height));
- /* Variant variables: extra small. */
- --dropbutton-extrasmall-spacing-size: 0.375rem;
- --dropbutton-extrasmall-font-size: var(--font-size-xs);
- --dropbutton-extrasmall-line-height: 0.75rem;
- --dropbutton-extrasmall-toggle-size: calc((2 * var(--dropbutton-extrasmall-spacing-size)) + var(--dropbutton-extrasmall-line-height));
- }
-
- .dropbutton-wrapper {
- display: inline-flex;
- border-radius: var(--button-border-radius-size);
- box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
- }
-
- .form-actions .dropbutton-wrapper,
- .field-actions .dropbutton-wrapper {
- margin-block: var(--space-xs);
- margin-inline: 0 var(--space-m);
- }
-
- .dropbutton-widget {
- position: relative;
- flex: 1 1 auto;
- .js .dropbutton-wrapper.open
- }
-
- /**
- * Dropbutton list.
- */
- .dropbutton {
- display: block;
- overflow: visible;
- min-width: 6rem; /* Help mitigate long dropbutton text from obscuring other dropbuttons. */
- height: var(--dropbutton-toggle-size);
- margin: 0;
- list-style: none;
- }
-
- .dropbutton-widget {
- border-radius: var(--button-border-radius-size);
- background-color: var(--button-bg-color);
- }
-
- /* Variants. */
- .dropbutton--small {
- height: var(--dropbutton-small-toggle-size);
- }
-
- .dropbutton--extrasmall {
- height: var(--dropbutton-extrasmall-toggle-size);
- }
-
- /**
- * First dropbutton list item.
- */
- .dropbutton--multiple .dropbutton__item:first-of-type {
- margin-right: calc(var(--dropbutton-toggle-size) + var(--dropbutton-toggle-size-spacing)); /* LTR */
- white-space: nowrap;
- [dir="rtl"]
- }
-
- /* First dropbutton list item variants */
- .no-touchevents .dropbutton--multiple.dropbutton--small .dropbutton__item:first-of-type {
- margin-right: calc(var(--dropbutton-small-toggle-size) + var(--dropbutton-toggle-size-spacing)); /* LTR */
- white-space: nowrap;
- [dir="rtl"]
- }
-
- .no-touchevents .dropbutton--multiple.dropbutton--extrasmall .dropbutton__item:first-of-type {
- margin-right: calc(var(--dropbutton-extrasmall-toggle-size) + var(--dropbutton-toggle-size-spacing)); /* LTR */
- white-space: nowrap;
- [dir="rtl"]
- }
-
- /**
- * Dropbutton toggler.
- */
- .dropbutton__toggle {
- position: absolute;
- z-index: 3;
- top: 0;
- right: 0; /* LTR */
- bottom: 0;
- width: var(--dropbutton-toggle-size);
- height: var(--dropbutton-toggle-size);
- border: var(--dropbutton-border-size) solid transparent !important; /* 1 */
- border-inline-start: var(--dropbutton-border-size) solid white !important;
- border-radius: 0 var(--button-border-radius-size) var(--button-border-radius-size) 0; /* LTR */
- background: var(--button-bg-color);
- font-size: 1px; /* iOS Safari sets a minimum button-width based on font-size. */
- appearance: none;
- [dir="rtl"]
- &::before {
- position: absolute;
- top: 50%;
- right: 50%;
- width: 0.875rem;
- height: 0.5625rem;
- content: "";
- transform: translate(50%, -50%) rotate(0);
- background: url(../../images/icons/000f33/chevron-down.svg) no-repeat center;
- background-size: contain;
- }
-
- /* Toggler states. */
- &:hover {
- color: var(--button-fg-color);
- background-color: var(--button--hover-bg-color);
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
- }
- &:focus {
- z-index: 2;
- }
- &:active {
- color: var(--button-fg-color);
- background-color: var(--button--active-bg-color);
- }
- }
-
- .dropbutton-wrapper.open .dropbutton__toggle::before {
- transform: translate(50%, -50%) rotate(180deg);
- [dir="rtl"]
- }
-
- /* Toggler variants */
- .no-touchevents .dropbutton--small .dropbutton__toggle {
- width: var(--dropbutton-small-toggle-size);
- height: var(--dropbutton-small-toggle-size);
- }
-
- .no-touchevents .dropbutton--extrasmall .dropbutton__toggle {
- width: var(--dropbutton-extrasmall-toggle-size);
- height: var(--dropbutton-extrasmall-toggle-size);
- }
-
- .no-touchevents .dropbutton--small .dropbutton__toggle::before,
- .no-touchevents .dropbutton--extrasmall .dropbutton__toggle::before {
- width: 0.75rem; /* 12px */
- }
-
- /* High contrast. */
- @media (forced-colors: active) {
- /* Default. */
- .dropbutton__toggle::before {
- width: 0.5625rem;
- height: 0.5625rem;
- margin-top: calc(0.5625rem / (2 * -1.41429));
- transform: translate(50%, -50%) rotate(135deg); /* LTR */
- border-width: 0.125rem 0.125rem 0 0;
- border-style: solid;
- background: none;
- .dropbutton-wrapper.open
- [dir="rtl"] .dropbutton-wrapper.open
- }
-
- /* Variants */
-
- .no-touchevents .dropbutton--small .dropbutton__toggle::before,
- .no-touchevents .dropbutton--extrasmall .dropbutton__toggle::before {
- width: 0.4375rem;
- height: 0.4375rem;
- margin-top: calc(0.4375rem / (2 * -1.41429));
- }
-
- .dropbutton-wrapper.open .dropbutton__toggle::before {
- margin-top: calc(0.4375rem / (2 * 1.41429));
- }
- }
-
- /**
- * Item in the first dropbutton list item (that looks like a button).
- *
- * Duplicates base button styles.
- */
- .dropbutton__item:first-of-type {
- & > * {
- display: inline-block;
- margin: 0;
- padding: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size)) calc(var(--space-l) - var(--dropbutton-border-size));
- cursor: pointer;
- text-align: center;
- text-decoration: none;
- color: var(--button-fg-color);
- border: var(--dropbutton-border-size) solid transparent !important; /* 1 */
- border-radius: var(--button-border-radius-size);
- background-color: var(--button-bg-color);
- font-size: var(--dropbutton-font-size);
- font-weight: 700;
- line-height: var(--dropbutton-line-height);
- appearance: none;
- -webkit-font-smoothing: antialiased;
- }
-
- .dropbutton--multiple & > * {
- padding-inline: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size));
- }
-
- /* Variants */
- .no-touchevents .dropbutton--small & > * {
- padding-block: calc(var(--dropbutton-small-spacing-size) - var(--dropbutton-border-size));
- font-size: var(--dropbutton-small-font-size);
- line-height: var(--dropbutton-small-line-height);
- }
-
- .no-touchevents .dropbutton--extrasmall & > * {
- padding-top: calc(var(--dropbutton-extrasmall-spacing-size) - var(--dropbutton-border-size));
- padding-bottom: calc(var(--dropbutton-extrasmall-spacing-size) - var(--dropbutton-border-size));
- font-size: var(--dropbutton-extrasmall-font-size);
- line-height: var(--dropbutton-extrasmall-line-height);
- }
-
- & > *:hover,
- & > .button:hover {
- text-decoration: none;
- color: var(--button-fg-color);
- background-color: var(--button--hover-bg-color);
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
- }
-
- & > *:focus:hover,
- & > .button:focus:hover {
- box-shadow:
- 0 0 0 2px var(--color-white),
- 0 0 0 5px var(--color-focus);
- }
-
- & > *:focus {
- text-decoration: none;
- }
-
- & > *:active {
- color: var(--button-fg-color);
- background-color: var(--button--active-bg-color);
- }
-
- .dropbutton--multiple & > * {
- position: relative;
- z-index: 3;
- }
-
- .dropbutton--multiple & > *:focus {
- z-index: 2;
- }
-
- .dropbutton--multiple & > * {
- border-radius: var(--button-border-radius-size) 0 0 var(--button-border-radius-size); /* LTR */
- }
- [dir="rtl"] .dropbutton--multiple & > * {
- border-radius: 0 var(--button-border-radius-size) var(--button-border-radius-size) 0;
- }
- }
-
- .dropbutton > .dropbutton__item > a,
- .dropbutton > .dropbutton__item > .button {
- display: block;
- box-sizing: border-box;
- width: 100%;
- margin: 0;
- text-align: left; /* LTR */
- }
- [dir="rtl"] .dropbutton > .dropbutton__item > a,
- [dir="rtl"] .dropbutton > .dropbutton__item > .button {
- text-align: right;
- }
-
- .dropbutton-wrapper:not(.open) .dropbutton__item:first-of-type ~ .dropbutton__item {
- visibility: hidden;
- /**
- * By setting a height of 1px, the dropbutton items are hidden
- * from view while still occupying minimal space, ensuring the layout remains intact.
- */
- height: 1px;
- }
-
- /**
- * Non-first dropbutton list elements.
- */
- .dropbutton__item:first-of-type ~ .dropbutton__item {
- border: var(--dropbutton-border-size) solid var(--color-gray-200);
- border-bottom: 0;
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
- & ~ .dropbutton__item {
- border-top: 0;
- }
- }
-
- .dropbutton__item ~ .dropbutton__item:last-child {
- border-bottom: var(--dropbutton-border-size) solid var(--color-gray-200);
- border-radius: 0 0 var(--dropbutton-border-radius-size) var(--dropbutton-border-radius-size);
- }
-
- /**
- * Dropbutton items of non-first dropbutton list elements.
- */
- .dropbutton__item:first-of-type ~ .dropbutton__item {
- max-width: var(--dropbutton-item-max-width);
- }
-
- .dropbutton__item:first-of-type ~ .dropbutton__item > a,
- .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
- position: relative;
- padding: calc(var(--dropbutton-spacing-size) - var(--dropbutton-border-size));
- white-space: normal;
- text-decoration: none;
- color: var(--color-gray-800);
- border: var(--dropbutton-border-size) solid transparent !important; /* 1 */
- border-radius: var(--dropbutton-border-radius-size);
- background: var(--color-white);
- box-shadow: 0;
- font-size: var(--dropbutton-font-size);
- font-weight: normal;
- line-height: var(--dropbutton-line-height);
- -webkit-font-smoothing: antialiased;
- }
-
- .dropbutton__item:first-of-type ~ .dropbutton__item > a:not(:focus),
- .dropbutton__item:first-of-type ~ .dropbutton__item > .button:not(:focus) {
- z-index: 1;
- }
-
- /* Variants. */
- .no-touchevents .dropbutton--small .dropbutton__item:first-of-type ~ .dropbutton__item > a,
- .no-touchevents .dropbutton--small .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
- padding-top: var(--dropbutton-small-spacing-size);
- padding-bottom: var(--dropbutton-small-spacing-size);
- font-size: var(--dropbutton-small-font-size);
- line-height: var(--dropbutton-small-line-height);
- }
-
- .no-touchevents .dropbutton--extrasmall .dropbutton__item:first-of-type ~ .dropbutton__item > a,
- .no-touchevents .dropbutton--extrasmall .dropbutton__item:first-of-type ~ .dropbutton__item > .button {
- padding-top: var(--dropbutton-extrasmall-spacing-size);
- padding-bottom: var(--dropbutton-extrasmall-spacing-size);
- font-size: var(--dropbutton-extrasmall-font-size);
- line-height: var(--dropbutton-extrasmall-line-height);
- }
-
- /* States. */
- .dropbutton__item {
- & > *:focus {
- position: relative;
- z-index: 3;
- }
-
- &:first-of-type ~ & > *:hover {
- color: var(--color-text);
- background: var(--color-gray-050);
- }
-
- & > .button:not(:focus) {
- box-shadow: none;
- }
-
- &:first-of-type ~ & > *:focus {
- border-color: var(--color-focus) !important; /* 1 */
- box-shadow:
- inset 0 0 0 1px var(--color-focus),
- 0 0 0 1px var(--color-focus);
- }
- }
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.