Accessible grouped fields
Applying Conform metadata to a native address or profile fieldset.
Conform · Function
getFieldsetProps derives the properties needed to make a native fieldset accessible from Conform field metadata. Options customize generated ARIA behavior.
Call getFieldsetProps with field metadata and optional settings, then spread the returned properties onto a native HTML fieldset. The helper derives the related accessibility attributes; custom components require equivalent helpers or explicit metadata handling.
getFieldsetProps(meta, options)| Name | Type | Description |
|---|---|---|
meta | FieldMetadata | Field metadata used to derive the fieldset properties. |
options | GetFieldsetPropsOptions | Options controlling generated accessibility attributes, including ariaAttributes, ariaInvalid, and ariaDescribedBy. |
The properties required for an accessible native fieldset element.
import { useForm, getFieldsetProps } from "@conform-to/react";
export function AddressFieldset() {
const [, fields] = useForm();
return (
<fieldset {...getFieldsetProps(fields.address)}>
<legend>Address</legend>
</fieldset>
);
}This applies the accessibility-related properties derived from the address field metadata to a native fieldset.
Applying Conform metadata to a native address or profile fieldset.
Adding a description identifier to generated aria-describedby.
Choosing whether invalid-state attributes use immediate or aggregated errors.
getFieldsetProps returns the properties needed to make a fieldset accessible. It is called with field metadata and can be spread onto a native fieldset element.
Follow-up: What should you do for a custom fieldset component? The documentation recommends making a custom helper rather than assuming the native-element helper fits it.
The normal usage is getFieldsetProps(fields.address), followed by spreading the result onto fieldset. This derives related attributes from the field metadata and reduces repetitive wiring.
Follow-up: Can it be omitted? Yes; the metadata can be used directly when explicitly setting the fieldset properties.
The helper supports options for accessibility behavior, including whether to include aria-describedby and whether invalid-state attributes use errors or allErrors. aria-describedby can also receive an additional identifier such as meta.descriptionId.
Follow-up: What is the default for ariaAttributes? It is true, so the accessibility attributes are included unless disabled.
getFormPropsgetInputPropsuseFormFieldMetadata