Components

Form group

Internal

A group of form fields.

Birthday
Enter your date of birth

Content

Rendering...
Rendering...
Props
NameTypeDefaultDescription
idstring-'id' attribute to place on the base HTML element
classBlockstring-Block name override in BEM style classes applied to all elements
classModifiersModifiers[]BEM style modifiers to apply to the base HTML element
classNamestring-Extra classes to apply to the base HTML element
errorReactNode-
errorIdstring-
fieldIdstring-
hintReactNode-
hintIdstring-
labelReactNode-REQUIRED.
labelCaptionReactNode-Caption for the section the question belongs to, shown above the label
labelClassModifiersModifiers-BEM style modifiers to apply to the label (or legend)
labelHeadingElementType-Component to wrap the label (or legend) in, making it a heading
standaloneboolean-

Stories

Standard

A standard Form group.

Birthday
Enter your date of birth

Content

Rendering...
Rendering...

Label

A Form group with just a label instead of a fieldset and legend.

Enter your name

Content

Rendering...
Rendering...

Error

A Form group with a validation error.

Birthday
Enter your date of birth

Error: Enter a date in the past

Content

Rendering...
Rendering...

Label modifiers

A Form group with a medium-sized label. labelClassModifiers applies BEM modifiers to the label, or to the legend where there is a fieldset.

Birthday
Enter your date of birth

Content

Rendering...
Rendering...

Heading

A Form group whose label is a heading, set with labelHeading. With a fieldset the heading goes inside the <legend>; with a label it goes around the <label>, which is the only place it can validly go.

It takes any component, so a question that is the page heading asks for "h1" and one that is a sub-heading on a page of several asks for "h2". The label or legend is sized to match the level, following the hierarchy GOV.UK uses on a page that is not long form content, unless labelClassModifiers says otherwise.

Birthday

Enter your date of birth

Content

Rendering...
Rendering...

Caption

A Form group whose question belongs to a wider section, named with labelCaption. It sits above the label or legend, and outside both, which is where GOV.UK puts it on a question page: a caption within a legend would be read out again for every field in the fieldset.

It is sized to match the label, so it needs no size of its own.

About you

Birthday

Enter your date of birth

Content

Rendering...
Rendering...