Loading...
Skip to main content

Form controls

Use FormControl, FormTextArea, and FormSelect to add custom styles, sizing, focus states, and more to native form controls.

Heads up! FormSelect uses the same base styles as FormControl for ease of use.

These wrappers style most textual inputs (including date and time types), textareas, and select elements consistently, with element-specific modifiers where needed.

<>
<FormLabel
className="mb-2"
htmlFor="exampleFormControlInput"
>
Email address
</FormLabel>
<FormControl
id="exampleFormControlInput"
placeholder="name@example.com"
type="email"
/>
</>

With form field

Use the form field component to layout and wrap your inputs with a label, description, and validation feedback messages in a vertical stack.

We’ll never share your email with anyone else.
<Stack gap={3}>
<FormField>
<FormLabel htmlFor="exampleFormControlInput1">
Email address
</FormLabel>
<FormControl
id="exampleFormControlInput1"
placeholder="name@example.com"
type="email"
/>
<FormText>
{' '}We’ll never share your email with anyone else.{' '}
</FormText>
</FormField>
</Stack>

Textarea

FormTextArea shares the base appearance of FormControl. Set its rows attribute or use custom CSS to change its height.

<Stack gap={3}>
<FormField>
<FormLabel htmlFor="exampleFormControlTextarea1">
Example textarea
</FormLabel>
<FormTextArea id="exampleFormControlTextarea1" />
</FormField>
<FormField>
<FormLabel htmlFor="exampleFormControlTextarea2">
Taller textarea
</FormLabel>
<FormTextArea
id="exampleFormControlTextarea2"
rows={4}
/>
</FormField>
</Stack>

Select

FormSelect provides the basic select appearance. Styling is limited by the browser—options and popovers cannot be styled.

<FormField>
<FormLabel htmlFor="exampleFormControlSelect2">
Example select
</FormLabel>
<FormSelect id="exampleFormControlSelect2">
<option>
Choose one…
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</FormField>

The multiple attribute is supported on select elements:

<div>
<FormLabel htmlFor="exampleFormControlSelect3">
Multiple select
</FormLabel>
<FormSelect
aria-label="Multiple select example"
defaultValue={[
'Open this select menu'
]}
id="exampleFormControlSelect3"
multiple
>
<option>
Open this select menu
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</div>

As is the size attribute:

<div>
<FormLabel htmlFor="exampleFormControlSelect4">
Size 3 select
</FormLabel>
<FormSelect
aria-label="Size 3 select example"
defaultValue="Open this select menu"
id="exampleFormControlSelect4"
size={3}
>
<option>
Open this select menu
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</div>

Sizes

Set controlSize to sm or lg on FormControl, FormTextArea, or FormSelect to adjust the control's height, padding, font size, line height, and border radius.

<Stack gap={3}>
<div>
<FormLabel htmlFor="sizesInputSmall">
Small input
</FormLabel>
<FormControl
aria-label="Small input example"
controlSize="sm"
id="sizesInputSmall"
placeholder="Small input"
type="text"
/>
</div>
<div>
<FormLabel htmlFor="sizesInputDefault">
Default input
</FormLabel>
<FormControl
aria-label="Default input example"
id="sizesInputDefault"
placeholder="Default input"
type="text"
/>
</div>
<div>
<FormLabel htmlFor="sizesInputLarge">
Large input
</FormLabel>
<FormControl
aria-label="Large input example"
controlSize="lg"
id="sizesInputLarge"
placeholder="Large input"
type="text"
/>
</div>
</Stack>

And for textareas:

<Stack gap={3}>
<div>
<FormLabel htmlFor="sizesTextareaSmall">
Small textarea
</FormLabel>
<FormTextArea
aria-label="Small textarea example"
controlSize="sm"
id="sizesTextareaSmall"
placeholder="Small textarea"
/>
</div>
<div>
<FormLabel htmlFor="sizesTextareaDefault">
Default textarea
</FormLabel>
<FormTextArea
aria-label="Default textarea example"
id="sizesTextareaDefault"
placeholder="Default textarea"
/>
</div>
<div>
<FormLabel htmlFor="sizesTextareaLarge">
Large textarea
</FormLabel>
<FormTextArea
aria-label="Large textarea example"
controlSize="lg"
id="sizesTextareaLarge"
placeholder="Large textarea"
/>
</div>
</Stack>

And for selects:

