Skip to main content
Components

Fieldset

Use the fieldset component to group related form inputs.

Read the Design System guidance for fieldset

Import

import * as Fieldset from 'govuk-react/fieldset';

Examples

Default

Code
<Fieldset.Composite legend="What is your address?">
  {(
    <>
      <InputField id="address-line-1" name="address-line-1" label="Address line 1" autoComplete="address-line1" />
      <InputField
        id="address-line-2"
        name="address-line-2"
        label="Address line 2 (optional)"
        autoComplete="address-line2"
      />
      <InputField id="address-town" name="address-town" label="Town or city" width="two-thirds" />
      <InputField id="address-postcode" name="address-postcode" label="Postcode" width={10} />
    </>
  )}
</Fieldset.Composite>

Legend as page heading

Code
<Fieldset.Composite
  legend="What is your address?"
  legendSize="l"
  legendIsPageHeading
>
  {(
    <>
      <InputField id="address-line-1" name="address-line-1" label="Address line 1" autoComplete="address-line1" />
      <InputField
        id="address-line-2"
        name="address-line-2"
        label="Address line 2 (optional)"
        autoComplete="address-line2"
      />
      <InputField id="address-town" name="address-town" label="Town or city" width="two-thirds" />
      <InputField id="address-postcode" name="address-postcode" label="Postcode" width={10} />
    </>
  )}
</Fieldset.Composite>

API reference

Fieldset.Root

Use the fieldset component to group related form inputs.

No props of its own. Other props are passed to the element it renders.

Fieldset.Composite

Use the fieldset component to group related form inputs.

PropType
legend

The legend for the fieldset component.

ReactNode
legendSize"s" | "m" | "l" | "xl"
legendIsPageHeading

Whether the legend also acts as the heading for the page.

boolean

Fieldset.Heading

No props of its own. Other props are passed to the element it renders.

Fieldset.Legend

PropType
size"s" | "m" | "l" | "xl"

Fieldset.LegendComposite

PropType
size"s" | "m" | "l" | "xl"
isPageHeading

Whether the legend also acts as the heading for the page.

boolean