FormLabel
Renders a label associated with a form field, even if the field is not a native input.
If the field is a native input, select or textarea element, this component
will render a native label element and rely on its htmlFor prop.
Otherwise, it'll render a span element and rely on the aria-labelledby
attribute on the form field instead. Clicking on the label will move focus to
the field even if it's not a native input.
Code examples
email: "",
},
});
Required Props
name
StringLike
Name of the field labeled by this element. This can either be a string or a
reference to a field name from the
names object in the
store, for type safety.
Code examples
Optional Props
getItem
((props: CollectionStoreItem) => CollectionStoreItem) | undefined
A memoized function that returns props to be passed with the item during its registration in the store.
Code examples
const getItem = useCallback((data) => ({ ...data, custom: true }), []);
id
string | undefined
The unique ID of the item. This will be used to register the item in the
store and for the element's id attribute. If not provided, a unique ID
will be automatically generated.
Live examples


render
RenderProp<React.HTMLAttributes<any> & { ref?: React.Ref<any> | undefined; }> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | undefined
Allows the component to be rendered as a different HTML element or React component. The value can be a React element or a function that takes in the original component props and gives back a React element with the props merged.
Some Ariakit components detect the type of the underlying element when
they mount. If the render element's type may change while the component
is mounted, pass a
key
key={custom ? "custom" : "native"}
/>
Check out the Composition guide for more details.
shouldRegisterItem
boolean | undefined = true
Whether the item should be registered as part of the collection.
store
FormStore<FormStoreValues> | undefined
Object returned by the
useFormStore hook. If not
provided, the closest Form or
FormProvider components'
context will be used.