UNPKG

15.8 kBSCSSView Raw
1// Name: Button
2// Description: Styles for buttons
3//
4// Component: `uk-button`
5//
6// Sub-objects: `uk-button-group`
7//
8// Modifiers: `uk-button-default`
9// `uk-button-primary`
10// `uk-button-secondary`
11// `uk-button-danger`
12// `uk-button-text`
13// `uk-button-link`
14// `uk-button-small`
15// `uk-button-large`
16//
17// States: `uk-active`
18//
19// ========================================================================
20
21
22// Variables
23// ========================================================================
24
25$button-line-height: $global-control-height !default;
26$button-small-line-height: $global-control-small-height !default;
27$button-large-line-height: $global-control-large-height !default;
28
29$button-font-size: $global-font-size !default;
30$button-small-font-size: $global-small-font-size !default;
31$button-large-font-size: $global-medium-font-size !default;
32
33$button-padding-horizontal: $global-gutter !default;
34$button-small-padding-horizontal: $global-small-gutter !default;
35$button-large-padding-horizontal: $global-medium-gutter !default;
36
37$button-default-background: $global-muted-background !default;
38$button-default-color: $global-emphasis-color !default;
39$button-default-hover-background: darken($button-default-background, 5%) !default;
40$button-default-hover-color: $global-emphasis-color !default;
41$button-default-active-background: darken($button-default-background, 10%) !default;
42$button-default-active-color: $global-emphasis-color !default;
43
44$button-primary-background: $global-primary-background !default;
45$button-primary-color: $global-inverse-color !default;
46$button-primary-hover-background: darken($button-primary-background, 5%) !default;
47$button-primary-hover-color: $global-inverse-color !default;
48$button-primary-active-background: darken($button-primary-background, 10%) !default;
49$button-primary-active-color: $global-inverse-color !default;
50
51$button-secondary-background: $global-secondary-background !default;
52$button-secondary-color: $global-inverse-color !default;
53$button-secondary-hover-background: darken($button-secondary-background, 5%) !default;
54$button-secondary-hover-color: $global-inverse-color !default;
55$button-secondary-active-background: darken($button-secondary-background, 10%) !default;
56$button-secondary-active-color: $global-inverse-color !default;
57
58$button-danger-background: $global-danger-background !default;
59$button-danger-color: $global-inverse-color !default;
60$button-danger-hover-background: darken($button-danger-background, 5%) !default;
61$button-danger-hover-color: $global-inverse-color !default;
62$button-danger-active-background: darken($button-danger-background, 10%) !default;
63$button-danger-active-color: $global-inverse-color !default;
64
65$button-disabled-background: $global-muted-background !default;
66$button-disabled-color: $global-muted-color !default;
67
68$button-text-line-height: $global-line-height !default;
69$button-text-color: $global-muted-color !default;
70$button-text-hover-color: $global-color !default;
71$button-text-disabled-color: $global-muted-color !default;
72
73$button-link-line-height: $global-line-height !default;
74$button-link-color: $global-link-color !default;
75$button-link-hover-color: $global-link-hover-color !default;
76$button-link-hover-text-decoration: underline !default;
77$button-link-disabled-color: $global-muted-color !default;
78
79
80/* ========================================================================
81 Component: Button
82 ========================================================================== */
83
84/*
85 * 1. Remove margins in Chrome, Safari and Opera.
86 * 2. Remove borders for `button`.
87 * 3. Address `overflow` set to `hidden` in IE.
88 * 4. Correct `font` properties and `color` not being inherited for `button`.
89 * 5. Remove the inheritance of text transform in Edge, Firefox, and IE.
90 * 6. Style
91 * 7. `line-height` is used to create a height because it also centers the text vertically for `a` elements.
92 * Better would be to use height and flexbox to center the text vertically but flexbox doesn't work in Firefox on `button` elements.
93 * 8. Align text if button has a width
94 * 9. Required for `a`.
95 */
96
97.uk-button {
98 /* 1 */
99 margin: 0;
100 /* 2 */
101 border: none;
102 /* 3 */
103 overflow: visible;
104 /* 4 */
105 font: inherit;
106 color: inherit;
107 /* 5 */
108 text-transform: none;
109 /* 6 */
110 display: inline-block;
111 box-sizing: border-box;
112 padding: 0 $button-padding-horizontal;
113 vertical-align: middle;
114 font-size: $button-font-size;
115 /* 7 */
116 line-height: $button-line-height;
117 /* 8 */
118 text-align: center;
119 /* 9 */
120 text-decoration: none;
121 @if(mixin-exists(hook-button)) {@include hook-button();}
122}
123
124.uk-button:not(:disabled) { cursor: pointer; }
125
126/*
127 * Remove the inner border and padding in Firefox.
128 */
129
130.uk-button::-moz-focus-inner {
131 border: 0;
132 padding: 0;
133}
134
135/* Hover */
136.uk-button:hover {
137 /* 9 */
138 text-decoration: none;
139 @if(mixin-exists(hook-button-hover)) {@include hook-button-hover();}
140}
141
142/* Focus */
143.uk-button:focus {
144 outline: none;
145 @if(mixin-exists(hook-button-focus)) {@include hook-button-focus();}
146}
147
148/* OnClick + Active */
149.uk-button:active,
150.uk-button.uk-active {
151 @if(mixin-exists(hook-button-active)) {@include hook-button-active();}
152}
153
154
155/* Style modifiers
156 ========================================================================== */
157
158/*
159 * Default
160 */
161
162.uk-button-default {
163 background-color: $button-default-background;
164 color: $button-default-color;
165 @if(mixin-exists(hook-button-default)) {@include hook-button-default();}
166}
167
168/* Hover + Focus */
169.uk-button-default:hover,
170.uk-button-default:focus {
171 background-color: $button-default-hover-background;
172 color: $button-default-hover-color;
173 @if(mixin-exists(hook-button-default-hover)) {@include hook-button-default-hover();}
174}
175
176/* OnClick + Active */
177.uk-button-default:active,
178.uk-button-default.uk-active {
179 background-color: $button-default-active-background;
180 color: $button-default-active-color;
181 @if(mixin-exists(hook-button-default-active)) {@include hook-button-default-active();}
182}
183
184/*
185 * Primary
186 */
187
188.uk-button-primary {
189 background-color: $button-primary-background;
190 color: $button-primary-color;
191 @if(mixin-exists(hook-button-primary)) {@include hook-button-primary();}
192}
193
194/* Hover + Focus */
195.uk-button-primary:hover,
196.uk-button-primary:focus {
197 background-color: $button-primary-hover-background;
198 color: $button-primary-hover-color;
199 @if(mixin-exists(hook-button-primary-hover)) {@include hook-button-primary-hover();}
200}
201
202/* OnClick + Active */
203.uk-button-primary:active,
204.uk-button-primary.uk-active {
205 background-color: $button-primary-active-background;
206 color: $button-primary-active-color;
207 @if(mixin-exists(hook-button-primary-active)) {@include hook-button-primary-active();}
208}
209
210/*
211 * Secondary
212 */
213
214.uk-button-secondary {
215 background-color: $button-secondary-background;
216 color: $button-secondary-color;
217 @if(mixin-exists(hook-button-secondary)) {@include hook-button-secondary();}
218}
219
220/* Hover + Focus */
221.uk-button-secondary:hover,
222.uk-button-secondary:focus {
223 background-color: $button-secondary-hover-background;
224 color: $button-secondary-hover-color;
225 @if(mixin-exists(hook-button-secondary-hover)) {@include hook-button-secondary-hover();}
226}
227
228/* OnClick + Active */
229.uk-button-secondary:active,
230.uk-button-secondary.uk-active {
231 background-color: $button-secondary-active-background;
232 color: $button-secondary-active-color;
233 @if(mixin-exists(hook-button-secondary-active)) {@include hook-button-secondary-active();}
234}
235
236/*
237 * Danger
238 */
239
240.uk-button-danger {
241 background-color: $button-danger-background;
242 color: $button-danger-color;
243 @if(mixin-exists(hook-button-danger)) {@include hook-button-danger();}
244}
245
246/* Hover + Focus */
247.uk-button-danger:hover,
248.uk-button-danger:focus {
249 background-color: $button-danger-hover-background;
250 color: $button-danger-hover-color;
251 @if(mixin-exists(hook-button-danger-hover)) {@include hook-button-danger-hover();}
252}
253
254/* OnClick + Active */
255.uk-button-danger:active,
256.uk-button-danger.uk-active {
257 background-color: $button-danger-active-background;
258 color: $button-danger-active-color;
259 @if(mixin-exists(hook-button-danger-active)) {@include hook-button-danger-active();}
260}
261
262/*
263 * Disabled
264 * The same for all style modifiers
265 */
266
267.uk-button-default:disabled,
268.uk-button-primary:disabled,
269.uk-button-secondary:disabled,
270.uk-button-danger:disabled {
271 background-color: $button-disabled-background;
272 color: $button-disabled-color;
273 @if(mixin-exists(hook-button-disabled)) {@include hook-button-disabled();}
274}
275
276
277/* Size modifiers
278 ========================================================================== */
279
280.uk-button-small {
281 padding: 0 $button-small-padding-horizontal;
282 line-height: $button-small-line-height;
283 font-size: $button-small-font-size;
284 @if(mixin-exists(hook-button-small)) {@include hook-button-small();}
285}
286
287.uk-button-large {
288 padding: 0 $button-large-padding-horizontal;
289 line-height: $button-large-line-height;
290 font-size: $button-large-font-size;
291 @if(mixin-exists(hook-button-large)) {@include hook-button-large();}
292}
293
294
295/* Text modifiers
296 ========================================================================== */
297
298/*
299 * Text
300 * 1. Reset
301 * 2. Style
302 */
303
304.uk-button-text {
305 /* 1 */
306 padding: 0;
307 line-height: $button-text-line-height;
308 background: none;
309 /* 2 */
310 color: $button-text-color;
311 @if(mixin-exists(hook-button-text)) {@include hook-button-text();}
312}
313
314/* Hover + Focus */
315.uk-button-text:hover,
316.uk-button-text:focus {
317 color: $button-text-hover-color;
318 @if(mixin-exists(hook-button-text-hover)) {@include hook-button-text-hover();}
319}
320
321/* Disabled */
322.uk-button-text:disabled {
323 color: $button-text-disabled-color;
324 @if(mixin-exists(hook-button-text-disabled)) {@include hook-button-text-disabled();}
325}
326
327/*
328 * Link
329 * 1. Reset
330 * 2. Style
331 */
332
333.uk-button-link {
334 /* 1 */
335 padding: 0;
336 line-height: $button-link-line-height;
337 background: none;
338 /* 2 */
339 color: $button-link-color;
340 @if(mixin-exists(hook-button-link)) {@include hook-button-link();}
341}
342
343/* Hover + Focus */
344.uk-button-link:hover,
345.uk-button-link:focus {
346 color: $button-link-hover-color;
347 text-decoration: $button-link-hover-text-decoration;
348}
349
350/* Disabled */
351.uk-button-link:disabled {
352 color: $button-link-disabled-color;
353 text-decoration: none;
354}
355
356
357/* Group
358 ========================================================================== */
359
360/*
361 * 1. Using `flex` instead of `inline-block` to prevent whitespace betweent child elements
362 * 2. Behave like button
363 * 3. Create position context
364 */
365
366.uk-button-group {
367 /* 1 */
368 display: inline-flex;
369 /* 2 */
370 vertical-align: middle;
371 /* 3 */
372 position: relative;
373}
374
375
376// Hooks
377// ========================================================================
378
379@if(mixin-exists(hook-button-misc)) {@include hook-button-misc();}
380
381// @mixin hook-button(){}
382// @mixin hook-button-hover(){}
383// @mixin hook-button-focus(){}
384// @mixin hook-button-active(){}
385// @mixin hook-button-default(){}
386// @mixin hook-button-default-hover(){}
387// @mixin hook-button-default-active(){}
388// @mixin hook-button-primary(){}
389// @mixin hook-button-primary-hover(){}
390// @mixin hook-button-primary-active(){}
391// @mixin hook-button-secondary(){}
392// @mixin hook-button-secondary-hover(){}
393// @mixin hook-button-secondary-active(){}
394// @mixin hook-button-danger(){}
395// @mixin hook-button-danger-hover(){}
396// @mixin hook-button-danger-active(){}
397// @mixin hook-button-disabled(){}
398// @mixin hook-button-small(){}
399// @mixin hook-button-large(){}
400// @mixin hook-button-text(){}
401// @mixin hook-button-text-hover(){}
402// @mixin hook-button-text-disabled(){}
403// @mixin hook-button-link(){}
404// @mixin hook-button-misc(){}
405
406
407// Inverse
408// ========================================================================
409
410$inverse-button-default-background: $inverse-global-primary-background !default;
411$inverse-button-default-color: $inverse-global-inverse-color !default;
412$inverse-button-default-hover-background: darken($inverse-button-default-background, 5%) !default;
413$inverse-button-default-hover-color: $inverse-global-inverse-color !default;
414$inverse-button-default-active-background: darken($inverse-button-default-background, 10%) !default;
415$inverse-button-default-active-color: $inverse-global-inverse-color !default;
416$inverse-button-primary-background: $inverse-global-primary-background !default;
417$inverse-button-primary-color: $inverse-global-inverse-color !default;
418$inverse-button-primary-hover-background: darken($inverse-button-primary-background, 5%) !default;
419$inverse-button-primary-hover-color: $inverse-global-inverse-color !default;
420$inverse-button-primary-active-background: darken($inverse-button-primary-background, 10%) !default;
421$inverse-button-primary-active-color: $inverse-global-inverse-color !default;
422$inverse-button-secondary-background: $inverse-global-primary-background !default;
423$inverse-button-secondary-color: $inverse-global-inverse-color !default;
424$inverse-button-secondary-hover-background: darken($inverse-button-secondary-background, 5%) !default;
425$inverse-button-secondary-hover-color: $inverse-global-inverse-color !default;
426$inverse-button-secondary-active-background: darken($inverse-button-secondary-background, 10%) !default;
427$inverse-button-secondary-active-color: $inverse-global-inverse-color !default;
428$inverse-button-text-color: $inverse-global-muted-color !default;
429$inverse-button-text-hover-color: $inverse-global-color !default;
430$inverse-button-text-disabled-color: $inverse-global-muted-color !default;
431$inverse-button-link-color: $inverse-global-muted-color !default;
432$inverse-button-link-hover-color: $inverse-global-color !default;
433
434
435
436// @mixin hook-inverse-button-default(){}
437// @mixin hook-inverse-button-default-hover(){}
438// @mixin hook-inverse-button-default-active(){}
439// @mixin hook-inverse-button-primary(){}
440// @mixin hook-inverse-button-primary-hover(){}
441// @mixin hook-inverse-button-primary-active(){}
442// @mixin hook-inverse-button-secondary(){}
443// @mixin hook-inverse-button-secondary-hover(){}
444// @mixin hook-inverse-button-secondary-active(){}
445// @mixin hook-inverse-button-text(){}
446// @mixin hook-inverse-button-text-hover(){}
447// @mixin hook-inverse-button-text-disabled(){}
448// @mixin hook-inverse-button-link(){}