UNPKG

4.29 kBSCSSView Raw
1// Foundation for Sites by ZURB
2// foundation.zurb.com
3// Licensed under MIT Open Source
4
5////
6/// @group forms
7////
8
9/// Font color of text inputs.
10/// @type Color
11$input-color: $black !default;
12
13/// Font color of placeholder text within text inputs.
14/// @type Color
15$input-placeholder-color: $medium-gray !default;
16
17/// Font family of text inputs.
18/// @type Font
19$input-font-family: inherit !default;
20
21/// Font size of text inputs.
22/// @type Number
23$input-font-size: rem-calc(16) !default;
24
25/// Font weight of text inputs.
26/// @type Keyword
27$input-font-weight: $global-weight-normal !default;
28
29/// Line height of text inputs.
30/// @type Keyword
31$input-line-height: $global-lineheight !default;
32
33/// Background color of text inputs.
34/// @type Color
35$input-background: $white !default;
36
37/// Background color of focused of text inputs.
38/// @type Color
39$input-background-focus: $white !default;
40
41/// Background color of disabled text inputs.
42/// @type Color
43$input-background-disabled: $light-gray !default;
44
45/// Border around text inputs.
46/// @type Border
47$input-border: 1px solid $medium-gray !default;
48
49/// Border around focused text inputs.
50/// @type Color
51$input-border-focus: 1px solid $dark-gray !default;
52
53/// Padding of text inputs.
54/// @type Color
55$input-padding: $form-spacing / 2 !default;
56
57/// Box shadow inside text inputs when not focused.
58/// @type Shadow
59$input-shadow: inset 0 1px 2px rgba($black, 0.1) !default;
60
61/// Box shadow outside text inputs when focused.
62/// @type Shadow
63$input-shadow-focus: 0 0 5px $medium-gray !default;
64
65/// Cursor to use when hovering over a disabled text input.
66/// @type Cursor
67$input-cursor-disabled: not-allowed !default;
68
69/// Properties to transition on text inputs.
70/// @type Transition
71$input-transition: box-shadow 0.5s, border-color 0.25s ease-in-out !default;
72
73/// Enables the up/down buttons that Chrome and Firefox add to `<input type='number'>` elements.
74/// @type Boolean
75$input-number-spinners: true !default;
76
77/// Radius for text inputs.
78/// @type Border
79$input-radius: $global-radius !default;
80
81/// Border radius for form buttons, defaulted to global-radius.
82/// @type Number
83$form-button-radius: $global-radius !default;
84
85@mixin form-element {
86 $height: ($input-font-size * unitless-calc($input-line-height)) + (get-side($input-padding, 'top') + get-side($input-padding, 'bottom')) - rem-calc(1);
87
88 display: block;
89 box-sizing: border-box;
90 width: 100%;
91 height: $height;
92 margin: 0 0 $form-spacing;
93 padding: $input-padding;
94
95 border: $input-border;
96 border-radius: $input-radius;
97 background-color: $input-background;
98 box-shadow: $input-shadow;
99
100 font-family: $input-font-family;
101 font-size: $input-font-size;
102 font-weight: $input-font-weight;
103 line-height: $input-line-height;
104 color: $input-color;
105
106 @if has-value($input-transition) {
107 transition: $input-transition;
108 }
109
110 // Focus state
111 &:focus {
112 outline: none;
113 border: $input-border-focus;
114 background-color: $input-background-focus;
115 box-shadow: $input-shadow-focus;
116
117 @if has-value($input-transition) {
118 transition: $input-transition;
119 }
120 }
121}
122
123@mixin foundation-form-text {
124 // Text inputs
125 #{text-inputs()},
126 textarea {
127 @include form-element;
128 appearance: none;
129 }
130
131 // Text areas
132 textarea {
133 max-width: 100%;
134
135 &[rows] {
136 height: auto;
137 }
138 }
139
140 input,
141 textarea {
142 // Placeholder text
143 &::placeholder {
144 color: $input-placeholder-color;
145 }
146
147 // Disabled/readonly state
148 &:disabled,
149 &[readonly] {
150 background-color: $input-background-disabled;
151 cursor: $input-cursor-disabled;
152 }
153 }
154
155 // Reset styles on button-like inputs
156 [type='submit'],
157 [type='button'] {
158 appearance: none;
159 border-radius: $form-button-radius;
160 }
161
162 // Reset Normalize setting content-box to search elements
163 input[type='search'] { // sass-lint:disable-line no-qualifying-elements
164 box-sizing: border-box;
165 }
166
167 // Number input styles
168 [type='number'] {
169 @if not $input-number-spinners {
170 -moz-appearance: textfield; // sass-lint:disable-line no-vendor-prefix
171
172 &::-webkit-inner-spin-button,
173 &::-webkit-outer-spin-button {
174 -webkit-appearance: none; // sass-lint:disable-line no-vendor-prefix
175 margin: 0;
176 }
177 }
178 }
179}