Skip to content

Conversation

@jouni
Copy link
Member

@jouni jouni commented Oct 14, 2025

  • Change all field components to use CSS grid layout on the host.
  • Make the internal .vaadin-*-container elements irrelevant with display: contents.
  • Use a pseudo element to set the baseline alignment of fields, while keeping support for multiline labels.

This change removes the ability to globally set "helper-above-field" variant on all fields with the --vaadin-input-field-helper-order property. Might still be possible with the new custom properties, but might require two properties instead of one.

Before

Screenshot 2025-10-15 at 11 40 01

After

Screenshot 2025-10-15 at 11 39 35

@jouni jouni force-pushed the refactor/baseline-alignment branch from 8e954af to d0f6061 Compare October 14, 2025 07:40
--_has-helper: ;
--_no-error: initial;
--_has-error: ;
display: inline-grid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question: would this also help to get us common features like "help-icon" next to the label or field? It's a pretty common UX pattern seen where people want to place an (i) icon on the right side of the label or on the right side of the field which people could click or hover to get more informations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it might, as the label isn't restricted to one line and truncated with an ellipsis, so it should be easier to render custom content in the label slot. But I don't know how feasible that is in general, regarding accessibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.. I'm also talking more about a slot next to the label.. ;) I don't think it would be a good fit within the label

Copy link
Member Author

@jouni jouni Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I don't see why that couldn't be a similar thing as the required indicator, sitting inside the part=label element.

@jouni jouni marked this pull request as ready for review October 15, 2025 08:41
Comment on lines 21 to 26
grid-template-rows:
var(--_helper-below-field, var(--_has-label, auto 0) 1fr var(--_has-helper, auto) var(--_has-error, auto))
var(
--_helper-above-field,
var(--_has-label, auto) var(--_has-helper, auto) var(--_has-label, 0) 1fr var(--_has-error, auto)
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in the daily, we might try to use grid-template-areas instead, see if that makes the code easier to understand.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing we discussed is to use margins instead of gap for the space between the parts. Then we wouldn't need to worry about empty grid cells creating unnecessary gaps, and could reduce the "logic" with the internal custom properties.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to use both. I suppose the code is slightly more readable.

@web-padawan
Copy link
Member

Rebased the PR after merging #10441 where input-fields part was added to date-time-picker.

@jouni jouni marked this pull request as draft November 7, 2025 07:32
@jouni
Copy link
Member Author

jouni commented Nov 7, 2025

Damn, I broke the alignment in Safari and Firefox when fields don't have a label.

@jouni jouni marked this pull request as ready for review November 7, 2025 07:47
color: var(--vaadin-input-field-error-color, var(--vaadin-text-color));
display: flex;
gap: var(--vaadin-gap-s);
gap: var(--vaadin-gap-xs);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extracted this into #10462 along with relevant screenshot updates, to make this PR focused on alignment.

@web-padawan web-padawan force-pushed the refactor/baseline-alignment branch from 681bcca to 3cc48fd Compare November 10, 2025 10:43
@sonarqubecloud
Copy link

@web-padawan web-padawan merged commit 128837a into main Nov 10, 2025
11 of 12 checks passed
@web-padawan web-padawan deleted the refactor/baseline-alignment branch November 10, 2025 11:52
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.

4 participants