_buttons.scss 2.5 KB

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