Summary Files Commits Branches @commit @diff @stats
path: root / docs / src / contents / forms.pug
blob: 75c096e50415379389546ffbf220d6a0d09aa25d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
p
  | Forms provide the most common control styles used in forms, including input, textarea, select, checkbox, radio and switch.

.docs-demo.columns
  .column.col-6.col-xs-12
    .form-group
      label.form-label(for="input-example-1") Name
      input#input-example-1.form-input(type="text" placeholder="Name")
    .form-group
      label.form-label(for="input-example-2") Email
      input#input-example-2.form-input(type="email" placeholder="Email")

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form input control -->
      <div class="form-group">
        <label class="form-label" for="input-example-1">Name</label>
        <input class="form-input" type="text" id="input-example-1" placeholder="Name">
      </div>

.docs-demo.columns
  .column.col-6.col-xs-12
    .form-group
      label.form-label(for="input-example-3") Message
      textarea#input-example-3.form-input(placeholder="Textarea" rows="3")

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form textarea control -->
      <div class="form-group">
        <label class="form-label" for="input-example-3">Message</label>
        <textarea class="form-input" id="input-example-3" placeholder="Textarea" rows="3"></textarea>
      </div>

.docs-demo.columns
  .column.col-6.col-xs-12
    .form-group
      select.form-select
        option Choose an option
        option Slack
        option Skype
        option Hipchat
    .form-group
      select.form-select(multiple="")
        option Choose an option
        option Slack
        option Skype
        option Hipchat

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form select control -->
      <div class="form-group">
        <select class="form-select">
          <option>Choose an option</option>
          <option>Slack</option>
          <option>Skype</option>
          <option>Hipchat</option>
        </select>
      </div>

.docs-demo.columns
  .column.col-6.col-xs-12
    form
      .form-group
        label.form-label Gender
        label.form-radio
          input(type="radio" name="gender" checked="")
          i.form-icon
          |  Male
        label.form-radio
          input(type="radio" name="gender")
          i.form-icon
          |  Female

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form radio control -->
      <div class="form-group">
        <label class="form-label">Gender</label>
        <label class="form-radio">
          <input type="radio" name="gender" checked>
          <i class="form-icon"></i> Male
        </label>
        <label class="form-radio">
          <input type="radio" name="gender">
          <i class="form-icon"></i> Female
        </label>
      </div>

.docs-demo.columns
  .column.col-6.col-xs-12
    .form-group
      label.form-switch
        input(type="checkbox")
        i.form-icon
        |  Send me emails with news and tips
    .form-group
      label.form-switch
        input(type="checkbox" checked="")
        i.form-icon
        |  Send me emails with news and tips

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form switch control -->
      <div class="form-group">
        <label class="form-switch">
          <input type="checkbox">
          <i class="form-icon"></i> Send me emails with news and tips
        </label>
      </div>

.docs-demo.columns
  .column.col-6.col-xs-12
    .form-group
      label.form-checkbox
        input(type="checkbox")
        i.form-icon
        |  Remember me
    .form-group
      label.form-checkbox
        input(type="checkbox" checked="")
        i.form-icon
        |  Remember me

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form checkbox control -->
      <div class="form-group">
        <label class="form-checkbox">
          <input type="checkbox">
          <i class="form-icon"></i> Remember me
        </label>
      </div>

p
  | You can use #[code :indeterminate] pseudo class for indeterminate state of checkboxes.

+docs-subheading('forms-horizontal', 'Horizontal forms')

p
  | If you want to have a horizontal form, add the #[code form-horizontal] class to the #{'<form>'} container.
  | And add the #[code col-<1-12>] and #[code col-xs/sm/lg/xl-<1-12>] class to the child elements for responsive form row layout.

