Forms
File, range, and color controls
Use styled native file uploads, range sliders, and color pickers with labels, states, sizes, and accessible values.
Forms
File, range, and color controls
These controls retain native browser behavior. Pair each one with a persistent label and explain constraints before submission.
File upload
PDF or Word document, up to 10 MB.
HTML · File upload
<!-- Default file upload with help text -->
<div class="bs-form-group">
<label class="bs-label" for="brief">Project brief</label>
<input class="bs-file" id="brief" type="file" accept=".pdf,.doc,.docx" aria-describedby="brief-help" />
<span class="bs-form-text" id="brief-help">PDF or Word document, up to 10 MB.</span>
</div>
<!-- Compact and large file sizes -->
<input class="bs-file bs-file-sm" type="file" aria-label="Compact file upload" />
<input class="bs-file bs-file-lg" type="file" aria-label="Large file upload" disabled />Range slider
HTML · Range slider
<div class="bs-form-group">
<div class="bs-flex bs-items-center bs-justify-between bs-gap-3">
<label class="bs-label" for="volume">Notification volume</label>
<output class="bs-badge bs-badge-primary" id="volume-value" for="volume">65%</output>
</div>
<input class="bs-range" id="volume" type="range" min="0" max="100" value="65" aria-describedby="volume-value" data-native-output="volume-value" />
</div>Color picker
HTML · Color picker
<div class="bs-form-group">
<label class="bs-label" for="accent">Accent color</label>
<div class="bs-flex bs-items-center bs-gap-3">
<input class="bs-color" id="accent" type="color" value="#d9468f" aria-describedby="accent-value" data-native-output="accent-value" />
<output class="bs-badge" id="accent-value" for="accent">#D9468F</output>
</div>
</div>Invalid file state
Please select a valid image or PDF under 5 MB.
HTML · Invalid file upload
<div class="bs-form-group">
<label class="bs-label" for="id-document">
Identity verification document <span class="bs-label-required" aria-hidden="true">*</span>
</label>
<input
class="bs-file bs-is-invalid"
id="id-document"
type="file"
accept=".jpg,.png,.pdf"
aria-invalid="true"
aria-describedby="doc-error"
required
/>
<span class="bs-form-feedback bs-form-feedback-invalid" id="doc-error">
Please select a valid image or PDF under 5 MB.
</span>
</div>JavaScript · Synchronize native values
document.querySelectorAll("[data-native-output]").forEach((input) => {
const output = document.querySelector(`#${input.dataset.nativeOutput}`);
const render = () => {
output.value = input.type === "range" ? `${input.value}%` : input.value.toUpperCase();
};
input.addEventListener("input", render);
render();
});Validate files on the server
accept guides selection but is not a security boundary.
Expose the current value
When a range or color value matters precisely, update a connected output as the user changes it.
Keep native behavior
Do not replace these inputs with div-based controls unless the product requirement justifies recreating all keyboard and form behavior.
Control API
Native control classes enhance file pickers, sliders, and color inputs with framework styling while preserving browser accessibility.
| Class | Purpose |
|---|---|
.bs-file | Styles file input button and file name area with custom padding and typography. |
.bs-file-sm | Compact file input sizing (2.25rem height) for dense upload forms. |
.bs-file-lg | Large file input sizing (3.25rem height) for prominent drag-or-browse targets. |
.bs-range | Styles range sliders with theme thumb colors, custom tracks, and smooth drag states. |
.bs-color | Circular or rounded swatch input for native HTML color pickers. |