_buttons.scss 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. @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. background-color: transparent;
  68. @include hover {
  69. color: $link-hover-color;
  70. text-decoration: $link-hover-decoration;
  71. background-color: transparent;
  72. border-color: transparent;
  73. }
  74. &:focus,
  75. &.focus {
  76. text-decoration: $link-hover-decoration;
  77. border-color: transparent;
  78. box-shadow: none;
  79. }
  80. &:disabled,
  81. &.disabled {
  82. color: $btn-link-disabled-color;
  83. pointer-events: none;
  84. }
  85. // No need for an active state here
  86. }
  87. //
  88. // Button Sizes
  89. //
  90. .btn-lg {
  91. @include button-size($btn-padding-y-lg, $btn-padding-x-lg, $font-size-lg, $btn-line-height-lg, $btn-border-radius-lg);
  92. }
  93. .btn-sm {
  94. @include button-size($btn-padding-y-sm, $btn-padding-x-sm, $font-size-sm, $btn-line-height-sm, $btn-border-radius-sm);
  95. }
  96. //
  97. // Block button
  98. //
  99. .btn-block {
  100. display: block;
  101. width: 100%;
  102. // Vertically space out multiple block buttons
  103. + .btn-block {
  104. margin-top: $btn-block-spacing-y;
  105. }
  106. }
  107. // Specificity overrides
  108. input[type="submit"],
  109. input[type="reset"],
  110. input[type="button"] {
  111. &.btn-block {
  112. width: 100%;
  113. }
  114. }