Form

A form allows people to input information.

Installation

Package installation information
Installyarn add @atlaskit/form
SourceBitbucket.org, (opens new window)
npm@atlaskit/form, (opens new window)
Bundleunpkg.com, (opens new window)

Props

Form props

autocomplete

Description

Indicates whether the value of the form's controls can be automatically completed by the browser. It is on by default.

Type"off" | "on"

children

Required
Description

The contents rendered inside of the form. This is a function where the props will be passed from the form. The function props you can access are dirty, submitting and disabled. You can read more about these props in react-final form documentation.

If you are only spreading formProps onto the HTML <form> element and not using any of the other props (like submitting, etc.), children can be plain JSX. All of the children will be wrapped within an HTML <form> element that includes all necessary props, including those provided on the form component.

Type(() => void) | React.ReactNode | ((args: FormChildrenArgs<FormValues>) => React.ReactNode)

formProps

Description

When Form renders JSX children directly and not using a function to spread formProps manually, the properties in this formProps prop will be spread on an internally rendered HTML form element.

Type{ [x: string]: any; } & ExcludeReservedFormProps

id

Description

id attribute applied to the form element.

Typestring

isDisabled

Description

Sets the form and its fields as disabled. Users cannot edit or focus on the fields.

Typeboolean

label

Description

Accessible name to be applied to the form element. Maps to the aria-label attribute.

Typestring

labelId

Description

ID of the element that has the accessible name to be applied to the form element. Maps to the aria-labelledby attribute.

Typestring

name

Description

name attribute applied to the form element.

Typestring

noValidate

Description

Indicates if the inputs within the form will bypass HTML5 constraint validation when submitted. This is not recommended to be used because it can cause experiences to be inaccessible. It is false by default but will be set to true in the future to increase accessibility, so it is not recommended.

Typeboolean

onSubmit

Required
Description

Event handler called when the form is submitted. Fields must be free of validation errors.

Type(values: FormValues, form: FormApi<FormValues>, callback?: (errors?: Record<string, string>) => void) => void | Object | Promise<...>

ref

Description

Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

@see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs}

Typestring | React.Ref<HTMLFormElement>

testId

Description

A test identifier for the form element. This will be applied as data-testid attribute.

Typestring

xcss

Description

Apply a subset of permitted styles powered by Atlassian Design System design tokens.

Typefalse | (XCSSValue<"flex" | "grid" | "fill" | "stroke" | "all" | "bottom" | "left" | "right" | "top" | "clip" | "overlay" | "accentColor" | "alignContent" | "alignItems" | "alignSelf" | ... 486 more ... | "glyphOrientationVertical", DesignTokenStyles, ""> & ... 4 more ... & { ...; })

Field props

aria-required

Description

The aria-required prop is disallowed. It is automatically applied when using isRequired via fieldProps.

Typenever

children

Description

Content to render in the field. This is a function that is called with props for the field component and other information about the field. This cannot be used at the same time as the component prop, as the children prop will be ignored.

Type(args: { fieldProps: FieldProps<FieldValue, Element>; error?: string; valid: boolean; meta: Meta; }) => React.ReactNode

component

Description

Content to render in the field. This will be rendered with the *Message props. This cannot be used at the same time as the children prop, as the children prop will be ignored.

Type(args: { fieldProps: FieldProps<FieldValue, Element>; }) => React.ReactNode

defaultValue

Description

Sets the default value of the field. If a function is provided, it is called with the current default value of the field.

TypeFieldValue | ((currentDefaultValue?: FieldValue) => FieldValue)

elementAfterLabel

Description

Element displayed after the label, and after the red asterisk if field is required.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

errorMessage

Description

Renders an ErrorMessage with the provided content when using the component prop.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

helperMessage

Description

Renders a HelperMessage with the provided content when using the component prop.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

id

Description

Passed to the ID attribute of the field. This is randomly generated if it is not specified.

Typestring

isDisabled

Description

Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.

Typeboolean

isRequired

Description

Sets whether the field is required for submission. Required fields are marked with a red asterisk.

Typeboolean

label

Description

Label displayed above the form field.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

name

Required
Description

Specifies the name of the field. This is important for referencing the form data.

Typestring

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests

Typestring

transform

Description

Access the current field value and transform it to return a different field value.

Type(event: FieldValue | React.FormEvent<Element>, current: FieldValue) => FieldValue

validate

Description

Checks whether the field input is valid. This is usually used to display a message relevant to the current value using ErrorMessage, HelperMessage or ValidMessage.

Type(value: FieldValue, formState: Object, fieldState: Meta) => string | void | Promise<string | void>

validMessage

Description

Renders a ValidMessage with the provided content when using the component prop.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

Character counter field props

aria-required

