Forms
Overview
Form controls, labels, help text and disabled states in the RopeBreak.net theme — validated by the browser, no script.
How it works in this theme
Bootstrap's form classes are unchanged. What changes is the look, and how validation is triggered.
-
Text inputs, textareas and selects sit on
cream-50(#faf3df) with acream-300border and the theme's 2 px "bracket" radius — the same radius as buttons. -
Focus is a gold ring:
0 0 0 .25rem rgba(184, 148, 31, .4), the same colour as--bs-focus-ring-color. The border tints to pale gold at the same time. -
Checked checkboxes, radios, switches and the range thumb use
primary—gold-700in light mode,gold-500in dark mode — with a navy check mark. - Input-group addons use
cream-300(#d9cdb0). -
Validation is native. A field turns green or red through
:user-valid/:user-invalidonce the user has interacted with it. No.was-validatedclass, no script. See Validation.
The section is split the same way as Bootstrap's docs:
- Form control — text inputs, textareas, file and color inputs.
- Select — the custom chevron select.
- Checks & radios — checkboxes, radios, switches and toggle buttons.
- Range — sliders.
- Input group — addons and buttons either side of a field.
- Floating labels — labels that float over the field.
- Layout — grids, horizontal and inline forms.
- Validation — native constraint validation, styled.
Overview
Bootstrap's form controls expand on Reboot's rebuilt form styles with classes. Use these classes to opt into the customised look, which is consistent across browsers and devices.
Be sure to use an appropriate type attribute on all inputs (e.g. email for email
addresses, number for numeric information). It gives you the right keyboard on touch devices
and, in this theme, it also drives native validation.
HTML
<form>
<div class="mb-4">
<label for="overview-email" class="form-label">Email address</label>
<input type="email" class="form-control" id="overview-email" aria-describedby="overview-email-help" />
<div id="overview-email-help" class="form-text">We'll never share your email with another promotion.</div>
</div>
<div class="mb-4">
<label for="overview-password" class="form-label">Password</label>
<input type="password" class="form-control" id="overview-password" />
</div>
<div class="mb-4 form-check">
<input type="checkbox" class="form-check-input" id="overview-remember" />
<label class="form-check-label" for="overview-remember">Remember this locker room</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
Each field is a block with .mb-4 (1 rem on the theme's 4 px scale) between fields. Labels use
.form-label, which adds .5rem below the label.
Form text
Block-level or inline help text can be created with .form-text. It renders in
--bs-secondary-color (navy-400) at .875em.
aria-describedby. Screen readers then announce the
help text when the user focuses the field.Form text below inputs can be styled with .form-text. If a block-level element is used, a top margin is added.
HTML
<label for="overview-ring-name" class="form-label">Ring name</label>
<input type="text" id="overview-ring-name" class="form-control" aria-describedby="overview-ring-name-help" />
<div id="overview-ring-name-help" class="form-text">
Must be 2–40 characters. No real names, no copyrighted gimmicks.
</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="overview-inline-pw" class="col-form-label">Password</label>
</div>
<div class="col-auto">
<input type="password" id="overview-inline-pw" class="form-control" aria-describedby="overview-inline-pw-help" />
</div>
<div class="col-auto">
<span id="overview-inline-pw-help" class="form-text">Must be 8–20 characters long.</span>
</div>
</div>Disabled forms
Add the disabled boolean attribute on an input to prevent user interaction and make it appear
lighter. Disabled inputs take --bs-secondary-bg (cream-300) as their background.
<input class="form-control" id="disabled-input" type="text" placeholder="Disabled input" aria-label="Disabled input example" disabled />
Add the disabled attribute to a <fieldset> to disable all the controls
within. Browsers treat every native form control inside a <fieldset disabled> as
disabled — no keyboard focus and no mouse clicks.
HTML
<form>
<fieldset disabled>
<legend>Disabled fieldset</legend>
<div class="mb-4">
<label for="overview-disabled-text" class="form-label">Disabled input</label>
<input type="text" id="overview-disabled-text" class="form-control" placeholder="Disabled input" />
</div>
<div class="mb-4">
<label for="overview-disabled-select" class="form-label">Disabled select menu</label>
<select id="overview-disabled-select" class="form-select">
<option>Disabled select</option>
</select>
</div>
<div class="mb-4">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="overview-disabled-check" />
<label class="form-check-label" for="overview-disabled-check">Can't check this</label>
</div>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form><a class="btn btn-primary">,
those only receive pointer-events: none from the fieldset:disabled .btn rule. They
stay focusable and operable with the keyboard. Add tabindex="-1" and
aria-disabled="true" to them yourself.Accessibility
Ensure that all form controls have an appropriate accessible name so that their purpose can be conveyed to
users of assistive technologies. The simplest way is a <label> element, or — in the case
of buttons — sufficiently descriptive text in the <button>…</button> content.
When a visible label is not possible, there are other options. In order of preference:
- A
<label>hidden with.visually-hidden. - Pointing to an existing element that can act as a label using
aria-labelledby. - Providing a
titleattribute. - Explicitly setting the accessible name on an element using
aria-label.
If none of these are present, assistive technologies may fall back to the placeholder attribute
as the accessible name on <input> and <textarea>. Do not rely on it:
placeholders disappear once the user types, and the theme renders them in the secondary text colour on
purpose.
Two theme-specific notes. First, the gold focus ring is not removed in any example; keep it. Second,
validation colours only appear after interaction, so never use colour as the only signal — pair every state
with a .valid-feedback / .invalid-feedback message.
A complete example
Everything above in one form: grid layout, labels, help text, an input group, selects, radios and a
required checkbox. Every field validates natively; tab through it and leave a required field empty to see
the red state. Submitting with the browser's own messages still works because there is no
novalidate.
HTML
<form class="row g-4">
<div class="col-md-6">
<label for="overview-full-ring" class="form-label">Ring name</label>
<input type="text" class="form-control" id="overview-full-ring" required minlength="2" />
<div class="invalid-feedback">A ring name is required.</div>
</div>
<div class="col-md-6">
<label for="overview-full-real" class="form-label">Real name</label>
<input type="text" class="form-control" id="overview-full-real" aria-describedby="overview-full-real-help" />
<div id="overview-full-real-help" class="form-text">Kept in kayfabe. Never printed on the program.</div>
</div>
<div class="col-md-6">
<label for="overview-full-from" class="form-label">Billed from</label>
<input type="text" class="form-control" id="overview-full-from" placeholder="Parts Unknown" />
</div>
<div class="col-md-3">
<label for="overview-full-weight" class="form-label">Weight</label>
<div class="input-group has-validation">
<input type="number" class="form-control" id="overview-full-weight" min="100" max="600" required />
<span class="input-group-text">lbs</span>
<div class="invalid-feedback">Between 100 and 600 lbs.</div>
</div>
</div>
<div class="col-md-3">
<label for="overview-full-debut" class="form-label">Debut</label>
<input type="date" class="form-control" id="overview-full-debut" min="1985-01-01" max="2002-12-31" />
</div>
<div class="col-md-6">
<label for="overview-full-finisher" class="form-label">Finisher</label>
<input type="text" class="form-control" id="overview-full-finisher" required />
<div class="invalid-feedback">Every worker needs a finisher.</div>
</div>
<div class="col-md-6">
<label for="overview-full-promotion" class="form-label">Home promotion</label>
<select id="overview-full-promotion" class="form-select" required>
<option value="" selected>Choose…</option>
<option>Territory</option>
<option>National</option>
<option>Independent</option>
</select>
<div class="invalid-feedback">Pick a promotion.</div>
</div>
<fieldset class="col-12">
<legend class="col-form-label pt-0">Alignment</legend>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="overview-full-align" id="overview-full-face" value="face" checked />
<label class="form-check-label" for="overview-full-face">Face</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="overview-full-align" id="overview-full-heel" value="heel" />
<label class="form-check-label" for="overview-full-heel">Heel</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="overview-full-align" id="overview-full-tweener" value="tweener" />
<label class="form-check-label" for="overview-full-tweener">Tweener</label>
</div>
</fieldset>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="overview-full-agree" required />
<label class="form-check-label" for="overview-full-agree">I agree to protect the business</label>
<div class="invalid-feedback">You must agree before signing.</div>
</div>
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Sign the contract</button>
<button type="reset" class="btn btn-outline-secondary">Reset</button>
</div>
</form>No JavaScript
Stock Bootstrap ships exactly one piece of form JavaScript: the snippet that adds
.was-validated on submit. This theme replaces it with two CSS pseudo-classes,
:user-invalid and :user-valid, which browsers set after the user has edited a
field or tried to submit. Everything else on this page — labels, help text, disabled fieldsets, input
groups, floating labels, toggle buttons — was already pure HTML and CSS in Bootstrap.
Two small additions in scss/components/_forms.scss: label.btn loses its bottom
margin (so toggle buttons line up), and <input type="checkbox" switch> keeps the
Bootstrap switch look rather than Safari's native one.
Sass variables
The theme's form overrides live in scss/_variables.scss. Every other
$input-*, $form-* variable keeps Bootstrap's default.
$input-btn-focus-color-opacity: 0.25;
$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;
$form-select-border-radius: $border-radius-sm;
$form-check-input-border-radius: $border-radius-sm;
$form-check-input-border: 1px solid $rb-navy-400;
$form-check-input-checked-bg-color: $primary; // gold-700
$form-check-input-checked-color: $rb-navy-900;
$form-switch-color: $rb-navy-300;
$form-range-thumb-bg: $primary;
$form-range-track-bg: $rb-cream-300;
$input-group-addon-bg: $rb-cream-300;
Dark-mode validation colours are set in scss/_variables-dark.scss:
$form-valid-color-dark: #8fd092;
$form-valid-border-color-dark: #8fd092;
$form-invalid-color-dark: #f0a19a;
$form-invalid-border-color-dark: #f0a19a;
The dark-mode swap of checked checks and the range thumb to gold-500 is in
scss/_tokens.scss, because Bootstrap compiles those colours statically from
$primary.