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