_buttons.scss 2.7 KB

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