You are viewing a PR preview for PR #1506

Agriculture Design System
Beta
Design System for the Export Service

Field

The field package exposes the elements around form inputs, and an API to compose them.

View in StorybookView in Github
import { ... } from '@ag.ds-next/react/field';

Usage

Field components can be imported via the field entrypoint in the @ag.ds-next/react package.

For example:

import { ... } from '@ag.ds-next/react/field';

Props

Field Props
PropTypeDescription
childrenReactNode | ((a11yProps: A11yProps) => ReactNode)
hintstring | undefinedProvides extra information about the field.
labelstringDescribes the purpose of the field.
messagestring | undefinedMessage to show when the field is invalid.
requiredbooleanIf false, "(optional)" will be appended to the label.
hideOptionalLabel?booleanIf true, "(optional)" will never be appended to the label even when `required` is `false`.
id?stringDefines an identifier (ID) of the field, which must be unique.
invalid?booleanIf true, the invalid state will be rendered.
labelId?stringDefines an identifier (ID) of the label element, which must be unique.
secondaryLabel?stringText to prepend to the default secondary label.
FieldContainer Props
PropTypeDescription
children?ReactNode
id?stringDefines an identifier (ID) which must be unique.
invalid?booleanIf true, the invalid state will be rendered.
FieldHint Props
PropTypeDescription
idstringDefines an identifier (ID) which must be unique.
children?ReactNode
FieldLabel Props
PropTypeDescription
requiredbooleanIf false, "(optional)" will be appended to the label.
as?ElementType<any>Default: "label"
children?ReactNode
hideOptionalLabel?booleanIf true, "(optional)" will never be appended to the label even when `required` is `false`.
htmlFor?stringThe ID of the form element this label relates to.
id?stringDefines an identifier (ID) which must be unique.
secondaryLabel?stringText to prepend to the default secondary label.
FieldMessage Props
PropTypeDescription
idstringDefines an identifier (ID) which must be unique.
children?ReactNode

Source

You can view the full source code for this package on Github.