_buttons.scss 2.6KB

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