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 | undefined
Provides extra information about the field.
labelstring
Describes the purpose of the field.
messagestring | undefined
Message to show when the field is invalid.
hideOptionalLabel?boolean
If `true`, "(optional)" will never be appended to the label even when `required` is `false` or `undefined`.
id?string
Defines an identifier (ID) of the field, which must be unique.
invalid?boolean
If true, the invalid state will be rendered.
labelId?string
Defines an identifier (ID) of the label element, which must be unique.
maxWidth?"md" | "lg" | "xl" | "xs" | "sm"
The maximum width of the field.
required?boolean
If `false` or `undefined`, "(optional)" will be appended to the label.
secondaryLabel?string
Text to prepend to the default secondary label.
FieldContainer Props
PropTypeDescription
children?ReactNode
id?string
Defines an identifier (ID) which must be unique.
invalid?boolean
If true, the invalid state will be rendered.
FieldHint Props
PropTypeDescription
idstring
Defines an identifier (ID) which must be unique.
children?ReactNode
FieldLabel Props
PropTypeDescription
as?ElementType<any>Default: "label"
children?ReactNode
hideOptionalLabel?boolean
If `true`, "(optional)" will never be appended to the label even when `required` is `false`.
htmlFor?string
The ID of the form element this label relates to.
id?string
Defines an identifier (ID) which must be unique.
required?boolean
If `false` or `undefined`, "(optional)" will be appended to the label.
secondaryLabel?string
Text to prepend to the default secondary label.
FieldMessage Props
PropTypeDescription
idstring
Defines an identifier (ID) which must be unique.
children?ReactNode

Source

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