<Stack gap={3}>
<div>
<FormLabel htmlFor="sizesSelectSmall">
Small select
</FormLabel>
<FormSelect
controlSize="sm"
id="sizesSelectSmall"
>
<option>
Open this select menu
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</div>
<div>
<FormLabel htmlFor="sizesSelectDefault">
Default select
</FormLabel>
<FormSelect id="sizesSelectDefault">
<option>
Open this select menu
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</div>
<div>
<FormLabel htmlFor="sizesSelectLarge">
Large select
</FormLabel>
<FormSelect
controlSize="lg"
id="sizesSelectLarge"
>
<option>
Open this select menu
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
</div>
</Stack>

Form text

FormText is inline by default; set block for descriptions that belong on their own line.

Form text should be explicitly associated with the form control it relates to using the aria-describedby attribute. This will ensure that assistive technologies—such as screen readers—will announce this form text when the user focuses or enters the control.

FormText adds top spacing when rendered as a block, keeping descriptions separated from the controls above.

Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
<>
<FormLabel htmlFor="inputPassword5">
Password
</FormLabel>
<FormControl
aria-describedby="passwordHelpBlock"
id="inputPassword5"
type="password"
/>
<FormText
block
id="passwordHelpBlock"
>
Your password must be 8-20 characters long, contain letters and numbers, and must not
contain spaces, special characters, or emoji.
</FormText>
</>

FormText renders as a <small> element by default. Use its as prop to choose another inline element when needed.

Must be 8-20 characters long.
<Row className="g-3 align-items-center">
<Col xs="auto">
<FormLabel
column
htmlFor="inputPassword6"
>
Password
</FormLabel>
</Col>
<Col xs="auto">
<FormControl
aria-describedby="passwordHelpInline"
id="inputPassword6"
type="password"
/>
</Col>
<Col xs="auto">
<FormText id="passwordHelpInline">
{' '}Must be 8-20 characters long.{' '}
</FormText>
</Col>
</Row>

States

Disabled

Add the disabled boolean attribute on an input to give it a grayed out appearance, remove pointer events, and prevent focusing.

<Stack gap={3}>
<FormControl
aria-label="Disabled input example"
disabled
placeholder="Disabled input"
type="text"
/>
<FormControl
aria-label="Disabled input example"
defaultValue="Disabled readonly input"
disabled
readOnly
type="text"
/>
<FormSelect
aria-label="Disabled select example"
defaultValue="Open this select menu"
disabled
>
<option>
Open this select menu
</option>
<option value="1">
One
</option>
<option value="2">
Two
</option>
<option value="3">
Three
</option>
</FormSelect>
<FormTextArea
aria-label="Disabled textarea example"
disabled
placeholder="Disabled textarea"
rows={3}
/>
</Stack>

Readonly

Add the readonly boolean attribute on an input to prevent modification of the input’s value. readonly inputs can still be focused and selected, while disabled inputs cannot.

<FormControl
aria-label="readonly input example"
defaultValue="Readonly input here..."
readOnly
type="text"
/>

Readonly plain text

Set plaintext on FormControl to display a read-only input as plain text, removing the default field styling while preserving its margin and padding.

<>
<Row className="mb-3">
<Col
as={function ve(){}}
column
htmlFor="staticEmail"
sm={2}
>
<p>
Email
</p>
</Col>
<Col sm={10}>
<FormControl
defaultValue="email@example.com"
id="staticEmail"
plaintext
readOnly
type="text"
/>
</Col>
</Row>
<Row className="mb-3">
<Col
as={function ve(){}}
column
htmlFor="inputPassword"
sm={2}
>
<p>
Password
</p>
</Col>
<Col sm={10}>
<FormControl
id="inputPassword"
type="password"
/>
</Col>
</Row>
</>
<Row
as={function ve(){}}
className="g-3"
>
<Col xs="auto">
<FormLabel
className="visually-hidden"
htmlFor="staticEmail2"
plain
>
Email
</FormLabel>
<FormControl
defaultValue="email@example.com"
id="staticEmail2"
plaintext
readOnly
type="text"
/>
</Col>
<Col xs="auto">
<FormLabel
className="visually-hidden"
htmlFor="inputPassword2"
plain
>
Password
</FormLabel>
<FormControl
id="inputPassword2"
placeholder="Password"
type="password"
/>
</Col>
<Col xs="auto">
<Button
className="mb-3"
theme="primary"
type="submit"
variant="solid"
>
Confirm identity
</Button>
</Col>
</Row>

Types

Nearly all input types are supported, but not all are documented here. Types that need additional props or styling are shown below.

Date & Time

Date and time inputs need no additional component-specific props. Their exact functionality and appearance depend on the browser and operating system. You can also use our datepicker component for a more consistent experience across browsers with JavaScript.

