_buttons.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // stylelint-disable selector-no-qualifying-type
  2. //
  3. // Base styles
  4. //
  5. .btn {
  6. display: inline-block;
  7. font-family: $btn-font-family;
  8. font-weight: $btn-font-weight;
  9. color: $body-color;
  10. text-align: center;
  11. white-space: $btn-white-space;
  12. vertical-align: middle;
  13. cursor: if($enable-pointer-cursor-for-buttons, pointer, null);
  14. user-select: none;
  15. background-color: transparent;
  16. border: $btn-border-width solid transparent;
  17. @include button-size($btn-padding-y, $btn-padding-x, $btn-font-size, $btn-line-height, $btn-border-radius);
  18. @include transition($btn-transition);
  19. @include hover() {
  20. color: $body-color;
  21. text-decoration: none;
  22. }
  23. &:focus,
  24. &.focus {
  25. outline: 0;
  26. box-shadow: $btn-focus-box-shadow;
  27. }
  28. // Disabled comes first so active can properly restyle
  29. &.disabled,
  30. &:disabled {
  31. opacity: $btn-disabled-opacity;
  32. @include box-shadow(none);
  33. }
  34. &:not(:disabled):not(.disabled):active,
  35. &:not(:disabled):not(.disabled).active {
  36. @include box-shadow($btn-active-box-shadow);
  37. &:focus {
  38. @include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow);
  39. }
  40. }
  41. }
  42. // Future-proof disabling of clicks on `<a>` elements
  43. a.btn.disabled,
  44. fieldset:disabled a.btn {
  45. pointer-events: none;
  46. }
  47. //
  48. // Alternate buttons
  49. //
  50. @each $color, $value in $theme-colors {
  51. .btn-#{$color} {
  52. @include button-variant($value, $value);
  53. }
  54. }
  55. @each $color, $value in $theme-colors {
  56. .btn-outline-#{$color} {
  57. @include button-outline-variant($value);
  58. }
  59. }
  60. //
  61. // Link buttons
  62. //
  63. // Make a button look and behave like a link
  64. .btn-link {
  65. font-weight: $font-weight-normal;
  66. color: $link-color;
  67. text-decoration: $link-decoration;
  68. @include hover() {
  69. color: $link-hover-color;
  70. text-decoration: $link-hover-decoration;
  71. }
  72. &:focus,
  73. &.focus {
  74. text-decoration: $link-hover-decoration;
  75. box-shadow: none;
  76. }
  77. &:disabled,
  78. &.disabled {
  79. color: $btn-link-disabled-color;
  80. pointer-events: none;
  81. }
  82. // No need for an active state here
  83. }
  84. //
  85. // Button Sizes
  86. //
  87. .btn-lg {
  88. @include button-size(
  89. $btn-padding-y-lg,
  90. $btn-padding-x-lg,
  91. $btn-font-size-lg,
  92. $btn-line-height-lg,
  93. $btn-border-radius-lg
  94. );
  95. }
  96. .btn-sm {
  97. @include button-size(
  98. $btn-padding-y-sm,
  99. $btn-padding-x-sm,
  100. $btn-font-size-sm,
  101. $btn-line-height-sm,
  102. $btn-border-radius-sm
  103. );
  104. }
  105. //
  106. // Block button
  107. //
  108. .btn-block {
  109. display: block;
  110. width: 100%;
  111. // Vertically space out multiple block buttons
  112. + .btn-block {
  113. margin-top: $btn-block-spacing-y;
  114. }
  115. }
  116. // Specificity overrides
  117. input[type='submit'],
  118. input[type='reset'],
  119. input[type='button'] {
  120. &.btn-block {
  121. width: 100%;
  122. }
  123. }