Return to Sky UI homepage

Control Field - React

import { ControlField } from '@sky-uk/ui-core';

The ControlField component builds up a semantic grouping of inputs and adds information like labels and validation messages.

Sub Components

  • ControlField.Legend – label of the input group
  • ControlField.Layout – grouping element for multiple Layout
  • ControlField.Option – input element with its label
  • ControlField.Validation – error message of the input group
  • ControlField.Message – inline message of the group

Using ControlField.Layout with Radio Card.

Props

as

Either a RadioInput, CheckboxInput or RadioCard component needs to be passed to the as prop on each of the ControlField.Option child components.

Checkbox

Radio

inlineMessage

ControlField.Option can have an inline message, which could be set by inlineMessage prop.

Add $legal property to ControlField.Option to set legal variant of the Checkbox. Legal variant of the label doesn't have an inline message.

state

Setting the state prop to state="error" on the ControlField component will cause error styling to be applied.

You can add an error message in addition to the inline message of the input group.

It is best practice to validate input fields only upon form submission.

System Modifiers

ControlField.Option supports the following system functions: