Input
Native inputs with consistent spacing, focus and validation.
When to use
Use .form-control on native inputs and textareas for text entry. Choose an input type that matches the value, such as email or password. Use Select for a list of options and Checkbox for a yes-or-no choice.
Default
Pair each control with a visible label. Use a placeholder for an example value, rather than as a replacement for the label.
<div>
<label class="form-label" for="inputDefault">Project name</label>
<input
class="form-control"
id="inputDefault"
name="textInput"
type="text"
placeholder="Website redesign" />
</div>Textarea
Apply .form-control to a textarea for longer, multiline content.
<div>
<label class="form-label" for="textareaExample">Message</label>
<textarea
class="form-control"
id="textareaExample"
name="textareaExample"
placeholder="Your message"></textarea>
</div>Invalid
Combine .is-invalid and aria-invalid="true" after validation reports an error. Link the feedback with aria-describedby and its id.
Enter a complete email address, such as alex@example.com.
<div>
<label class="form-label" for="invalidInput">Email address</label>
<input
class="form-control is-invalid"
id="invalidInput"
name="invalidInput"
type="email"
value="alex@"
aria-invalid="true"
aria-describedby="invalidInputFeedback" />
<div class="invalid-feedback" id="invalidInputFeedback">
Enter a complete email address, such as alex@example.com.
</div>
</div>Disabled
Use the native disabled attribute when a field is unavailable. Disabled fields are skipped in keyboard navigation and omitted from native form submission.
<div>
<label class="form-label" for="disabledInput">Account owner</label>
<input
class="form-control"
id="disabledInput"
name="disabledInput"
disabled
value="Alex Morgan" />
</div>Accessibility and behavior
- Match each label’s
forattribute to a unique controlid. Keep the label visible when the user enters a value. - Add a
namefor native form submission and an appropriateautocompletevalue for personal details such as names or email addresses. - Connect hints and errors through
aria-describedby. When both apply, list both IDs so the user can access the guidance and the error. - Keep native constraints such as
required,minlengthor an appropriatetype..is-invalidstyles an error andaria-invalidcommunicates it; neither performs validation. See Form for validation patterns. - Preserve the visible focus indicator. Use
readonlyon supported inputs or textareas when a value should remain focusable and submitted while editing is unavailable.
CSS variables
Override these base defaults on the listed selector after the library styles. Variants and states may replace them; global tokens follow the active theme.
| Token | Default | Purpose | Scope / state |
|---|---|---|---|
--form-control-bg-color | var(--bg-surface) | Background color. | .form-control |
--form-control-border-width | var(--border-width) | Border thickness. | .form-control |
--form-control-border-color | var(--control-border-color) | Border color. | .form-control |
--form-control-border-radius | var(--border-radius) | Corner radius. | .form-control |
--form-control-padding-y | var(--spacer-1) | Top and bottom padding. | .form-control |
--form-control-padding-x | var(--spacer-3) | Left and right padding. | .form-control |
--form-control-font-size | var(--font-size) | Text size. | .form-control |
--form-control-font-weight | 400 | Input text weight. | .form-control |
--form-control-placeholder-color | var(--text-subtle) | Placeholder text color. | .form-control |
--form-control-disabled-text-color | var(--disabled-text-color) | Text color while disabled. | .form-control (disabled) |
--form-control-disabled-bg-color | var(--disabled-bg-color) | Background color while disabled. | .form-control (disabled) |
--form-control-disabled-border-color | var(--disabled-border-color) | Border color while disabled. | .form-control (disabled) |
--form-control-focus-border-color | var(--primary-hover) | Border color while focused. | .form-control (focus) |
--form-control-focus-outline-width | var(--focus-outline-width) | Focus ring thickness. | .form-control (focus) |
--form-control-focus-outline-style | var(--focus-outline-style) | Focus ring line style. | .form-control (focus) |
--form-control-focus-outline-color | var(--focus-outline-color) | Focus ring color. | .form-control (focus) |
--form-control-focus-outline-offset | var(--focus-offset) | Distance between the focus ring and control. | .form-control (focus) |
--form-control-transition-duration | var(--transition-duration) | Duration of visual state transitions. | .form-control |
--form-control-transition-easing | var(--transition-easing) | Timing curve for visual state transitions. | .form-control |