You are here

button.css in Drupal 10

Structural styles for Claro's UI buttons

Apply these classes to button elements (<button>, <input type="button" />).

File

core/themes/claro/css/components/button.css
View source
  1. /*
  2. * DO NOT EDIT THIS FILE.
  3. * See the following change record for more information,
  4. * https://www.drupal.org/node/3084859
  5. * @preserve
  6. */
  7. /**
  8. * @file
  9. * Structural styles for Claro's UI buttons
  10. *
  11. * Apply these classes to button elements (
  12. */
  13. /**
  14. * Buttons.
  15. *
  16. * 1. Padding widths detracted by width of the transparent borders to make
  17. * button size match with design system.
  18. * 2. Transparent border is needed for high contrast mode. This has to be set to
  19. * !important to render Firefox borders with consistent width in high
  20. * contrast mode.
  21. * 3. Prevent fat text in WebKit.
  22. *
  23. * @todo Consider moving box-sizing into base.css under a universal selector.
  24. * See https://www.drupal.org/node/2124251
  25. */
  26. /**
  27. * Base button styles.
  28. *
  29. * These styles have been duplicated to dropbutton.css and action-links.css
  30. * since those components inherits most of these design elements. Whenever
  31. * making changes to this file, remember to check if that needs to be applied to
  32. * dropbutton.css or action-links.css as well.
  33. */
  34. .button {
  35. display: inline-block;
  36. margin: var(--space-m) var(--space-s) var(--space-m) 0; /* LTR */
  37. padding: calc(var(--space-m) - 1px) calc(var(--space-l) - 1px); /* 1 */
  38. cursor: pointer;
  39. text-align: center;
  40. text-decoration: none;
  41. color: var(--button-fg-color);
  42. border: 1px solid transparent !important; /* 2 */
  43. border-radius: var(--button-border-radius-size);
  44. background-color: var(--button-bg-color);
  45. font-size: var(--font-size-base);
  46. font-weight: 700;
  47. line-height: 1rem;
  48. -webkit-appearance: none;
  49. appearance: none;
  50. -webkit-font-smoothing: antialiased; /* 3 */
  51. }
  52. [dir="rtl"] .button {
  53. margin: var(--space-m) 0 var(--space-m) var(--space-s);
  54. }
  55. .button:not(:focus) {
  56. box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  57. }
  58. .button:hover {
  59. text-decoration: none;
  60. background-color: var(--button--hover-bg-color);
  61. }
  62. .button:focus {
  63. text-decoration: none;
  64. }
  65. .button:active {
  66. background-color: var(--button--active-bg-color);
  67. }
  68. /* Common styles for small buttons */
  69. .no-touchevents .button--small {
  70. margin: var(--space-s) var(--space-xs) var(--space-s) 0; /* LTR */
  71. padding: calc(var(--space-xs) - 1px) calc(var(--space-m) - 1px); /* 1 */
  72. font-size: var(--font-size-xs);
  73. }
  74. /* Common styles for extra small buttons */
  75. .no-touchevents .button--extrasmall {
  76. margin: var(--space-xs) var(--space-xs) var(--space-xs) 0; /* LTR */
  77. padding: calc(calc(var(--space-xs) / 2) - 1px) calc(var(--space-s) - 1px); /* 1 */
  78. font-size: var(--font-size-xs);
  79. }
  80. [dir="rtl"].no-touchevents .button--small,
  81. [dir="rtl"].no-touchevents .button--extrasmall {
  82. margin-right: 0;
  83. margin-left: var(--space-xs);
  84. }
  85. /* Styles for action link buttons */
  86. .button--action {
  87. margin: 0;
  88. }
  89. .button--action::before {
  90. margin-left: -0.25em; /* LTR */
  91. padding-right: 0.25em; /* LTR */
  92. content: "+";
  93. font-weight: 900;
  94. }
  95. [dir="rtl"] .button--action::before {
  96. margin-right: -0.25em;
  97. margin-left: 0;
  98. padding-right: 0;
  99. padding-left: 0.25em;
  100. }
  101. a.button:hover,
  102. a.button:active {
  103. color: var(--button-fg-color);
  104. }
  105. /* Primary button styles */
  106. .button--primary {
  107. color: var(--button-fg-color--primary);
  108. background-color: var(--button-bg-color--primary);
  109. }
  110. .button--primary:hover {
  111. color: var(--button-fg-color--primary);
  112. background-color: var(--button--hover-bg-color--primary);
  113. }
  114. .button--primary:active {
  115. background-color: var(--button--active-bg-color--primary);
  116. }
  117. a.button--primary:hover,
  118. a.button--primary:active {
  119. color: var(--button-fg-color--primary);
  120. }
  121. /* Danger button styles */
  122. .button--danger {
  123. color: var(--button-fg-color--danger);
  124. background-color: var(--button-bg-color--danger);
  125. }
  126. .button--danger:hover {
  127. color: var(--button-fg-color--danger);
  128. background-color: var(--button--hover-bg-color--danger);
  129. }
  130. .button--danger:active {
  131. background-color: var(--button--active-bg-color--danger);
  132. }
  133. a.button--danger:hover,
  134. a.button--danger:active {
  135. color: var(--button-fg-color--danger);
  136. }
  137. /**
  138. * Disabled state styles as last.
  139. *
  140. * Overrides every definitions before, including variants.
  141. */
  142. .button:disabled,
  143. .button.is-disabled {
  144. color: var(--button--disabled-fg-color);
  145. background-color: var(--button--disabled-bg-color);
  146. }
  147. .button--primary:disabled,
  148. .button--primary.is-disabled {
  149. color: var(--button--disabled-fg-color--primary);
  150. background-color: var(--button--disabled-bg-color--primary);
  151. }
  152. /* Make disabled behave like a [disabled] or
  153. .button.is-disabled {
  154. -webkit-user-select: none;
  155. user-select: none;
  156. pointer-events: none;
  157. }
  158. /**
  159. * Style a clickable/tappable element as a link. Duplicates the base style for
  160. * the tag, plus a reset for padding, borders and background.
  161. */
  162. .link {
  163. display: inline;
  164. padding: 0;
  165. cursor: pointer;
  166. text-decoration: underline;
  167. border: 0;
  168. background: none;
  169. -webkit-appearance: none;
  170. appearance: none;
  171. }