Bootstrap 5 Forms CSS Classes
1. Basic Form Controls
Use .form-control to style inputs, selects, and textareas:
2. Form Labels
Use <label> normally, or with .form-label for better styling:
3. Form Layouts
Vertical Form (default)
Stacked labels and controls:
Horizontal Form
Use Bootstrap grid classes for side-by-side labels and inputs:
4. Input Sizes
Add size classes .form-control-sm or .form-control-lg for small or large inputs:
5. Disabled & Readonly
Add disabled attribute and .disabled class:
Readonly input:
6. Validation States
Bootstrap 5 uses custom validation with .is-valid and .is-invalid:
7. Checkboxes and Radios
Use .form-check container and .form-check-input for inputs:
8. Switches (Toggle Buttons)
Add .form-switch to .form-check:
9. Input Groups
Group inputs with text or buttons using .input-group:
10. Floating Labels
Place labels inside inputs with .form-floating wrapper:
11. File Input
Styled file input with .form-control:
12. Range Input
Slider with .form-range:
Summary Table
| Class | Use |
|---|---|
.form-control |
Style inputs, selects, textareas |
.form-label |
Style labels |
.form-check |
Checkbox/radio container |
.form-check-input |
Checkbox/radio input style |
.form-check-label |
Label for checkbox/radio |
.form-switch |
Checkbox toggle switch |
.form-select |
Style select dropdown |
.input-group |
Group inputs & buttons |
.form-floating |
Floating labels |
.form-control-sm |
Small input size |
.form-control-lg |
Large input size |
.is-valid |
Valid input state |
.is-invalid |
Invalid input state |
