Form layouts
Form and form rows
Use the EuiFormRow
component to easily associate form components with labels, help text, and error text. Use the EuiForm
component to group EuiFormRow
s.
Should we do this?
Full-width
Form elements will automatically flex to a max-width of 400px
. You can optionally pass the fullWidth
prop to the row and form control to expand to their container. This should be done rarely and usually you will only need it for isolated controls like search bars and sliders.
Described form groups
Use EuiDescribedFormGroup
component to associate multiple EuiFormRow
s. It can also simply be used with one EuiFormRow
as a way to display help text (or additional text) next to the field instead of below (on mobile, will revert to being stacked).
Single text field
idAria="someID"
to the form group and passdescribedByIds={[someID]}
to its form row.No description
describedByIds
when there are multiple form rows.Full width
EuiDescribedFormGroup
will be double the default width of form elements. However, you can pass fullWidth
prop to this, the individual field and row components to expand to their container.Should we do this?
Inline
Inline forms can be made with FlexGroup
. Applygrow=false
on any of the items you want to collapse (like this button). Note that the button FormRow component also requires an additional prop because it’s missing a label.
Sizing inline form rows
Apply a width to the wrapping FlexItem to size individual controls. When you need to make a field smaller, always apply the width to the FlexItem, not the input. The input inside will resize as needed.
When supplying children to an EuiFormRow that is not a form control, and you need to the content to vertically center with the other form controls, change the display
prop to center
or centerCompressed
.
In a popover
Because forms auto-size to their wrapping elements, it means you can do fun things with them like stuff them in popovers and they’ll still work perfectly.