From 7a61f9ddc0a03ca636a6afd0a88d067fa2505641 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Wed, 12 Aug 2026 08:36:29 -0700 Subject: [PATCH 1/3] fix(forms): always float labels on date and time inputs Date, time, datetime-local, month, and week inputs do not support placeholders like text fields, so floating labels looked filled even when empty and padding stayed inconsistent. Keep those controls (and selects) in the floated label and padding state, and document the behavior. Fixes #39257 --- js/tests/visual/floating-label.html | 12 ++++++++ scss/forms/_floating-labels.scss | 29 ++++++++++++++++++- .../content/docs/forms/floating-labels.mdx | 13 +++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/js/tests/visual/floating-label.html b/js/tests/visual/floating-label.html index 4d993d9bca9e..c1085e14c438 100644 --- a/js/tests/visual/floating-label.html +++ b/js/tests/visual/floating-label.html @@ -109,6 +109,18 @@ +
+ + +
+
+ + +
+
+ + +
diff --git a/scss/forms/_floating-labels.scss b/scss/forms/_floating-labels.scss index fe5ec5ace793..1e9bc2c7cbda 100644 --- a/scss/forms/_floating-labels.scss +++ b/scss/forms/_floating-labels.scss @@ -91,12 +91,39 @@ $form-floating-tokens: defaults( } } + // Date and time inputs (and ``s, they’ll always sh
`} /> +## Date and time + +Date, time, datetime-local, month, and week inputs also always show the ` -`} /> - -Date picker -`} /> - -Time picker -`} /> - ### File `input[type="file"]` elements are styled with the `::file-selector-button` pseudo element to add a button to the input. You only need to add the `.form-control` class, plus any size modifiers you need. From 898a9561c333b8d2cd3eae2817d9f7cdb4717cfc Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Wed, 12 Aug 2026 19:12:08 -0700 Subject: [PATCH 3/3] feat(forms): add always-floating labels for v6 Port the always-visible floating label opt-in from #36155 to the v6 token and label-first :has() model. Show placeholders on focus by default, and add .form-floating-always to keep the label floated with a visible placeholder. Supersedes #36155 --- js/tests/visual/floating-label.html | 8 ++++ scss/forms/_floating-labels.scss | 40 +++++++++++++++++++ .../content/docs/forms/floating-labels.mdx | 17 +++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/js/tests/visual/floating-label.html b/js/tests/visual/floating-label.html index c1085e14c438..5d51c58e80c0 100644 --- a/js/tests/visual/floating-label.html +++ b/js/tests/visual/floating-label.html @@ -121,6 +121,14 @@ +
+ + +
+
+ + +
diff --git a/scss/forms/_floating-labels.scss b/scss/forms/_floating-labels.scss index 1e9bc2c7cbda..9a34c4c95758 100644 --- a/scss/forms/_floating-labels.scss +++ b/scss/forms/_floating-labels.scss @@ -79,6 +79,11 @@ $form-floating-tokens: defaults( color: transparent; } + // Show the placeholder once focused so the floated label has a hint. + &:focus::placeholder { + color: var(--control-placeholder-color); + } + &:focus, &:not(:placeholder-shown) { padding-top: var(--form-floating-input-padding-t); @@ -157,4 +162,39 @@ $form-floating-tokens: defaults( color: var(--form-floating-label-disabled-color); } } + + // Opt in to an always-floated label with a visible placeholder. Works on the + // `.form-floating` itself or as a wrapper around one. + .form-floating-always { + &.form-floating, + .form-floating { + > .form-control { + padding-top: var(--form-floating-input-padding-t); + padding-bottom: var(--form-floating-input-padding-b); + + &::placeholder, + &:focus::placeholder { + color: var(--control-placeholder-color); + } + } + + > label { + transform: var(--form-floating-label-transform); + } + + > label:has(~ textarea)::after { + position: absolute; + inset: var(--form-floating-padding-y) calc(var(--form-floating-padding-x) * .5); + z-index: -1; + height: var(--form-floating-label-height); + content: ""; + background-color: var(--form-floating-label-bg); + @include border-radius(var(--btn-input-border-radius)); + } + + > label:has(~ textarea:disabled)::after { + background-color: var(--form-floating-label-disabled-bg); + } + } + } } diff --git a/site/src/content/docs/forms/floating-labels.mdx b/site/src/content/docs/forms/floating-labels.mdx index 13d89df4e91e..09b9a6a2bb1a 100644 --- a/site/src/content/docs/forms/floating-labels.mdx +++ b/site/src/content/docs/forms/floating-labels.mdx @@ -9,7 +9,7 @@ css_layer: forms Wrap a pair of `` and `
`} /> +## Always floating + +Add `.form-floating-always` to keep the label floated and show the placeholder. Use it on the `.form-floating` itself or as a wrapper around one. + + + + + +
+ + +
`} /> + +By default, placeholders stay transparent until the control is focused. With `.form-floating-always`, the placeholder stays visible in both states. + ## Layout When working with the Bootstrap grid system, be sure to place form elements within column classes.