UNPKG

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