Form
A form allows people to input information.Installation
| Install | yarn add @atlaskit/form |
|---|---|
| Source | Bitbucket.org, (opens new window) |
| npm | @atlaskit/form, (opens new window) |
| Bundle | unpkg.com, (opens new window) |
Props
Form props
| Description | Indicates whether the value of the form's controls can be automatically completed by the browser. It is |
|---|---|
| Type | "off" | "on" |
| 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 If you are only spreading |
|---|---|
| Type | (() => void) | React.ReactNode | ((args: FormChildrenArgs<FormValues>) => React.ReactNode) |
| Description | When |
|---|---|
| Type | { [x: string]: any; } & ExcludeReservedFormProps |
| Description |
|
|---|---|
| Type | string |
| Description | Sets the form and its fields as disabled. Users cannot edit or focus on the fields. |
|---|---|
| Type | boolean |
| Description | Accessible name to be applied to the form element. Maps to the |
|---|---|
| Type | string |
| Description | ID of the element that has the accessible name to be applied to the form element. Maps to the |
|---|---|
| Type | string |
| Description |
|
|---|---|
| Type | string |
| 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 |
|---|---|
| Type | boolean |
| 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<...> |
| Description | Allows getting a ref to the component instance.
Once the component unmounts, React will set @see {@link https://react.dev/learn/referencing-values-with-refs#refs-and-the-dom React Docs} |
|---|---|
| Type | string | React.Ref<HTMLFormElement> |
| Description | A test identifier for the form element. This will be applied as |
|---|---|
| Type | string |
| Description | Apply a subset of permitted styles powered by Atlassian Design System design tokens. |
|---|---|
| Type | false | (XCSSValue<"flex" | "grid" | "fill" | "stroke" | "all" | "bottom" | "left" | "right" | "top" | "clip" | "overlay" | "accentColor" | "alignContent" | "alignItems" | "alignSelf" | ... 486 more ... | "glyphOrientationVertical", DesignTokenStyles, ""> & ... 4 more ... & { ...; }) |
Field props
| Description | The |
|---|---|
| Type | never |
| 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 |
|---|---|
| Type | (args: { fieldProps: FieldProps<FieldValue, Element>; error?: string; valid: boolean; meta: Meta; }) => React.ReactNode |
| Description | Content to render in the field. This will be rendered with the |
|---|---|
| Type | (args: { fieldProps: FieldProps<FieldValue, Element>; }) => React.ReactNode |
| Description | Sets the default value of the field. If a function is provided, it is called with the current default value of the field. |
|---|---|
| Type | FieldValue | ((currentDefaultValue?: FieldValue) => FieldValue) |
| Description | Element displayed after the label, and after the red asterisk if field is required. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Renders an |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Renders a |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Passed to the ID attribute of the field. This is randomly generated if it is not specified. |
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | boolean |
| Description | Sets whether the field is required for submission. Required fields are marked with a red asterisk. |
|---|---|
| Type | boolean |
| Description | Label displayed above the form field. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Specifies the name of the field. This is important for referencing the form data. |
|---|---|
| Type | string |
| Description | A |
|---|---|
| Type | string |
| Description | Access the current field value and transform it to return a different field value. |
|---|---|
| Type | (event: FieldValue | React.FormEvent<Element>, current: FieldValue) => FieldValue |
| Description | Checks whether the field input is valid. This is usually used to display a message relevant to the current value using |
|---|---|
| Type | (value: FieldValue, formState: Object, fieldState: Meta) => string | void | Promise<string | void> |
| Description | Renders a |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Character counter field props
| Description | The |
|---|---|
| Type | never |
| Description | The input component to render. Use a render function that receives |
|---|---|
| Type | (args: { fieldProps: FieldProps<FieldValue, Element>; error?: string; valid: boolean; meta: Meta; }) => ReactNode |
| Description | Sets the default value of the field. If a function is provided, it is called with the current default value of the field. |
|---|---|
| Type | FieldValue | ((currentDefaultValue?: FieldValue) => FieldValue) |
| Description | Element displayed after the label, and after the red asterisk if field is required. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Helper text displayed above the input to provide additional context or instructions. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Passed to the ID attribute of the field. This is randomly generated if it is not specified. |
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | boolean |
| Description | Sets whether the field is required for submission. Required fields are marked with a red asterisk. |
|---|---|
| Type | boolean |
| Description | Label displayed above the form field. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Maximum number of characters allowed. When exceeded, the field displays an error message or the message provided by |
|---|---|
| Type | number |
| Description | Minimum number of characters required. When not met, the character counter displays an error message or the message provided by |
|---|---|
| Type | number |
| Description | Specifies the name of the field. This is important for referencing the form data. |
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | string |
| Description | A |
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | string |
| Description | Checks whether the field input is valid. This is usually used to display a message relevant to the current value using |
|---|---|
| Type | (value: FieldValue, formState: Object, fieldState: Meta) => string | void | Promise<string | void> |
Checkbox field props
| 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 |
| Description | Sets the default state of the checkbox as checked. |
|---|---|
| Default | false |
| Type | boolean |
| 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. |
|---|---|
| Type | boolean |
| Description | Sets whether the field is required for submission. Required fields are marked with a red asterisk. |
|---|---|
| Type | boolean |
| Description | Label displayed beside the checkbox. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Specifies the name of the field. This is important for referencing the form data. |
|---|---|
| Type | string |
| Description | The value of the checkbox. This is the value used in the form state when the checkbox is checked. |
|---|---|
| Type | string |
Fieldset props
| Description | Content to render in the fieldset. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Label describing the contents of the fieldset. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
Range field props
| 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 |
| Description | Sets the default value of the field. If a function is provided, it is called with the current default value of the field. |
|---|---|
| Type | number | ((currentDefaultValue?: number) => number) |
| Description | Value passed to the |
|---|---|
| Type | string |
| 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. |
|---|---|
| Type | boolean |
| Description | Displays a label above the range field and identifies the form fields. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
| Description | Specifies the name of the field. This is important for referencing the form data. |
|---|---|
| Type | string |
Form header props
| Description | Child content to render in the form below the title and description. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Description or subtitle of the form. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Title of the form. This is a header. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
Form section props
| Description | Content or components to render after the description. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Description of the contents of the section. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |
| Description | Title of the form section. |
|---|---|
| Type | string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.ReactPortal |