.docs-demo.columns
  .column.col-9.col-sm-12
    form.form-horizontal(action="#forms")
      .form-group
        .col-3.col-sm-12
          label.form-label(for="input-example-4") Name
        .col-9.col-sm-12
          input#input-example-4.form-input(type="text" placeholder="Name")
      .form-group
        .col-3.col-sm-12
          label.form-label(for="input-example-5") Email
        .col-9.col-sm-12
          input#input-example-5.form-input(type="email" placeholder="Email")
      .form-group
        .col-3.col-sm-12
          label.form-label Gender
        .col-9.col-sm-12
          label.form-radio
            input(type="radio" name="gender")
            i.form-icon
            |  Male
          label.form-radio
            input(type="radio" name="gender" checked="")
            i.form-icon
            |  Female
      .form-group
        .col-3.col-sm-12
          label.form-label Source
        .col-9.col-sm-12
          select.form-select(multiple="")
            option Slack
            option Skype
            option Hipchat
      .form-group
        .col-9.col-sm-12.col-ml-auto
          label.form-switch
            input(type="checkbox")
            i.form-icon
            |  Send me emails with news and tips
      .form-group
        .col-3.col-sm-12
          label.form-label(for="input-example-6") Message
        .col-9.col-sm-12
          textarea#input-example-6.form-input(placeholder="Textarea" rows="3")
      .form-group
        .col-9.col-sm-12.col-ml-auto
          label.form-checkbox
            input(type="checkbox")
            i.form-icon
            |  Remember me

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <form class="form-horizontal">
        <div class="form-group">
          <div class="col-3 col-sm-12">
            <label class="form-label" for="input-example-1">Name</label>
          </div>
          <div class="col-9 col-sm-12">
            <input class="form-input" type="text" id="input-example-1" placeholder="Name">
          </div>
        </div>
        <!-- form structure -->
      </form>

+docs-subheading('forms-sizes', 'Form sizes')

p
  | For smaller or larger input and select controls, you could add the #[code input-sm]/#[code input-lg], #[code select-sm]/#[code select-lg] and #[code label-sm]/#[code label-lg] classes to the elements.

.docs-demo.columns
  .column.col-4.col-xs-12
    label.form-label.label-sm Label
  .column.col-4.col-xs-12
    input.form-input.input-sm(type="text" placeholder="Name")
  .column.col-4.col-xs-12
    select.form-select.select-sm
      option Choose an option
      option Slack
      option Skype
      option Hipchat
  .column.col-4.col-xs-12
    label.form-label.label-lg Label
  .column.col-4.col-xs-12
    input.form-input.input-lg(type="text" placeholder="Name")
  .column.col-4.col-xs-12
    select.form-select.select-lg
      option Choose an option
      option Slack
      option Skype
      option Hipchat

p
  | You can add the #[code input-sm]/#[code input-lg] classes to the input-checkbox, input-radio and input-switch to have different sizes.

+docs-subheading('forms-icons', 'Form icons')

p
  | Spectre Form components has 
  a(href="#icons") Spectre Icons
  |  support.
p
  | Add a wrapper with the #[code has-icon-left]/#[code has-icon-right] class to #{'<input>'} element.
  | And add the icon with #[code form-icon] class next to the #{'<input>'}.

.docs-demo.columns
  .column.col-4.col-xs-12
    .has-icon-left
      input.form-input.input-sm(type="text" placeholder="Name")
      i.form-icon.icon.icon-arrow-right
  .column.col-4.col-xs-12
    .has-icon-left.tooltip(data-tooltip="Lorem ipsum dolor sit amet")
      input.form-input(type="text" placeholder="Name")
      i.form-icon.icon.icon-arrow-right
  .column.col-4.col-xs-12
    .has-icon-left
      input.form-input.input-lg(type="text" placeholder="Name")
      i.form-icon.icon.icon-arrow-right
  .column.col-4.col-xs-12
    .has-icon-right
      input.form-input.input-sm(type="text" placeholder="Name")
      i.form-icon.icon.icon-check
  .column.col-4.col-xs-12
    .has-icon-right
      input.form-input(type="text" placeholder="Name")
      i.form-icon.icon.icon-check
  .column.col-4.col-xs-12
    .has-icon-right
      input.form-input.input-lg(type="text" placeholder="Name")
      i.form-icon.icon.icon-check

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form input with Spectre icon -->
      <div class="has-icon-left">
        <input type="text" class="form-input" placeholder="...">
        <i class="form-icon icon icon-check"></i>
      </div>

p
  | You can use the #[code loading] class for loading or posting state.

.docs-demo.columns
  .column.col-4.col-xs-12
    .has-icon-right
      input.form-input.input-sm(type="text" placeholder="Name")
      i.form-icon.loading
  .column.col-4.col-xs-12
    .has-icon-right
      input.form-input(type="text" placeholder="Name")
      i.form-icon.loading
  .column.col-4.col-xs-12
    .has-icon-right
      input.form-input.input-lg(type="text" placeholder="Name")
      i.form-icon.loading

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- form input with loading icon -->
      <div class="has-icon-right">
        <input type="text" class="form-input" placeholder="...">
        <i class="form-icon loading"></i>
      </div>

+docs-subheading('forms-input', 'Input types')

