Form Elements
Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms. Here’s a quick example to demonstrate form styles, so use these classes to opt into their customized displays.
Form controls
Textual form controls—like <input>
s, <select>
s, and <textarea>
s—are styled with the .form-control
class. Included are styles for general appearance, focus state, sizing, and more. Additional classes can be used to vary this layout on a per-form basis.
State Preview
Size Preview
Use .form-control-lg
or .form-control-sm
with .form-control
for large or small input box.
Code Example
<div class="form-group"> <label class="form-label" for="default-01">Input text label</label> <div class="form-control-wrap"> <input type="text" class="form-control" id="default-01" placeholder="Input placeholder"> </div> </div> <div class="form-group"> <label class="form-label" for="default-02">Textarea label</label> <div class="form-control-wrap"> <textarea class="form-control" id="default-textarea">Large text area content</textarea> </div> </div>
Select with Select2
As .form-select
class use for default <select>
, using .js-select2
class in <select>
element to replace browser default style with Select2, as its give you a customizable select box with support for searching, tagging, and many other highly used options. For the documentation for Select2, that can be found here.
For large or small size of Select2, use lg
, sm
in data-ui=""
attribute of <select>
element. And you can use on
in data-search=""
attribute to display search option in select2.
Code Example
<div class="form-group"> <label class="form-label">Select2 Default</label> <div class="form-control-wrap"> <select class="form-select js-select2"> ... </select> </div> </div>
Date Picker
Using .date-picker
, .date-picker-alt
class in <input>
element to enable datepicker.
We have used Bootstrap Datepicker for date picker, here you see full documentation here.
mm/dd/yyyy
yyyy-mm-dd
yyyy-mm-dd
mm/dd/yyyy
Additionally you can use data-date-format=""
attribute of <input>
element to formate date. Default format mm/dd/yyyy
.
Code Example
<div class="form-group"> <label class="form-label">Select2 Default</label> <div class="form-control-wrap"> <select class="form-select"> ... </select> </div> </div>
Time Picker
Using .time-picker
class in <select>
element to enable time picker.
We have used Bootstrap Timepicker for date picker, here you see full documentation here.
Additionally you can use some_thing_else
attribute of <input>
element.
Code Example
<div class="form-group"> <label class="form-label">Select2 Default</label> <div class="form-control-wrap"> <select class="form-select"> ... </select> </div> </div>
Checkbox Styles
To create custom control, wrapped with <div>
each checkbox <input>
& <label>
using .custom-control
, .custom-checkbox
classes.
For large or small size of .custom-checkbox
, use .custom-control-{lg|sm}
with .custom-control
class.
Code Example
<div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" id="customCheck1"> <label class="custom-control-label" for="customCheck1">Option Label</label> </div> <div class="custom-control custom-control-lg custom-checkbox"> <input type="checkbox" class="custom-control-input" id="customCheck2"> <label class="custom-control-label" for="customCheck2">Option Label</label> </div>
Radio Style
To create custom control, wrapped with <div>
each radio <input>
& <label>
using .custom-control
, .custom-radio
classes.
For large or small size of .custom-radio
, use .custom-control-{lg|sm}
with .custom-control
class.
Code Example
<div class="custom-control custom-radio"> <input type="radio" id="customRadio1" name="customRadio" class="custom-control-input"> <label class="custom-control-label" for="customRadio1">Radio</label> </div> <div class="custom-control custom-control-lg custom-radio"> <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input"> <label class="custom-control-label" for="customRadio2">Radio</label> </div>
Switch Style
The switch markup of a .custom-control
checkbox
but uses the .custom-switch
class to render a toggle switch.
For large or small size of .custom-switch
, use .custom-control-{lg|sm}
with .custom-control
class.
Code Example
<div class="custom-control custom-switch"> <input type="checkbox" class="custom-control-input" id="customSwitch1"> <label class="custom-control-label" for="customSwitch1">Switch</label> </div> <div class="custom-control custom-control-lg custom-switch"> <input type="checkbox" class="custom-control-input" id="customSwitch2"> <label class="custom-control-label" for="customSwitch2">Switch</label> </div>