Description

The aria-required prop is disallowed. It is automatically applied when using isRequired via fieldProps.

Typenever

children

Required
Description

The input component to render. Use a render function that receives fieldProps, error, valid, and meta state. Spread fieldProps onto your input element (such as TextField or TextArea).

Type(args: { fieldProps: FieldProps<FieldValue, Element>; error?: string; valid: boolean; meta: Meta; }) => ReactNode

defaultValue

Description

Sets the default value of the field. If a function is provided, it is called with the current default value of the field.

TypeFieldValue | ((currentDefaultValue?: FieldValue) => FieldValue)

elementAfterLabel

Description

Element displayed after the label, and after the red asterisk if field is required.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

helperMessage

Description

Helper text displayed above the input to provide additional context or instructions.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

id

Description

Passed to the ID attribute of the field. This is randomly generated if it is not specified.

Typestring

isDisabled

Description

Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.

Typeboolean

isRequired

Description

Sets whether the field is required for submission. Required fields are marked with a red asterisk.

Typeboolean

label

Description

Label displayed above the form field.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

maxCharacters

Description

Maximum number of characters allowed. When exceeded, the field displays an error message or the message provided by overMaximumMessage.

Typenumber

minCharacters

Description

Minimum number of characters required. When not met, the character counter displays an error message or the message provided by underMinimumMessage.

Typenumber

name

Required
Description

Specifies the name of the field. This is important for referencing the form data.

Typestring

overMaximumMessage

Description

Custom message displayed when input exceeds the maximum character limit. Use this to provide context-specific guidance or localized messages. Overrides the default "X characters too many" message.

Typestring

testId

Description

A testId prop is provided for specified elements, which is a unique string that appears as a data attribute data-testid in the rendered code, serving as a hook for automated tests

Typestring

underMaximumMessage

Description

Custom message displayed when input is under the maximum limit. Use this to provide context-specific guidance or localized messages. Overrides the default "X characters remaining" message.

Typestring

underMinimumMessage

Description

Custom message displayed when input is under the minimum requirement. Use this to guide users on how much more they need to type. Overrides the default "Minimum of X characters required" message.

Typestring

validate

Description

Checks whether the field input is valid. This is usually used to display a message relevant to the current value using ErrorMessage, HelperMessage or ValidMessage.

Type(value: FieldValue, formState: Object, fieldState: Meta) => string | void | Promise<string | void>

Checkbox field props

children

Required
Description

Content to render in the checkbox field. This is a function that is called with information about the field.

Type(args: { fieldProps: CheckboxFieldProps; error?: string; valid: boolean; meta: Meta; }) => React.ReactNode

defaultIsChecked

Description

Sets the default state of the checkbox as checked.

Defaultfalse
Typeboolean

isDisabled

Description

Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.

Typeboolean

isRequired

Description

Sets whether the field is required for submission. Required fields are marked with a red asterisk.

Typeboolean

label

Description

Label displayed beside the checkbox.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

name

Required
Description

Specifies the name of the field. This is important for referencing the form data.

Typestring

value

Description

The value of the checkbox. This is the value used in the form state when the checkbox is checked.

Typestring

Fieldset props

children

Required
Description

Content to render in the fieldset.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

legend

Description

Label describing the contents of the fieldset.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

Range field props

children

Required
Description

Content to render in the range field. This function is called with props for the field component and other information about the field.

Type(args: { fieldProps: RangeProps; error?: string; meta: Meta; }) => React.ReactNode

defaultValue

Required
Description

Sets the default value of the field. If a function is provided, it is called with the current default value of the field.

Typenumber | ((currentDefaultValue?: number) => number)

id

Description

Value passed to the id attribute of the field. This is randomly generated if it is not specified.

Typestring

isDisabled

Description

Sets whether the field is disabled. Users cannot edit or focus on the fields. If the parent form component is disabled, then the field will always be disabled.

Typeboolean

label

Description

Displays a label above the range field and identifies the form fields.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal

name

Required
Description

Specifies the name of the field. This is important for referencing the form data.

Typestring

Form header props

children

Description

Child content to render in the form below the title and description.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

description

Description

Description or subtitle of the form.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

title

Description

Title of the form. This is a header.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

align

Description

Sets the alignment of the footer contents. This is often a button. This should be left-aligned in single-page forms, flags, cards, and section messages.

Default"end"
Type"end" | "start"

children

Description

Content to render in the footer of the form.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

Form section props

children

Description

Content or components to render after the description.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

description

Description

Description of the contents of the section.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal

title

Description

Title of the form section.

Typestring | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal
Was this page helpful?
We use this feedback to improve our documentation.
© 2026 AtlassianTrademark, (opens new window)Privacy, (opens new window)License