Components

Label

Internal

A label for a form field.

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
headingElementType-Component to wrap the label in, making it a heading

Stories

Standard

A standard Label.

Rendering...
Rendering...

In-line

Rendering...
Rendering...

Heading

Where the question is a heading, give heading the component to wrap the label in. The heading goes around the label rather than inside it, which would not be valid HTML.

The label is sized to match the level, following the hierarchy GOV.UK uses on a page that is not long form content: large for an <h1>, medium for an <h2>, small below that. Say so with classModifiers to size it otherwise, and do say so if you pass a component we cannot read a level from.

Rendering...
Rendering...