<Stack gap={3}>
<FormControl
aria-label="Date and time picker"
defaultValue="2026-02-24T13:00"
type="datetime-local"
/>
<FormControl
aria-label="Date and time picker with seconds"
defaultValue="2026-02-24T13:00:30"
step="1"
type="datetime-local"
/>
<FormControl
aria-label="Date and time picker with milliseconds"
defaultValue="2026-02-24T13:00:30.500"
step="0.001"
type="datetime-local"
/>
<FormControl
aria-label="Date picker"
defaultValue="2026-02-24"
type="date"
/>
<FormControl
aria-label="Time picker"
defaultValue="13:00"
type="time"
/>
<FormControl
aria-label="Month picker"
defaultValue="2026-02"
type="month"
/>
<FormControl
aria-label="Week picker"
defaultValue="2026-W09"
type="week"
/>
</Stack>

Color

Set type="color" and the color prop on FormControl to size the color input consistently and account for browser differences.

<>
<FormLabel htmlFor="exampleColorInput">
Color picker
</FormLabel>
<FormControl
color
defaultValue="#631aff"
id="exampleColorInput"
title="Choose your color"
type="color"
/>
</>

Sizes are also supported:

<Stack gap={3}>
<div>
<FormLabel htmlFor="exampleColorInputLg">
Large color picker
</FormLabel>
<FormControl
color
controlSize="lg"
defaultValue="#631aff"
id="exampleColorInputLg"
title="Choose your color"
type="color"
/>
</div>
<div>
<FormLabel htmlFor="exampleColorInputSm">
Small color picker
</FormLabel>
<FormControl
color
controlSize="sm"
defaultValue="#631aff"
id="exampleColorInputSm"
title="Choose your color"
type="color"
/>
</div>
</Stack>

Datalists

Datalists allow you to create a group of <option>s that can be accessed (and autocompleted) from within an <input>. These are similar to <select> elements, but come with more menu styling limitations and differences. While most browsers and operating systems include some support for <datalist> elements, their styling is inconsistent at best.

Learn more about support for datalist elements.

<>
<FormLabel htmlFor="exampleDataList">
Datalist example
</FormLabel>
<FormControl
id="exampleDataList"
list="datalistOptions"
placeholder="Type to search..."
/>
<datalist id="datalistOptions">
<option value="San Francisco" />
<option value="New York" />
<option value="Seattle" />
<option value="Los Angeles" />
<option value="Chicago" />
</datalist>
</>

Set the caret prop on FormControl to add a caret without using a select element.

<>
<FormLabel htmlFor="exampleDataListCaret">
Datalist example with caret
</FormLabel>
<FormControl
caret
id="exampleDataListCaret"
list="datalistOptionsCaret"
placeholder="Type to search..."
/>
<datalist id="datalistOptionsCaret">
<option value="San Francisco" />
<option value="New York" />
<option value="Seattle" />
<option value="Los Angeles" />
<option value="Chicago" />
</datalist>
</>

File

File inputs use the ::file-selector-button pseudo-element to style the button within the control. Use FormControl with controlSize when you need a size variant.

<Stack gap={5}>
<FormField>
<FormLabel htmlFor="formFile">
Default file input example
</FormLabel>
<FormControl
id="formFile"
type="file"
/>
</FormField>
<FormField>
<FormLabel htmlFor="formFileMultiple">
Multiple files input example
</FormLabel>
<FormControl
id="formFileMultiple"
multiple
type="file"
/>
</FormField>
<FormField>
<FormLabel htmlFor="formFileDisabled">
Disabled file input example
</FormLabel>
<FormControl
disabled
id="formFileDisabled"
type="file"
/>
</FormField>
<FormField>
<FormLabel htmlFor="formFileSm">
Small file input example
</FormLabel>
<FormControl
controlSize="sm"
id="formFileSm"
type="file"
/>
</FormField>
<FormField>
<FormLabel htmlFor="formFileLg">
Large file input example
</FormLabel>
<FormControl
controlSize="lg"
id="formFileLg"
type="file"
/>
</FormField>
</Stack>

Ghost

FormGhost removes the input's default styling when a surrounding component handles spacing, borders, and focus states. Use it for composites such as search bars and command inputs.

Because FormGhost removes the input's focus outline, make sure its surrounding component provides a visible focus indicator, such as with :focus-within.

<FormField>
<FormLabel htmlFor="exampleGhostInput">
Search
</FormLabel>
<div className="d-flex align-items-center gap-3 p-3 border rounded-3">
<Icon name="file-earmark-code" />
<FormGhost
aria-label="Search docs"
id="exampleGhostInput"
placeholder="Search docs"
type="search"
/>
</div>
</FormField>

You can also use the form-adorn component to provide prebuilt styles for your ghost input.

CSS

Optional custom properties shown as initial are unset in the published CSS.

Variables

