You are here

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