API: components
Fieldset
A native fieldset that groups related fields under a legend and disables them together, nested fieldsets included, in each framework.
Groups related fields under a shared legend, and disables them together: a
native <fieldset>, a group named by its Legend. A Fieldset inside a disabled Fieldset is
disabled too. The APG has no fieldset pattern; it follows Base UI's Fieldset (the
behaviour rule).
Behaviour
- Name: the Root's
aria-labelledbypoints at the Legend'sid, while a Legend is rendered. The Legend is adiv, not a native<legend>: a<legend>sits on the fieldset's border and resists styling. - Disabled:
disableddisables the native fieldset, so every native control inside it, and every Field inside it: their parts and controls carrydata-disabled, show no error and submit nothing. A nested Fieldset inherits it.
Anatomy
| part | element | data-primitives-part | role |
|---|---|---|---|
| Root | fieldset | fieldset-root | the group, named by its Legend |
| Legend | div | fieldset-legend | names the Root |
Usage
import { Field } from "@fragiola/primitives-react/field";
import { Fieldset } from "@fragiola/primitives-react/fieldset";
<form>
<Fieldset.Root>
<Fieldset.Legend>Shipping address</Fieldset.Legend>
<Field.Root name="street">
<Field.Label>Street</Field.Label>
<Field.Control />
</Field.Root>
</Fieldset.Root>
<Fieldset.Root disabled={sameAsShipping}>
<Fieldset.Legend>Billing address</Fieldset.Legend>
<Field.Root name="billing-street">
<Field.Label>Billing street</Field.Label>
<Field.Control />
</Field.Root>
</Fieldset.Root>
</form>;Props
Every part also takes what the primitive contract gives:
render (Vue: as and the render slot), a class and a style, a ref, and any attribute, which
it forwards. Vue binds them the same way (:disabled), and Angular as inputs ([disabled]).
Root
| prop | type | default | description |
|---|---|---|---|
disabled | boolean | false | disables the fieldset and every field inside it, nested fieldsets included |
Legend
| prop | type | default | description |
|---|---|---|---|
id | string | generated | the id the Root's aria-labelledby points at |
State and part attributes
| part | attributes |
|---|---|
| Root | aria-labelledby (the Legend's id), disabled and data-disabled while disabled |
| Legend | id, data-disabled while the Root is disabled |
A Field inside a disabled Fieldset carries data-disabled on its parts and its control.
Keyboard
Nothing of its own: a disabled fieldset's controls are not focusable.
Exports
| entry | exports |
|---|---|
@fragiola/primitives-react/fieldset | Fieldset, FieldsetLegendProps, FieldsetRootProps, FieldsetState, RenderProp |
@fragiola/primitives-vue/fieldset | Fieldset, FieldsetLegendProps, FieldsetRootProps, FieldsetState, RenderSlotProps |
@fragiola/primitives-angular/fieldset | FieldsetLegend, FieldsetRoot, FieldsetState |