r/webdev • • Oct 16 '26

How to manage layouts in forms

I'm trying to design a 2 column form but can't decide how should I render error messages.

If I don't allocate a fixed height for an input div (label + input + error) then entire layout of form gets disturbed whenever an error message is rendered.

If I pre-allocate a fixed min-height for input div (label + input + error) then this does solves the layout shift issue but the form looks bad.

One option is showing an error icon and error message as tooltip on hover but this doesn't works on mobile as users would have to tap on the icon to get error message.

The only solution which I think would work is showing icon + tooltip on desktop and plain error message on mobile as on mobile the form is single column.

Is there any better way to handle this? Would appreciate any suggestion.

No Fixed Min Height
No Fixed Min Height
Fixed Min height
Fixed Min Height
28 Upvotes

46 comments sorted by

View all comments

Show parent comment

1

u/Friction_693 Oct 17 '26

I've tried grid, although it is more scalable as it can also support multi row error messages but I've noticed that if I try to make sure that my error messages are 1 liner then controlling the height manually allows rendering the error messages without layout shift a still slightly more clean.

2

u/SoftwareNegative8783 Oct 18 '26

makes sense. if you can keep every error to one line, a fixed height is cleaner. just watch long translated messages or small mobile screens.