_buttons.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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($btn-padding-y-lg, $btn-padding-x-lg, $btn-font-size-lg, $btn-line-height-lg, $btn-border-radius-lg);
  89. }
  90. .btn-sm {
  91. @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $btn-font-size-sm, $btn-line-height-sm, $btn-border-radius-sm);
  92. }
  93. //
  94. // Block button
  95. //
  96. .btn-block {
  97. display: block;
  98. width: 100%;
  99. // Vertically space out multiple block buttons
  100. + .btn-block {
  101. margin-top: $btn-block-spacing-y;
  102. }
  103. }
  104. // Specificity overrides
  105. input[type="submit"],
  106. input[type="reset"],
  107. input[type="button"] {
  108. &.btn-block {
  109. width: 100%;
  110. }
  111. }