.docs-demo.columns
  .column.col-9.col-sm-12
    form.form-horizontal(action="#forms")
      .form-group
        .col-3
          label.form-label(for="input-example-8") Email
        .col-9
          input#input-example-8.form-input(type="email" placeholder="Email" value="spectre@example.com" pattern="[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$")
      .form-group
        .col-3
          label.form-label(for="input-example-9") URL
        .col-9
          input#input-example-9.form-input(type="url" placeholder="URL" value="https://github.com/picturepan2/spectre")
      .form-group
        .col-3
          label.form-label(for="input-example-10") Search
        .col-9
          input#input-example-10.form-input(type="search" placeholder="Search")
      .form-group
        .col-3
          label.form-label(for="input-example-11") Tel
        .col-9
          input#input-example-11.form-input(type="tel" placeholder="Tel" value="1-(888)-888-8888")
      .form-group
        .col-3
          label.form-label(for="input-example-12") Password
        .col-9
          input#input-example-12.form-input(type="password" placeholder="Password" value="123456789")
      .form-group
        .col-3
          label.form-label(for="input-example-13") Number
        .col-9
          input#input-example-13.form-input(type="number" placeholder="00" value="66")
      .form-group
        .col-3
          label.form-label(for="input-example-14") Date
        .col-9
          input#input-example-14.form-input(type="date" value="2016-12-31")
      .form-group
        .col-3
          label.form-label(for="input-example-15") Color
        .col-9
          input#input-example-15.form-input(type="color" value="#5755d9")
      .form-group
        .col-3
          label.form-label(for="input-example-16") File
        .col-9
          input#input-example-16.form-input(type="file")

+docs-subheading('forms-input-groups', 'Input groups')

.docs-demo.columns
  .column.col-6.col-xs-12
    .input-group
      input.form-input.input-sm(type="text" placeholder="username")
      select.form-select.select-sm
        option Slack
        option Skype
        option Hipchat
  .column.col-6.col-xs-12
    .input-group
      span.input-group-addon.addon-sm slack.com/
      input.form-input.input-sm(type="text" placeholder="site name")
      button.btn.btn-primary.input-group-btn.btn-sm Submit
  .column.col-6.col-xs-12
    .input-group
      input.form-input(type="text" placeholder="username")
      select.form-select
        option Slack
        option Skype
        option Hipchat
  .column.col-6.col-xs-12
    .input-group
      span.input-group-addon slack.com/
      input.form-input(type="text" placeholder="site name")
      button.btn.btn-primary.input-group-btn Submit
  .column.col-6.col-xs-12
    .input-group
      label.form-switch
        input(type="checkbox")
        i.form-icon
      input.form-input(type="text" placeholder="name")
  .column.col-6.col-xs-12
    .input-group
      label.form-checkbox
        input(type="checkbox")
        i.form-icon
      input.form-input(type="text" placeholder="name")
  .column.col-6.col-xs-12
    .input-group
      input.form-input.input-lg(type="text" placeholder="username")
      select.form-select.select-lg
        option Slack
        option Skype
        option Hipchat
  .column.col-6.col-xs-12
    .input-group
      span.input-group-addon.addon-lg slack.com/
      input.form-input.input-lg(type="text" placeholder="site name")
      button.btn.btn-primary.input-group-btn.btn-lg Submit

p
  | If you want to attach text and button along with an input, add the #[code input-group] class to the input container.
  | And add the #[code input-group-addon] class to the text element and #[code input-group-btn] to the button element.

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <!-- normal input group -->
      <div class="input-group">
        <span class="input-group-addon">...</span>
        <input type="text" class="form-input" placeholder="...">
      </div>

      <!-- large input group -->
      <div class="input-group">
        <span class="input-group-addon addon-lg">...</span>
        <input type="text" class="form-input input-lg" placeholder="...">
      </div>

      <!-- normal input group with button -->
      <div class="input-group">
        <span class="input-group-addon">...</span>
        <input type="text" class="form-input" placeholder="...">
        <button class="btn btn-primary input-group-btn">Submit</button>
      </div>

+docs-subheading('forms-validation', 'Form validation styles')

p
  | To use form validation styles, you can either add #[code is-success] or #[code is-error] class to the controls or add #[code has-success] or #[code has-error] class to parent elements.
  | Use the #[code form-input-hint] class to provide form validation success and error messages.