.example {
--bs-control-min-height: var(--bs-btn-input-min-height);
--bs-control-padding-y: var(--bs-btn-input-padding-y);
--bs-control-padding-x: var(--bs-btn-input-padding-x);
--bs-control-font-size: var(--bs-btn-input-font-size);
--bs-control-line-height: var(--bs-btn-input-line-height);
--bs-control-fg: var(--bs-btn-input-fg);
--bs-control-bg: var(--bs-btn-input-bg);
--bs-control-border-width: var(--bs-border-width);
--bs-control-border-color: var(--bs-border-color);
--bs-control-border-radius: var(--bs-radius-5);
--bs-control-box-shadow: var(--bs-box-shadow-inset);
--bs-control-action-bg: var(--bs-bg-1);
--bs-control-action-hover-bg: var(--bs-bg-2);
--bs-control-transition-property: border-color, box-shadow;
--bs-control-transition-duration: 0.15s;
--bs-control-transition-timing: cubic-bezier(0.34, 1.56, 0.64, 1);
--bs-control-placeholder-color: var(--bs-fg-3);
--bs-control-disabled-color: var(--bs-control-fg);
--bs-control-disabled-bg: var(--bs-bg-3);
--bs-control-disabled-border-color: var(--bs-control-border-color);
--bs-control-select-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2300000080' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
--bs-control-select-bg-position: right 0.75rem center;
--bs-control-select-bg-size: 16px 12px;
--bs-control-select-bg-dark: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff80' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

For FormLabel:

.example {
--bs-label-margin-bottom: calc(var(--bs-spacer) / 2);
--bs-label-font-size: inherit;
--bs-label-font-style: inherit;
--bs-label-font-weight: 500;
--bs-label-color: var(--bs-fg-body);
}

For FormText:

.example {
--bs-form-text-margin-top: 0.25rem;
--bs-form-text-font-size: var(--bs-font-size-sm);
--bs-form-text-font-style: initial;
--bs-form-text-font-weight: initial;
--bs-form-text-color: var(--bs-fg-2);
}

Root variables

Some inputs and buttons share some root variables for consistency across all form elements, primarily for sizing.

.example {
--bs-control-checked-bg: var(--bs-primary-base);
--bs-control-checked-border-color: var(--bs-control-checked-bg);
--bs-control-active-bg: var(--bs-primary-base);
--bs-control-active-border-color: var(--bs-control-active-bg);
--bs-control-disabled-bg: var(--bs-bg-3);
--bs-control-disabled-opacity: 0.65;
--bs-control-transition-duration: 0.15s;
--bs-control-transition-timing: cubic-bezier(0.34, 1.56, 0.64, 1);
--bs-btn-input-fg: var(--bs-fg-body);
--bs-btn-input-bg: var(--bs-bg-body);
--bs-btn-input-gap: 0.375rem;
--bs-btn-input-min-height: 2.375rem;
--bs-btn-input-padding-y: 0.375rem;
--bs-btn-input-padding-x: 0.75rem;
--bs-btn-input-font-size: var(--bs-body-font-size);
--bs-btn-input-font-weight: var(--bs-font-weight-normal);
--bs-btn-input-line-height: var(--bs-body-line-height);
--bs-btn-input-border-radius: var(--bs-radius-5);
--bs-btn-input-xs-gap: var(--bs-spacer-1);
--bs-btn-input-xs-min-height: 1.5rem;
--bs-btn-input-xs-padding-y: 0.125rem;
--bs-btn-input-xs-padding-x: 0.5rem;
--bs-btn-input-xs-font-size: var(--bs-font-size-xs);
--bs-btn-input-xs-line-height: 1.125;
--bs-btn-input-xs-border-radius: var(--bs-radius-5);
--bs-btn-input-sm-gap: 0.375rem;
--bs-btn-input-sm-min-height: 2rem;
--bs-btn-input-sm-padding-y: 0.25rem;
--bs-btn-input-sm-padding-x: 0.625rem;
--bs-btn-input-sm-font-size: var(--bs-font-size-sm);
--bs-btn-input-sm-line-height: var(--bs-line-height-sm);
--bs-btn-input-sm-border-radius: var(--bs-radius-5);
--bs-btn-input-lg-gap: 0.375rem;
--bs-btn-input-lg-min-height: 2.75rem;
--bs-btn-input-lg-padding-y: 0.5rem;
--bs-btn-input-lg-padding-x: 1rem;
--bs-btn-input-lg-font-size: var(--bs-font-size-md);
--bs-btn-input-lg-line-height: var(--bs-line-height-md);
--bs-btn-input-lg-border-radius: var(--bs-radius-7);
}
Documentation navigation
On this page
On this page