Aligning form controls in a row with other elements
When putting form controls (inputs, selects etc) inline with text, or in a center-aligned flex container with other elements, we may run into alignment issues when the form controls have labels, errors, or descriptions.
The presence of these labels or errors changes the dimensions of the form control's element, making it no longer aligned with the rest of the content as expected.
To support these scenarios, form control components accept a withCenterBaseline
argument. Enabling it makes the components render a custom CSS grid, which
makes the baseline of the form control component align with the baseline of text
nodes.
The keyword baseline is important here: when using this option, all elements
must either be inline elements, or must be placed in a flex container with a
baseline alignment (not center).
This prop, along with the CenterBaseline component,
allows us to correctly align text (and buttons, icons etc) with form elements,
while maintaining correct alignment when those form elements are showing errors
or labels.