.docs-demo.columns
  .column.col-9.col-sm-12
    fieldset
      legend Input
      .form-group
        label.form-label(for="input-example-17") Name
        input#input-example-17.form-input.is-success(type="text" placeholder="Name")
        p.form-input-hint The name is valid.
      .form-group.has-error
        label.form-label(for="input-example-18") Password
        input#input-example-18.form-input(type="password" placeholder="Password")
        p.form-input-hint Passwords must have at least 8 characters.
      .form-group
        label.form-label(for="input-example-21") Email
        input#input-example-21.form-input(type="text" placeholder="Email" pattern="[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$")
        p.form-input-hint The Email address is unavailable.
    fieldset
      legend Select
      .form-group
        select.form-select.is-error
          option Choose an option
          option Slack
          option Skype
          option Hipchat
        p.form-input-hint The option is invalid.
      .form-group.has-success
        select.form-select
          option Choose an option
          option Slack
          option Skype
          option Hipchat
        p.form-input-hint The option is available.
    fieldset
      legend Checkbox, Radio and Switch (Error state only)
      .form-group
        label.form-checkbox.is-error
          input(type="checkbox" checked="")
          i.form-icon
          |  I'm not a robot.
      .form-group.has-error
        label.form-radio
          input(type="radio" name="gender" checked="")
          i.form-icon
          |  Male
        label.form-radio
          input(type="radio" name="gender")
          i.form-icon
          |  Female
      .form-group
        label.form-switch.is-error
          input(type="checkbox" checked="")
          i.form-icon
          |  Send me emails with news and tips

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <form>
        <!-- form validation class: has-success -->
        <div class="form-group has-success">
          <label class="form-label" for="input-example-1">Name</label>
          <input class="form-input" type="text" id="input-example-1" placeholder="...">
          <p class="form-input-hint">The name is invalid.</p>
        </div>

        <!-- form validation class: is-success -->
        <div class="form-group">
          <label class="form-label" for="input-example-1">Name</label>
          <input class="form-input is-success" type="text" id="input-example-1" placeholder="...">
          <p class="form-input-hint">The name is invalid.</p>
        </div>

        <!-- form validation example for checkbox, radio and switch -->
        <div class="form-group">
          <label class="form-checkbox is-error">
            <input type="checkbox">
            <i class="form-icon"></i> Remember me
          </label>
        </div>
      </form>

+docs-subheading('forms-disabled', 'Form disabled styles')

p 
  | Add the #[code disabled] attribute to the element or #{'<fieldset>'} for a disabled form components style.

.docs-demo.columns
  .column.col-6.col-xs-12
    form(action="#forms")
      fieldset(disabled="")
        .form-group
          label.form-label(for="input-example-19") Name
          input#input-example-19.form-input(type="text" placeholder="Name")
        .form-group
          label.form-label Gender
          label.form-radio
            input(type="radio" name="gender" disabled="")
            i.form-icon
            |  Male
          label.form-radio
            input(type="radio" name="gender" disabled="")
            i.form-icon
            |  Female
        .form-group
          select.form-select(disabled="")
            option Choose an option
            option Slack
            option Skype
            option Hipchat
        .form-group
          label.form-switch
            input(type="checkbox" disabled="")
            i.form-icon
            |  Send me emails with news and tips
        .form-group
          label.form-label(for="input-example-20") Message
          textarea#input-example-20.form-input(placeholder="Textarea" rows="3" disabled="")
        .form-group
          label.form-checkbox
            input(type="checkbox" disabled="")
            i.form-icon
            |  Remember me

pre.code(data-lang='HTML')
  code
    :highlight(lang="html")
      <form action="#forms">
        <fieldset disabled>
          <div class="form-group">
            <label class="form-label" for="input-example-19">Name</label>
            <input class="form-input" type="text" id="input-example-19" placeholder="Name">
          </div>
          <div class="form-group">
            <label class="form-label">Gender</label>
            <label class="form-radio">
              <input type="radio" name="gender" disabled>
              <i class="form-icon"></i> Male
            </label>
            <label class="form-radio">
              <input type="radio" name="gender" disabled>
              <i class="form-icon"></i> Female
            </label>
          </div>
          <div class="form-group">
            <select class="form-select" disabled>
              <option>Choose an option</option>
              <option>Slack</option>
              <option>Skype</option>
              <option>Hipchat</option>
            </select>
          </div>
          <div class="form-group">
            <label class="form-switch">
              <input type="checkbox" disabled>
              <i class="form-icon"></i> Send me emails with news and tips
            </label>
          </div>
          <div class="form-group">
            <label class="form-label" for="input-example-20">Message</label>
            <textarea class="form-input" id="input-example-20" placeholder="Textarea" rows="3" disabled></textarea>
          </div>
          <div class="form-group">
            <label class="form-checkbox">
              <input type="checkbox" disabled>
              <i class="form-icon"></i> Remember me
            </label>
          </div>
        </fieldset>