buttons.less 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. // stylelint-disable selector-no-qualifying-type
  2. //
  3. // Buttons
  4. // --------------------------------------------------
  5. // Base styles
  6. // --------------------------------------------------
  7. .btn {
  8. display: inline-block;
  9. margin-bottom: 0; // For input.btn
  10. font-weight: @btn-font-weight;
  11. text-align: center;
  12. white-space: nowrap;
  13. vertical-align: middle;
  14. touch-action: manipulation;
  15. cursor: pointer;
  16. background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
  17. border: 1px solid transparent;
  18. .button-size(
  19. @padding-base-vertical; @padding-base-horizontal; @font-size-base; @line-height-base;
  20. @btn-border-radius-base
  21. );
  22. user-select: none;
  23. &,
  24. &:active,
  25. &.active {
  26. &:focus,
  27. &.focus {
  28. .tab-focus();
  29. }
  30. }
  31. &:hover,
  32. &:focus,
  33. &.focus {
  34. color: @btn-default-color;
  35. text-decoration: none;
  36. }
  37. &:active,
  38. &.active {
  39. background-image: none;
  40. outline: 0;
  41. box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
  42. }
  43. &.disabled,
  44. &[disabled],
  45. fieldset[disabled] & {
  46. cursor: @cursor-disabled;
  47. opacity: 0.65;
  48. box-shadow: none;
  49. }
  50. a& {
  51. &.disabled,
  52. fieldset[disabled] & {
  53. pointer-events: none; // Future-proof disabling of clicks on `<a>` elements
  54. }
  55. }
  56. }
  57. // Alternate buttons
  58. // --------------------------------------------------
  59. .btn-default {
  60. .button-variant(@btn-default-color; @btn-default-bg; @btn-default-border);
  61. }
  62. .btn-primary {
  63. .button-variant(@btn-primary-color; @btn-primary-bg; @btn-primary-border);
  64. }
  65. // Success appears as green
  66. .btn-success {
  67. .button-variant(@btn-success-color; @btn-success-bg; @btn-success-border);
  68. }
  69. // Info appears as blue-green
  70. .btn-info {
  71. .button-variant(@btn-info-color; @btn-info-bg; @btn-info-border);
  72. }
  73. // Warning appears as orange
  74. .btn-warning {
  75. .button-variant(@btn-warning-color; @btn-warning-bg; @btn-warning-border);
  76. }
  77. // Danger and error appear as red
  78. .btn-danger {
  79. .button-variant(@btn-danger-color; @btn-danger-bg; @btn-danger-border);
  80. }
  81. // Link buttons
  82. // -------------------------
  83. // Make a button look and behave like a link
  84. .btn-link {
  85. font-weight: 400;
  86. color: @link-color;
  87. border-radius: 0;
  88. &,
  89. &:active,
  90. &.active,
  91. &[disabled],
  92. fieldset[disabled] & {
  93. background-color: transparent;
  94. box-shadow: none;
  95. }
  96. &,
  97. &:hover,
  98. &:focus,
  99. &:active {
  100. border-color: transparent;
  101. }
  102. &:hover,
  103. &:focus {
  104. color: @link-hover-color;
  105. text-decoration: @link-hover-decoration;
  106. background-color: transparent;
  107. }
  108. &[disabled],
  109. fieldset[disabled] & {
  110. &:hover,
  111. &:focus {
  112. color: @btn-link-disabled-color;
  113. text-decoration: none;
  114. }
  115. }
  116. }
  117. // Button Sizes
  118. // --------------------------------------------------
  119. .btn-lg {
  120. // line-height: ensure even-numbered height of button next to large input
  121. .button-size(
  122. @padding-large-vertical; @padding-large-horizontal; @font-size-large;
  123. @line-height-large; @btn-border-radius-large
  124. );
  125. }
  126. .btn-sm {
  127. // line-height: ensure proper height of button next to small input
  128. .button-size(
  129. @padding-small-vertical; @padding-small-horizontal; @font-size-small;
  130. @line-height-small; @btn-border-radius-small
  131. );
  132. }
  133. .btn-xs {
  134. .button-size(
  135. @padding-xs-vertical; @padding-xs-horizontal; @font-size-small; @line-height-small;
  136. @btn-border-radius-small
  137. );
  138. }
  139. // Block button
  140. // --------------------------------------------------
  141. .btn-block {
  142. display: block;
  143. width: 100%;
  144. }
  145. // Vertically space out multiple block buttons
  146. .btn-block + .btn-block {
  147. margin-top: 5px;
  148. }
  149. // Specificity overrides
  150. input[type='submit'],
  151. input[type='reset'],
  152. input[type='button'] {
  153. &.btn-block {
  154. width: 100%;
  155. }
  156. }