Forms
Form control
Text inputs, textareas, file and color inputs with the cream field, gold focus ring and 2 px radius.
How it works in this theme
.form-control is Bootstrap's class. The theme changes the colours and the radius:
- Background
cream-50(#faf3df), bordercream-300(#d9cdb0), radius 2 px at every size. - Text uses
--bs-body-color; placeholder text uses--bs-secondary-color(navy-400). - Focus: border tints to pale gold and a
.25remring ofrgba(184, 148, 31, .4)appears. - Disabled: background
--bs-secondary-bg(cream-300), text unchanged. - The file-selector button uses
--bs-tertiary-bg, darkening to--bs-secondary-bgon hover.
Nothing here needs a script. Validation states are covered in Validation.
Example
HTML
<div class="mb-4">
<label for="form-control-email" class="form-label">Email address</label>
<input type="email" class="form-control" id="form-control-email" placeholder="[email protected]" />
</div>
<div class="mb-4">
<label for="form-control-textarea" class="form-label">Promo</label>
<textarea class="form-control" id="form-control-textarea" rows="3"></textarea>
</div>Sizing
Set heights using classes like .form-control-lg and .form-control-sm. Large is
1.125rem text with .5rem 1rem padding; small is .875rem text with
.25rem .5rem. The radius stays 2 px at every size.
HTML
<label for="form-control-lg" class="visually-hidden">Large input</label>
<input class="form-control form-control-lg mb-4" type="text" id="form-control-lg" placeholder=".form-control-lg" />
<label for="form-control-default" class="visually-hidden">Default input</label>
<input class="form-control mb-4" type="text" id="form-control-default" placeholder="Default input" />
<label for="form-control-sm" class="visually-hidden">Small input</label>
<input class="form-control form-control-sm" type="text" id="form-control-sm" placeholder=".form-control-sm" />Form text
Block-level or inline-level form text can be created using .form-text. Link it to the control
with aria-describedby.
HTML
<label for="form-control-pw" class="form-label">Password</label>
<input type="password" id="form-control-pw" class="form-control" aria-describedby="form-control-pw-help" />
<div id="form-control-pw-help" class="form-text">
Your password must be 8–20 characters long, contain letters and numbers, and must not contain spaces,
special characters, or emoji.
</div>Inline text can use any typical inline HTML element with nothing more than the .form-text class.
HTML
<div class="row g-4 align-items-center">
<div class="col-auto">
<label for="form-control-pw-inline" class="col-form-label">Password</label>
</div>
<div class="col-auto">
<input type="password" id="form-control-pw-inline" class="form-control" aria-describedby="form-control-pw-inline-help" />
</div>
<div class="col-auto">
<span id="form-control-pw-inline-help" class="form-text">Must be 8–20 characters long.</span>
</div>
</div>Disabled
Add the disabled boolean attribute on an input to give it a greyed-out appearance, remove
pointer events, and prevent focusing.
HTML
<label for="form-control-disabled" class="visually-hidden">Disabled input</label>
<input class="form-control mb-4" type="text" id="form-control-disabled" placeholder="Disabled input" aria-label="Disabled input example" disabled />
<label for="form-control-disabled-ro" class="visually-hidden">Disabled readonly input</label>
<input class="form-control" type="text" id="form-control-disabled-ro" value="Disabled readonly input" aria-label="Disabled input example" disabled readonly />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.
The theme leaves readonly fields in the normal cream so the difference is clear.
HTML
<label for="form-control-readonly" class="visually-hidden">Readonly input</label>
<input class="form-control" type="text" id="form-control-readonly" value="Readonly input here…" aria-label="readonly input example" readonly />Readonly plain text
If you want to have <input readonly> elements in your form styled as plain text, replace
.form-control with .form-control-plaintext. It removes the field's background and
border but keeps the padding and line-height, so it lines up with its neighbours.
HTML
<div class="mb-4 row">
<label for="form-control-static-email" class="col-sm-2 col-form-label">Email</label>
<div class="col-sm-10">
<input type="text" readonly class="form-control-plaintext" id="form-control-static-email" value="[email protected]" />
</div>
</div>
<div class="mb-4 row">
<label for="form-control-input-pw" class="col-sm-2 col-form-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="form-control-input-pw" />
</div>
</div>HTML
<form class="row g-4">
<div class="col-auto">
<label for="form-control-static-email-2" class="visually-hidden">Email</label>
<input type="text" readonly class="form-control-plaintext" id="form-control-static-email-2" value="[email protected]" />
</div>
<div class="col-auto">
<label for="form-control-input-pw-2" class="visually-hidden">Password</label>
<input type="password" class="form-control" id="form-control-input-pw-2" placeholder="Password" />
</div>
<div class="col-auto">
<button type="submit" class="btn btn-primary mb-4">Confirm identity</button>
</div>
</form>File input
File inputs are .form-control with type="file". The browser's selector button is
restyled through ::file-selector-button: it inherits the field's border and takes
--bs-tertiary-bg.
HTML
<div class="mb-4">
<label for="form-control-file" class="form-label">Default file input example</label>
<input class="form-control" type="file" id="form-control-file" />
</div>
<div class="mb-4">
<label for="form-control-file-multiple" class="form-label">Multiple files input example</label>
<input class="form-control" type="file" id="form-control-file-multiple" multiple />
</div>
<div class="mb-4">
<label for="form-control-file-disabled" class="form-label">Disabled file input example</label>
<input class="form-control" type="file" id="form-control-file-disabled" disabled />
</div>
<div class="mb-4">
<label for="form-control-file-sm" class="form-label">Small file input example</label>
<input class="form-control form-control-sm" id="form-control-file-sm" type="file" />
</div>
<div>
<label for="form-control-file-lg" class="form-label">Large file input example</label>
<input class="form-control form-control-lg" id="form-control-file-lg" type="file" />
</div>Color
Set the type="color" and add .form-control-color. The class sets a 3 rem width and
resets the swatch's own radius to the theme's 2 px. Use the sizing classes to match other controls.
HTML
<label for="form-control-color" class="form-label">Corner colour</label>
<input type="color" class="form-control form-control-color" id="form-control-color" value="#b8941f" title="Choose your corner colour" />Datalists
Datalists allow you to create a group of <option>s that can be accessed (and
autocompleted) from within an <input>. Browsers draw the suggestion list themselves —
the theme does not style it, and it needs no script.
HTML
<label for="form-control-datalist" class="form-label">Billed from</label>
<input class="form-control" list="form-control-datalist-options" id="form-control-datalist" placeholder="Type to search…" />
<datalist id="form-control-datalist-options">
<option value="Parts Unknown"></option>
<option value="Death Valley"></option>
<option value="The Bronx"></option>
<option value="Venice Beach, California"></option>
<option value="Dudleyville"></option>
</datalist>CSS
Bootstrap 5.3 compiles .form-control from Sass; there are no --bs-form-control-*
custom properties to override at runtime. The control does read these global variables, so changing them in
a [data-bs-theme] region changes the field:
| Variable | Used for |
|---|---|
--bs-body-color | Text, and the file-selector button text |
--bs-secondary-color | Placeholder text |
--bs-secondary-bg | Disabled background; file-selector hover |
--bs-tertiary-bg | File-selector button background |
--bs-border-width | Border width |
The field background (cream-50) and border colour (cream-300) are static values
from $input-bg and $input-border-color.
Sass variables
Set in scss/_variables.scss:
$input-bg: $rb-cream-50;
$input-border-color: $rb-cream-300;
$input-border-radius: $border-radius-sm; // 2px
$input-border-radius-sm: $border-radius-sm;
$input-border-radius-lg: $border-radius-sm;
Everything else — $input-padding-y, $input-font-size,
$input-disabled-bg, $input-placeholder-color, $form-file-button-bg
and friends — keeps Bootstrap's defaults, which resolve to the runtime variables listed above.