--form-floating-input-padding-t: 1.625rem,
--form-floating-input-padding-b: .625rem,
--form-floating-label-height: 1.5em,
+ // Backgrounds for the textarea label's masking pseudo-element. Mirrors
+ // `.form-control` here because the label is a sibling of the control, so it
+ // can't inherit the control's own `--control-bg`/`--control-disabled-bg`.
+ --form-floating-label-bg: var(--btn-input-bg),
+ --form-floating-label-disabled-bg: var(--bg-2),
--form-floating-label-opacity: .65,
--form-floating-label-transform: scale(.85) translateY(-.5rem) translateX(.15rem),
--form-floating-label-disabled-color: var(--fg-3),
@include transition(var(--form-floating-transition));
}
+ // Anchor the label to the top for textareas so it floats correctly at any height
+ > textarea ~ label {
+ align-items: flex-start;
+ }
+
> .form-control,
> .form-control-plaintext {
height: var(--form-floating-height);
z-index: -1;
height: var(--form-floating-label-height);
content: "";
- background-color: var(--control-bg);
+ background-color: var(--form-floating-label-bg);
@include border-radius(var(--btn-input-border-radius));
}
}
> textarea:disabled ~ label::after {
- background-color: var(--control-disabled-bg);
+ background-color: var(--form-floating-label-disabled-bg);
}
> .form-control-plaintext {
}
}
- @media (prefers-color-scheme: dark) {
+ [data-bs-theme="dark"] {
select.form-control,
.form-control-caret {
background-image: var(--control-select-bg-dark);
cursor: default;
}
}
+ &:disabled:checked {
+ opacity: var(--radio-disabled-opacity);
+ }
&:focus-visible {
@include focus-ring(true);
@include focus-ring(true);
}
+ &:has(input:disabled:not(:checked)) {
+ --switch-bg: var(--switch-disabled-bg);
+ --switch-indicator-bg: var(--switch-disabled-indicator-bg);
+
+ &::before { opacity: .4; }
+
+ ~ label {
+ color: var(--fg-3);
+ cursor: default;
+ }
+ }
+
&:has(input:checked) {
background-color: var(--theme-bg, var(--switch-checked-bg));
border-color: var(--theme-bg, var(--switch-checked-border-color));
}
}
- &:has(input:disabled) {
- --switch-bg: var(--switch-disabled-bg);
- --switch-indicator-bg: var(--switch-disabled-indicator-bg);
-
- &::before { opacity: .4; }
+ &:has(input:checked:disabled) {
+ opacity: .65;
~ label {
- color: var(--secondary-fg);
+ color: var(--fg-3);
cursor: default;
}
}
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input’s state.
-<Example code={`<div class="form-field">
+<Example class="vstack gap-2" code={`<div class="form-field">
<input type="checkbox" id="checkDisabled" class="check" disabled />
<label for="checkDisabled">Example new checkbox</label>
- </div>`} />
-
-Applies to checked states, too.
+ </div>
-<Example code={`<div class="form-field">
+ <div class="form-field">
<input type="checkbox" id="checkDisabledChecked" class="check" checked disabled />
<label for="checkDisabledChecked">Example new checkbox</label>
</div>`} />
The Bootstrap Datepicker is a wrapper around [Vanilla Calendar Pro](https://vanilla-calendar.pro/) that provides a consistent, accessible date selection experience. It supports light/dark themes, input binding, and flexible configuration via data attributes or JavaScript.
<Example code={`<label for="datepicker1" class="form-label">Datepicker</label>
- <input type="text" class="form-control w-12" id="datepicker1" data-bs-toggle="datepicker" placeholder="Choose date…">`} />
+ <input type="text" class="form-control w-12" id="datepicker1" data-bs-toggle="datepicker" autocomplete="off" placeholder="Choose date…">`} />
Note that we’re using a width utility of `.w-12` to ensure the input is wide enough to accommodate the date format and imply some affordance for the expected type of input.
<Example code={`<div class="form-field">
<label for="datepicker2" class="form-label">Datepicker field</label>
- <input type="text" class="form-control w-12" id="datepicker2" data-bs-toggle="datepicker" placeholder="Choose date…">
+ <input type="text" class="form-control w-12" id="datepicker2" data-bs-toggle="datepicker" autocomplete="off" placeholder="Choose date…">
<div class="form-text">
We’ll never share your email with anyone else.
</div>
<div class="form-adorn-icon">
<svg class="bi" width="16" height="16"><use href="#calendar-week" /></svg>
</div>
- <input type="text" class="form-ghost" id="datepickerIconStart" data-bs-toggle="datepicker" placeholder="Choose date…">
+ <input type="text" class="form-ghost" id="datepickerIconStart" data-bs-toggle="datepicker" autocomplete="off" placeholder="Choose date…">
</div>`} />
### Min & Max dates
Restrict the selectable date range using `data-bs-date-min` and `data-bs-date-max`.
<Example code={`<label for="datepickerMinMax" class="form-label">Event date (2026 only)</label>
- <input type="text" class="form-control w-12" id="datepickerMinMax" data-bs-toggle="datepicker" data-bs-date-min="2026-01-01" data-bs-date-max="2026-12-31" placeholder="Select a date in 2026">`} />
+ <input type="text" class="form-control w-12" id="datepickerMinMax" data-bs-toggle="datepicker" autocomplete="off" data-bs-date-min="2026-01-01" data-bs-date-max="2026-12-31" placeholder="Select a date in 2026">`} />
### Multiple dates
Enable multiple date selection with `data-bs-selection-mode="multiple"`.
<Example code={`<label for="datepicker3" class="form-label">Select multiple dates</label>
- <input type="text" class="form-control" id="datepicker3" data-bs-toggle="datepicker" data-bs-selection-mode="multiple" placeholder="Select date range…">`} />
+ <input type="text" class="form-control" id="datepicker3" data-bs-toggle="datepicker" autocomplete="off" data-bs-selection-mode="multiple" placeholder="Select date range…">`} />
### Multiple months
Display multiple months side-by-side with the `displayMonthsCount` option. This is useful for date range selection where users need to see more context.
<Example code={`<label for="datepickerMultiMonth" class="form-label">Select date range</label>
- <input type="text" class="form-control" id="datepickerMultiMonth" data-bs-toggle="datepicker" data-bs-selection-mode="multiple-ranged" data-bs-display-months-count="2" placeholder="Select start and end dates">`} />
+ <input type="text" class="form-control" id="datepickerMultiMonth" data-bs-toggle="datepicker" autocomplete="off" data-bs-selection-mode="multiple-ranged" data-bs-display-months-count="2" placeholder="Select start and end dates">`} />
### Date range
Select a range of dates with `data-bs-selection-mode="multiple-ranged"`. Use `data-bs-selected-dates` to preselect a date range.
<Example code={`<label for="datepicker4" class="form-label">Select date range</label>
- <input type="text" class="form-control" id="datepicker4" data-bs-toggle="datepicker" data-bs-selection-mode="multiple-ranged" data-bs-selected-dates='["2026-06-10", "2026-06-18"]' placeholder="Select start and end dates…">`} />
+ <input type="text" class="form-control" id="datepicker4" data-bs-toggle="datepicker" autocomplete="off" data-bs-selection-mode="multiple-ranged" data-bs-selected-dates='["2026-06-10", "2026-06-18"]' placeholder="Select start and end dates…">`} />
### Multi-month date range
For selecting date ranges that span multiple months, combine `data-bs-selection-mode="multiple-ranged"` with `data-bs-display-months-count="2"` to show two months side-by-side, making it easier for users to select across month boundaries.
<Example code={`<label for="datepickerRangeTwoMonths" class="form-label">Select date range</label>
- <input type="text" class="form-control" id="datepickerRangeTwoMonths" data-bs-toggle="datepicker" data-bs-selection-mode="multiple-ranged" data-bs-display-months-count="2" data-bs-selected-dates='["2026-06-25", "2026-07-08"]' placeholder="Select start and end dates…">`} />
+ <input type="text" class="form-control" id="datepickerRangeTwoMonths" data-bs-toggle="datepicker" autocomplete="off" data-bs-selection-mode="multiple-ranged" data-bs-display-months-count="2" data-bs-selected-dates='["2026-06-25", "2026-07-08"]' placeholder="Select start and end dates…">`} />
## Options
Set the first day of the week (0 = Sunday, 1 = Monday, etc.) with `data-bs-first-weekday`.
<Example code={`<label for="datepicker6" class="form-label">Week starts on Sunday</label>
- <input type="text" class="form-control w-12" id="datepicker6" data-bs-toggle="datepicker" data-bs-first-weekday="0" placeholder="Select a date">`} />
+ <input type="text" class="form-control w-12" id="datepicker6" data-bs-toggle="datepicker" autocomplete="off" data-bs-first-weekday="0" placeholder="Select a date">`} />
### Placement
<Example code={`<div class="d-flex gap-3">
<div>
<label for="datepickerLeft" class="form-label">Left aligned</label>
- <input type="text" class="form-control" id="datepickerLeft" data-bs-toggle="datepicker" data-bs-placement="left" placeholder="Left">
+ <input type="text" class="form-control" id="datepickerLeft" data-bs-toggle="datepicker" autocomplete="off" data-bs-placement="left" placeholder="Left">
</div>
<div>
<label for="datepickerCenter" class="form-label">Center aligned</label>
- <input type="text" class="form-control" id="datepickerCenter" data-bs-toggle="datepicker" data-bs-placement="center" placeholder="Center">
+ <input type="text" class="form-control" id="datepickerCenter" data-bs-toggle="datepicker" autocomplete="off" data-bs-placement="center" placeholder="Center">
</div>
<div>
<label for="datepickerRight" class="form-label">Right aligned</label>
- <input type="text" class="form-control" id="datepickerRight" data-bs-toggle="datepicker" data-bs-placement="right" placeholder="Right">
+ <input type="text" class="form-control" id="datepickerRight" data-bs-toggle="datepicker" autocomplete="off" data-bs-placement="right" placeholder="Right">
</div>
</div>`} />
<Example code={`<div data-bs-theme="dark" class="p-3 bg-body fg-body rounded">
<label for="datepickerDark" class="form-label">Dark mode datepicker</label>
- <input type="text" class="form-control" id="datepickerDark" data-bs-toggle="datepicker" placeholder="Select a date">
+ <input type="text" class="form-control" id="datepickerDark" data-bs-toggle="datepicker" autocomplete="off" placeholder="Select a date">
</div>`} />
### Datepicker-only theme
Use `data-bs-datepicker-theme` to set the datepicker popup’s theme independently of the input. This is useful when you want a light input with a dark datepicker, or vice versa:
<Example code={`<label for="datepickerTheme" class="form-label">Light input, dark datepicker</label>
-<input type="text" class="form-control w-12" id="datepickerTheme" data-bs-toggle="datepicker" data-bs-datepicker-theme="dark" placeholder="Select a date">`} />
+<input type="text" class="form-control w-12" id="datepickerTheme" data-bs-toggle="datepicker" autocomplete="off" data-bs-datepicker-theme="dark" placeholder="Select a date">`} />
## CSS
<label for="floatingTextarea">Comments</label>
</div>`} />
-To set a custom height on your `<textarea>`, do not use the `rows` attribute. Instead, set an explicit `height` (either inline or via custom CSS).
+To set a custom height on your `<textarea>`, do not use the `rows` attribute. Instead, override the `--bs-form-floating-height` CSS variable on the `.form-floating` wrapper (either inline or via custom CSS) so the label floats correctly at any height.
-<Example code={`<div class="form-floating">
- <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2" style="height: 100px"></textarea>
+<Example code={`<div class="form-floating" style="--bs-form-floating-height: 100px">
+ <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2"></textarea>
<label for="floatingTextarea2">Comments</label>
</div>`} />
<textarea class="form-control" placeholder="Leave a comment here" id="floatingTextareaDisabled" disabled></textarea>
<label for="floatingTextareaDisabled">Comments</label>
</div>
- <div class="form-floating">
- <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2Disabled" style="height: 100px" disabled>Disabled textarea with some text inside</textarea>
+ <div class="form-floating" style="--bs-form-floating-height: 100px">
+ <textarea class="form-control" placeholder="Leave a comment here" id="floatingTextarea2Disabled" disabled>Disabled textarea with some text inside</textarea>
<label for="floatingTextarea2Disabled">Comments</label>
</div>
<div class="form-floating">
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input’s state.
-<Example code={`<div class="form-field">
+<Example class="vstack gap-2" code={`<div class="form-field">
<input type="radio" id="radioDisabled" class="radio" disabled />
<label for="radioDisabled">Example new radio</label>
</div>
- `} />
+
+ <div class="form-field">
+ <input type="radio" id="radioCheckedDisabled" class="radio" disabled checked />
+ <label for="radioCheckedDisabled">Example checked disabled radio</label>
+ </div>`} />
## Sizes
Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input’s state.
-<Example class="d-flex flex-column gap-3" code={`<div class="form-field">
+<Example class="vstack gap-2" code={`<div class="form-field">
<div class="switch">
<input type="checkbox" value="" id="switchDisabledLabel" role="switch" switch disabled>
</div>
<label for="switchDisabledLabel">Disabled switch</label>
+ </div>
+
+ <div class="form-field">
+ <div class="switch">
+ <input type="checkbox" value="" id="switchCheckedDisabledLabel" role="switch" switch disabled checked>
+ </div>
+ <label for="switchCheckedDisabledLabel">Disabled checked switch</label>
</div>`} />
## Sizes