You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
6.9 KiB

8 months ago
  1. //
  2. // Base styles
  3. //
  4. .btn {
  5. // scss-docs-start btn-css-vars
  6. --#{$prefix}btn-padding-x: #{$btn-padding-x};
  7. --#{$prefix}btn-padding-y: #{$btn-padding-y};
  8. --#{$prefix}btn-font-family: #{$btn-font-family};
  9. @include rfs($btn-font-size, --#{$prefix}btn-font-size);
  10. --#{$prefix}btn-font-weight: #{$btn-font-weight};
  11. --#{$prefix}btn-line-height: #{$btn-line-height};
  12. --#{$prefix}btn-color: #{$btn-color};
  13. --#{$prefix}btn-bg: transparent;
  14. --#{$prefix}btn-border-width: #{$btn-border-width};
  15. --#{$prefix}btn-border-color: transparent;
  16. --#{$prefix}btn-border-radius: #{$btn-border-radius};
  17. --#{$prefix}btn-hover-border-color: transparent;
  18. --#{$prefix}btn-box-shadow: #{$btn-box-shadow};
  19. --#{$prefix}btn-disabled-opacity: #{$btn-disabled-opacity};
  20. --#{$prefix}btn-focus-box-shadow: 0 0 0 #{$btn-focus-width} rgba(var(--#{$prefix}btn-focus-shadow-rgb), .5);
  21. // scss-docs-end btn-css-vars
  22. display: inline-block;
  23. padding: var(--#{$prefix}btn-padding-y) var(--#{$prefix}btn-padding-x);
  24. font-family: var(--#{$prefix}btn-font-family);
  25. @include font-size(var(--#{$prefix}btn-font-size));
  26. font-weight: var(--#{$prefix}btn-font-weight);
  27. line-height: var(--#{$prefix}btn-line-height);
  28. color: var(--#{$prefix}btn-color);
  29. text-align: center;
  30. text-decoration: if($link-decoration == none, null, none);
  31. white-space: $btn-white-space;
  32. vertical-align: middle;
  33. cursor: if($enable-button-pointers, pointer, null);
  34. user-select: none;
  35. border: var(--#{$prefix}btn-border-width) solid var(--#{$prefix}btn-border-color);
  36. @include border-radius(var(--#{$prefix}btn-border-radius));
  37. @include gradient-bg(var(--#{$prefix}btn-bg));
  38. @include box-shadow(var(--#{$prefix}btn-box-shadow));
  39. @include transition($btn-transition);
  40. &:hover {
  41. color: var(--#{$prefix}btn-hover-color);
  42. text-decoration: if($link-hover-decoration == underline, none, null);
  43. background-color: var(--#{$prefix}btn-hover-bg);
  44. border-color: var(--#{$prefix}btn-hover-border-color);
  45. }
  46. .btn-check + &:hover {
  47. // override for the checkbox/radio buttons
  48. color: var(--#{$prefix}btn-color);
  49. background-color: var(--#{$prefix}btn-bg);
  50. border-color: var(--#{$prefix}btn-border-color);
  51. }
  52. &:focus-visible {
  53. color: var(--#{$prefix}btn-hover-color);
  54. @include gradient-bg(var(--#{$prefix}btn-hover-bg));
  55. border-color: var(--#{$prefix}btn-hover-border-color);
  56. outline: 0;
  57. // Avoid using mixin so we can pass custom focus shadow properly
  58. @if $enable-shadows {
  59. box-shadow: var(--#{$prefix}btn-box-shadow), var(--#{$prefix}btn-focus-box-shadow);
  60. } @else {
  61. box-shadow: var(--#{$prefix}btn-focus-box-shadow);
  62. }
  63. }
  64. .btn-check:focus-visible + & {
  65. border-color: var(--#{$prefix}btn-hover-border-color);
  66. outline: 0;
  67. // Avoid using mixin so we can pass custom focus shadow properly
  68. @if $enable-shadows {
  69. box-shadow: var(--#{$prefix}btn-box-shadow), var(--#{$prefix}btn-focus-box-shadow);
  70. } @else {
  71. box-shadow: var(--#{$prefix}btn-focus-box-shadow);
  72. }
  73. }
  74. .btn-check:checked + &,
  75. :not(.btn-check) + &:active,
  76. &:first-child:active,
  77. &.active,
  78. &.show {
  79. color: var(--#{$prefix}btn-active-color);
  80. background-color: var(--#{$prefix}btn-active-bg);
  81. // Remove CSS gradients if they're enabled
  82. background-image: if($enable-gradients, none, null);
  83. border-color: var(--#{$prefix}btn-active-border-color);
  84. @include box-shadow(var(--#{$prefix}btn-active-shadow));
  85. &:focus-visible {
  86. // Avoid using mixin so we can pass custom focus shadow properly
  87. @if $enable-shadows {
  88. box-shadow: var(--#{$prefix}btn-active-shadow), var(--#{$prefix}btn-focus-box-shadow);
  89. } @else {
  90. box-shadow: var(--#{$prefix}btn-focus-box-shadow);
  91. }
  92. }
  93. }
  94. .btn-check:checked:focus-visible + & {
  95. // Avoid using mixin so we can pass custom focus shadow properly
  96. @if $enable-shadows {
  97. box-shadow: var(--#{$prefix}btn-active-shadow), var(--#{$prefix}btn-focus-box-shadow);
  98. } @else {
  99. box-shadow: var(--#{$prefix}btn-focus-box-shadow);
  100. }
  101. }
  102. &:disabled,
  103. &.disabled,
  104. fieldset:disabled & {
  105. color: var(--#{$prefix}btn-disabled-color);
  106. pointer-events: none;
  107. background-color: var(--#{$prefix}btn-disabled-bg);
  108. background-image: if($enable-gradients, none, null);
  109. border-color: var(--#{$prefix}btn-disabled-border-color);
  110. opacity: var(--#{$prefix}btn-disabled-opacity);
  111. @include box-shadow(none);
  112. }
  113. }
  114. //
  115. // Alternate buttons
  116. //
  117. // scss-docs-start btn-variant-loops
  118. @each $color, $value in $theme-colors {
  119. .btn-#{$color} {
  120. @if $color == "light" {
  121. @include button-variant(
  122. $value,
  123. $value,
  124. $hover-background: shade-color($value, $btn-hover-bg-shade-amount),
  125. $hover-border: shade-color($value, $btn-hover-border-shade-amount),
  126. $active-background: shade-color($value, $btn-active-bg-shade-amount),
  127. $active-border: shade-color($value, $btn-active-border-shade-amount)
  128. );
  129. } @else if $color == "dark" {
  130. @include button-variant(
  131. $value,
  132. $value,
  133. $hover-background: tint-color($value, $btn-hover-bg-tint-amount),
  134. $hover-border: tint-color($value, $btn-hover-border-tint-amount),
  135. $active-background: tint-color($value, $btn-active-bg-tint-amount),
  136. $active-border: tint-color($value, $btn-active-border-tint-amount)
  137. );
  138. } @else {
  139. @include button-variant($value, $value);
  140. }
  141. }
  142. }
  143. @each $color, $value in $theme-colors {
  144. .btn-outline-#{$color} {
  145. @include button-outline-variant($value);
  146. }
  147. }
  148. // scss-docs-end btn-variant-loops
  149. //
  150. // Link buttons
  151. //
  152. // Make a button look and behave like a link
  153. .btn-link {
  154. --#{$prefix}btn-font-weight: #{$font-weight-normal};
  155. --#{$prefix}btn-color: #{$btn-link-color};
  156. --#{$prefix}btn-bg: transparent;
  157. --#{$prefix}btn-border-color: transparent;
  158. --#{$prefix}btn-hover-color: #{$btn-link-hover-color};
  159. --#{$prefix}btn-hover-border-color: transparent;
  160. --#{$prefix}btn-active-color: #{$btn-link-hover-color};
  161. --#{$prefix}btn-active-border-color: transparent;
  162. --#{$prefix}btn-disabled-color: #{$btn-link-disabled-color};
  163. --#{$prefix}btn-disabled-border-color: transparent;
  164. --#{$prefix}btn-box-shadow: 0 0 0 #000; // Can't use `none` as keyword negates all values when used with multiple shadows
  165. --#{$prefix}btn-focus-shadow-rgb: #{$btn-link-focus-shadow-rgb};
  166. text-decoration: $link-decoration;
  167. @if $enable-gradients {
  168. background-image: none;
  169. }
  170. &:hover,
  171. &:focus-visible {
  172. text-decoration: $link-hover-decoration;
  173. }
  174. &:focus-visible {
  175. color: var(--#{$prefix}btn-color);
  176. }
  177. &:hover {
  178. color: var(--#{$prefix}btn-hover-color);
  179. }
  180. // No need for an active state here
  181. }
  182. //
  183. // Button Sizes
  184. //
  185. .btn-lg {
  186. @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $btn-font-size-lg, $btn-border-radius-lg);
  187. }
  188. .btn-sm {
  189. @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $btn-font-size-sm, $btn-border-radius-sm);
  190. }