Skip to content

feat: apply labels aside to form layout field children - #12601

Draft
vursen wants to merge 38 commits into
mainfrom
feat/form-layout-label-aside-fields
Draft

feat: apply labels aside to form layout field children#12601
vursen wants to merge 38 commits into
mainfrom
feat/form-layout-label-aside-fields

Conversation

@vursen

@vursen vursen commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Description

Depends on #12590

  • Form layout in auto-responsive mode with labelsAside sets the data-form-layout-labels-aside attribute on each child while labels fit beside the fields, and removes it when they fall back above
    • The attribute goes on all children, including form row children, form items and plain elements; the layout no longer touches the theme attribute
  • Fields that support the label-aside theme variant (text fields, pickers, select, combo boxes, custom field, checkbox and radio groups, sliders) also switch to the label-aside layout when the attribute is set
  • vaadin-checkbox, vaadin-radio-button and vaadin-switch indent themselves by the label width plus spacing when the attribute is set, so their controls line up with the inputs
    • Uses padding-inline-start, since the layout resets child margins in auto-responsive mode
  • Added a labels-aside-active host attribute, set while labels are displayed aside, and documented it and the child attribute in the JSDoc. It replaces the internal fits-labels-aside attribute on #layout
  • The layout passes its label width and spacing to the children as --vaadin-field-side-label-width and --vaadin-field-side-label-gap, so every field shares the same label column, also fields without a label
  • Updated the DOM snapshot
  • Replaced the vaadin-form-item wrappers in the labels-aside examples of dev/form-layout-auto-responsive.html with fields as direct children

Type of change

  • Feature

How to test

  1. Open dev/form-layout-auto-responsive.html
  2. Scroll to "autoResponsive inside HorizontalLayout + labels aside"
  3. Make the browser window narrower, then wider again
  4. Labels move beside the fields when there is room and back above them when there isn't; all inputs in a column start at the same x
  5. Optionally add a <vaadin-checkbox label="Newsletter"> to one of those layouts: its box lines up with the inputs

Note

Base theme only. The Lumo styles for the variant live on feat/label-aside-lumo-styles and still need the data-form-layout-labels-aside selectors. Visual tests for this behavior are to be added separately. The slider label sits at the top of its row instead of on the input text line; that comes from the base variant in #12590, where #controls is not baseline-aligned.

🤖 Generated with Claude Code

@vursen
vursen force-pushed the feat/form-layout-label-aside-fields branch from 3c37dc3 to fec5d00 Compare September 3, 2026 09:52
@jouni

jouni commented Sep 4, 2026

Copy link
Copy Markdown
Member

Why labels-aside-active and not simply labels-aside on the form-layout as well?

@vursen

vursen commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Why labels-aside-active and not simply labels-aside on the form-layout as well?

Labels-aside is already used to mean simply that the mode is enabled. So maybe labels-aside-active would be better off as labels-fit-aside or something along those lines instead.

@vursen vursen changed the title feat: apply label-aside variant to form layout field children feat: apply labels aside to form layout field children Sep 4, 2026
@jouni

jouni commented Sep 4, 2026

Copy link
Copy Markdown
Member

labels-aside-active is fine.

@vursen
vursen force-pushed the feat/form-layout-label-aside-fields branch 2 times, most recently from 597b8b7 to ebc6f66 Compare September 7, 2026 08:15
vursen and others added 23 commits September 7, 2026 12:15
The baseline guide now always uses the bottom-anchored configuration:
its area ends at the input's top line and the negative margin pulls it
down over the input box, which works no matter what is displayed above
the input. This removes the has-label / no-label toggle properties,
whose only consumer was the guide, and fixes the baseline of a field
with a helper above and no label, which was reported at the helper's
text line instead of the input's.

