UNPKG

@atlaskit/form

Version:

A form allows people to input information.

52 lines (51 loc) 1.97 kB
import React, { type ReactNode } from 'react'; import { type FieldProps, type Meta } from './field'; export interface CheckboxFieldProps extends FieldProps<string | undefined> { isChecked: boolean; } interface CheckboxProps { /** * Content to render in the checkbox field. This is a function that is called with information about the field. */ children: (args: { fieldProps: CheckboxFieldProps; error?: string; valid: boolean; meta: Meta; }) => ReactNode; /** * Sets the default state of the checkbox as checked. */ defaultIsChecked?: boolean; /** * Sets whether the field is required for submission. Required fields are marked with a red asterisk. */ isRequired?: boolean; /** * 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. */ isDisabled?: boolean; /** * Label displayed beside the checkbox. */ label?: ReactNode; /** * Specifies the name of the field. This is important for referencing the form data. */ name: string; /** * The value of the checkbox. This is the value used in the form state when the checkbox is checked. */ value?: string; } /** * __Checkbox field__ * * A checkbox field is a form field that lets users select an item. Users can check or uncheck the checkbox. * * - [Examples] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference * - [Code] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference * - [Usage] https://atlaskit.atlassian.com/packages/design-system/form/docs/fields#checkboxfield-reference */ declare const CheckboxField: ({ children, defaultIsChecked, isDisabled, isRequired, label, name, value, }: CheckboxProps) => React.JSX.Element; export default CheckboxField;