Skip to content

Commit e6f4c23

Browse files
authored
Merge pull request #59 from nicknickel/add-input-suffix
add support for text input suffix icons
2 parents 57bfcdf + 3e516e5 commit e6f4c23

File tree

4 files changed

+84
-5
lines changed

4 files changed

+84
-5
lines changed

jade/page-contents/text_inputs_content.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,45 @@ <h5>Icon Prefixes</h5>
161161
</code></pre>
162162
<br>
163163

164+
<h5>Icon Suffixes</h5>
165+
<p>You can also add an icon suffix. Just add an icon with the class <code class="language-markup">suffix</code> before the input and label.</p><br>
166+
<div class="row">
167+
<form class="col s12">
168+
<div class="row">
169+
<div class="input-field col s6">
170+
<i class="material-icons suffix">account_circle</i>
171+
<input id="icon_suffix" type="text" class="validate">
172+
<label for="icon_suffix">First Name</label>
173+
</div>
174+
<div class="input-field col s6">
175+
<i class="material-icons suffix">phone</i>
176+
<input id="icon_telephone_suffix" type="tel" class="validate">
177+
<label for="icon_telephone_suffix">Telephone</label>
178+
</div>
179+
</div>
180+
</form>
181+
</div>
182+
183+
<pre><code class="language-markup">
184+
&lt;div class="row">
185+
&lt;form class="col s12">
186+
&lt;div class="row">
187+
&lt;div class="input-field col s6">
188+
&lt;i class="material-icons suffix">account_circle</i>&lt;/i>
189+
&lt;input id="icon_suffix" type="text" class="validate">
190+
&lt;label for="icon_suffix">First Name&lt;/label>
191+
&lt;/div>
192+
&lt;div class="input-field col s6">
193+
&lt;i class="material-icons suffix">phone</i>&lt;/i>
194+
&lt;input id="icon_telephone_suffix" type="tel" class="validate">
195+
&lt;label for="icon_telephone_suffix">Telephone&lt;/label>
196+
&lt;/div>
197+
&lt;/div>
198+
&lt;/form>
199+
&lt;/div>
200+
</code></pre>
201+
<br>
202+
164203
<h5>Custom Error or Success Messages</h5>
165204
<p>You can add custom validation messages by adding either <code class="language-markup">data-error</code> or <code class="language-markup">data-success</code> attributes to your helper text element.</p><br>
166205
<div class="row">

sass/components/_chips.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
width: 92%;
8585
width: calc(100% - 3rem);
8686
}
87+
// Form suffix
88+
.suffix ~ .chips {
89+
margin-right: 3rem;
90+
width: 92%;
91+
width: calc(100% - 3rem);
92+
}
8793
.chips:empty ~ label {
8894
font-size: 0.8rem;
8995
transform: translateY(-140%);

sass/components/forms/_input-fields.scss

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ textarea.materialize-textarea {
166166
}
167167

168168
.prefix ~ label,
169-
.prefix ~ .validate ~ label {
169+
.prefix ~ .validate ~ label,
170+
.suffix ~ label,
171+
.suffix ~ .validate ~ label {
170172
width: calc(100% - 3rem - #{$gutter-width});
171173
}
172174
}
@@ -217,7 +219,7 @@ textarea.materialize-textarea {
217219
}
218220

219221
// Prefix Icons
220-
.prefix {
222+
.prefix, .suffix {
221223
position: absolute;
222224
width: $input-height;
223225
font-size: $input-icon-size;
@@ -229,6 +231,7 @@ textarea.materialize-textarea {
229231

230232
.prefix ~ input,
231233
.prefix ~ textarea,
234+
.prefix ~ .select-wrapper,
232235
.prefix ~ label,
233236
.prefix ~ .validate ~ label,
234237
.prefix ~ .helper-text,
@@ -241,21 +244,43 @@ textarea.materialize-textarea {
241244
.prefix ~ label { margin-left: 3rem; }
242245

243246
@media #{$medium-and-down} {
244-
.prefix ~ input {
247+
.prefix ~ input,
248+
.suffix ~ input {
245249
width: 86%;
246250
width: calc(100% - 3rem);
247251
}
248252
}
249253

250254
@media #{$small-and-down} {
251-
.prefix ~ input {
255+
.prefix ~ input,
256+
.suffix ~ input {
252257
width: 80%;
253258
width: calc(100% - 3rem);
254259
}
255260
}
256-
}
257261

258262

263+
// Suffix Icons
264+
.suffix {
265+
right: 0;
266+
}
267+
268+
.suffix ~ input,
269+
.suffix ~ textarea,
270+
.suffix ~ .select-wrapper,
271+
.suffix ~ label,
272+
.suffix ~ .validate ~ label,
273+
.suffix ~ .helper-text,
274+
.suffix ~ .autocomplete-content {
275+
margin-right: 3rem;
276+
width: 92%;
277+
width: calc(100% - 3rem);
278+
}
279+
280+
.suffix ~ label { margin-right: 3rem; }
281+
282+
}
283+
259284
/* Search Field */
260285

261286
.input-field input[type=search] {

sass/components/forms/_select.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ body.keyboard-focused {
162162

163163
.prefix ~ label { margin-left: 3rem; }
164164

165+
// Suffix Icons
166+
.suffix ~ .select-wrapper {
167+
margin-right: 3rem;
168+
width: 92%;
169+
width: calc(100% - 3rem);
170+
}
171+
172+
.suffix ~ label { margin-right: 3rem; }
173+
165174
// Icons
166175
.select-dropdown li {
167176
img {

0 commit comments

Comments
 (0)