The slider controls now get the input border and padding also without
a label; this height previously came from the guide's size in the
no-label configuration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Message-input set --vaadin-input-field-border-width to a unitless 0,
which made the baseline guide's margin calc invalid.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The shared guide now anchors to the first row unconditionally, so the
variant no longer needs its own grid-row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Without a label the label column width and spacing default to 0.
Explicit --vaadin-field-label-width and --vaadin-field-label-spacing
still apply, so a form layout can keep the column to align fields.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Rename the label-aside properties to --vaadin-field-side-label-width
and --vaadin-field-side-label-gap. Their defaults (auto, 1em) apply
only when the field has a label; without one both fall back to 0, while
explicit values still apply so a form layout can keep the column.

The shared label rule uses width: min-content so long labels don't
widen the field. In its own column that collapses the label to one
character, so label-aside sets width: auto on the label.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Replaces the unit test with screenshots of the empty and selected
states, where the label must sit at the same height.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The em-space keeps a text baseline in the empty value button so the
label doesn't move when a value is set in the label-aside variant. The
value button is the box without text, so it carries the rule itself,
like the Lumo button does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The field templates take extra rows after the input from
--_rows-after-input, empty by default, so the slider no longer
duplicates the label-above and label-aside templates for its marks row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The auto-responsive form layout publishes a private inherited
--_form-layout-labels-aside property for its grid items (direct children
and form row children). Fields switch their own grid to a fixed-width
label column + input column via a container style query, so no subgrid
and no JS are needed. Checkboxes, radio buttons and switches keep their
label next to the control and are indented into the input column.

Form items derive their label position from the same property,
replacing the --_form-item-labels-above/aside pair previously published
by the layout and the ::slotted inherit pass-through rules.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
vursen and others added 15 commits September 7, 2026 12:15
The form layout now applies a "label-aside" theme variant to its direct
children instead of publishing an inherited custom property, and sets
the labels-aside-active state attribute on the host. Add Lumo styles
for the variant, stop forwarding it from date-time-picker to its inner
pickers, and align slider, custom-field and date-time-picker with other
fields on the same row.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Apply the label-aside token only to children with a theme property.
Every slotted child gets margin-inline-start of label width plus
spacing through --_label-aside-indent; fields with the variant and
form items set it to 0 since they render the label column themselves.
Replaces the checkable indent rule.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Form row is display: contents with its own slot, so the layout's
::slotted rule never reaches the fields inside a row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Checkboxes, radio buttons and switches add a start margin of the form
layout label width plus spacing when they inherit the labels-aside
toggle, and default the toggle to false so nothing changes outside an
auto-responsive layout. The layout now resets only block margins on
its children so that margin can apply, and no longer indents anything
itself.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Matches #12611, which removes the reset on main.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Keep the margin reset on auto-responsive children: Lumo buttons rely
on it. Form layout and form row now indent vaadin-checkbox,
vaadin-radio-button and vaadin-switch explicitly while labels are
aside, and the checkable styles no longer know about the layout. The
side label width and gap are passed to fields in every mode.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The layout no longer edits the theme attribute of its children. Fields
match [data-form-layout-labels-aside] beside theme~=label-aside, and
checkables indent themselves with padding because the layout margin
reset cancels a host margin. Drops the branch's unit tests; visual
tests will cover this.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Class selectors are cheaper to toggle/match than attribute selectors
across the shared field-base and slider styles.
The layout marks every visible child with data-form-layout-item and adds
the label-aside theme variant while labels fit aside. Field styles match
the theme alone; the attribute scopes form-layout-only rules such as the
checkable indent and the reserved label column for fields without a label.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…bute

Replaces the `[theme~='label-aside']` + `data-form-layout-item` combo with
a single `data-form-layout-labels-aside` attribute set by the layout,
simplifying the CSS selectors and removing the theme-attribute juggling
in `auto-responsive-layout.js`.
@vursen
vursen force-pushed the feat/form-layout-label-aside-fields branch from ebc6f66 to 3dd8209 Compare September 7, 2026 08:15
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

Base automatically changed from feat/label-aside-base-styles to main September 10, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants