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.

HTML
<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.

HTML
<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.

HTML
<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.

HTML
<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 for attribute to a unique control id. Keep the label visible when the user enters a value.
  • Add a name for native form submission and an appropriate autocomplete value 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, minlength or an appropriate type. .is-invalid styles an error and aria-invalid communicates it; neither performs validation. See Form for validation patterns.
  • Preserve the visible focus indicator. Use readonly on 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.

TokenDefaultPurposeScope / state
--form-control-bg-colorvar(--bg-surface)Background color..form-control
--form-control-border-widthvar(--border-width)Border thickness..form-control
--form-control-border-colorvar(--control-border-color)Border color..form-control
--form-control-border-radiusvar(--border-radius)Corner radius..form-control
--form-control-padding-yvar(--spacer-1)Top and bottom padding..form-control
--form-control-padding-xvar(--spacer-3)Left and right padding..form-control
--form-control-font-sizevar(--font-size)Text size..form-control
--form-control-font-weight400Input text weight..form-control
--form-control-placeholder-colorvar(--text-subtle)Placeholder text color..form-control
--form-control-disabled-text-colorvar(--disabled-text-color)Text color while disabled..form-control (disabled)
--form-control-disabled-bg-colorvar(--disabled-bg-color)Background color while disabled..form-control (disabled)
--form-control-disabled-border-colorvar(--disabled-border-color)Border color while disabled..form-control (disabled)
--form-control-focus-border-colorvar(--primary-hover)Border color while focused..form-control (focus)
--form-control-focus-outline-widthvar(--focus-outline-width)Focus ring thickness..form-control (focus)
--form-control-focus-outline-stylevar(--focus-outline-style)Focus ring line style..form-control (focus)
--form-control-focus-outline-colorvar(--focus-outline-color)Focus ring color..form-control (focus)
--form-control-focus-outline-offsetvar(--focus-offset)Distance between the focus ring and control..form-control (focus)
--form-control-transition-durationvar(--transition-duration)Duration of visual state transitions..form-control
--form-control-transition-easingvar(--transition-easing)Timing curve for visual state transitions..form-control