_buttons.scss 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. .btn {
  2. --btn-bg: #{$color-white};
  3. --btn-text-color: #{$color-text};
  4. --btn-border-color: #{$color-border};
  5. --btn-padding-x: #{$gap-3};
  6. --btn-hover-bg: var(--btn-bg);
  7. --btn-hover-border-color: #{$color-border-hover};
  8. --btn-focus-color: #{rgba($color-text, .3)};
  9. --btn-height: 2.5rem;
  10. &.disabled {
  11. --btn-text-color: #{$color-muted};
  12. cursor: not-allowed;
  13. }
  14. background: var(--btn-bg);
  15. color: var(--btn-text-color);
  16. border: 1px solid var(--btn-border-color);
  17. display: inline-flex;
  18. align-items: center;
  19. justify-content: center;
  20. border-radius: $border-radius-lg;
  21. text-decoration: none;
  22. font-weight: $font-weight-medium;
  23. font-size: $font-size-h6;
  24. height: var(--btn-height);
  25. min-width: var(--btn-height);
  26. padding: 0 var(--btn-padding-x);
  27. box-shadow: rgba(0, 0, 0, 0.04) 0px 10px 15px -3px, rgba(0, 0, 0, 0.02) 0px 4px 6px -2px;
  28. user-select: none;
  29. transition: .3s opacity, .3s transform, .3s border-color, .3s background-color;
  30. cursor: pointer;
  31. white-space: nowrap;
  32. @at-root a#{&}:hover {
  33. color: var(--btn-hover-color, var(--btn-text-color));
  34. border-color: var(--btn-hover-border-color);
  35. background-color: var(--btn-hover-bg, var(--btn-bg));
  36. }
  37. &:focus-visible {
  38. box-shadow: 0 0 0 3px var(--btn-focus-color);
  39. outline: none;
  40. }
  41. .icon {
  42. width: divide(20, 16) * 1em;
  43. height: divide(20, 16) * 1em;
  44. vertical-align: bottom;
  45. margin-right: $gap-2;
  46. margin-left: -$gap-1;
  47. }
  48. }
  49. .btn-block {
  50. width: 100%;
  51. }
  52. .btn-icon {
  53. padding-left: 0;
  54. padding-right: 0;
  55. .icon {
  56. margin: 0;
  57. }
  58. }
  59. .btn-sm {
  60. --btn-height: 1.75rem;
  61. --btn-padding-x: #{$gap-2};
  62. font-size: $font-size-h6;
  63. svg {
  64. width: 1rem;
  65. height: 1rem;
  66. stroke-width: 2;
  67. margin-right: $gap-1;
  68. }
  69. }
  70. .btn-lg {
  71. @include media-breakpoint-up(md) {
  72. height: 3.25rem;
  73. --btn-padding-x: #{$gap-4};
  74. font-size: $font-size-h4;
  75. font-weight: $font-weight-medium;
  76. svg {
  77. width: 1.5rem;
  78. height: 1.5rem;
  79. margin-right: $gap-3;
  80. margin-left: -$gap-1;
  81. stroke-width: 2;
  82. }
  83. }
  84. }
  85. .btn-circle {
  86. border-radius: 50%;
  87. }
  88. .btn-link {
  89. background: transparent;
  90. color: $color-muted;
  91. svg {
  92. stroke-width: 1.5;
  93. }
  94. &:hover {
  95. color: $color-text;
  96. }
  97. }
  98. .btn-outline {
  99. border-color: var(--btn-color);
  100. color: var(--btn-color);
  101. background: transparent;
  102. }
  103. @each $name, $color in map-merge($colors, $extra-colors) {
  104. .btn-#{$name} {
  105. --btn-color: #{$color};
  106. --btn-color-darken: #{darken($color, 5%)};
  107. --btn-bg: #{$color};
  108. --btn-text-color: #{contrast-color($color)};
  109. --btn-border-color: #{$color};
  110. --btn-hover-bg: #{darken($color, 5%)};
  111. --btn-hover-border-color: #{darken($color, 5%)};
  112. &.disabled {
  113. --btn-bg: #{$color-muted};
  114. --btn-text-color: #{$color-white};
  115. --btn-border-color: #{$color-muted};
  116. }
  117. }
  118. }
  119. .btn-list {
  120. --btn-list-margin: .5rem;
  121. display: flex;
  122. margin: 0 calc(var(--btn-list-margin) * -1) calc(var(--btn-list-margin) * -1) 0;
  123. > * {
  124. margin: 0 var(--btn-list-margin) var(--btn-list-margin) 0;
  125. }
  126. }
  127. @each $breakpoint in map-keys($grid-breakpoints) {
  128. @if $breakpoint != 0 {
  129. .btn-responsive-#{$breakpoint} {
  130. @include media-breakpoint-down($breakpoint) {
  131. .icon {
  132. margin-left: -.5rem;
  133. margin-right: -.5rem;
  134. }
  135. .btn-responsive-text {
  136. display: none;
  137. }
  138. }
  139. }
  140. }
  141. }