Fieldset
A group of related fields under a legend and a description, disabled together.
Previews are drawn in the theme you made.
Edit itEnabled and disabled #
import { Fieldset, FieldsetSlots, Input, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'
import { stack } from '../../snippets/layout.js'
const Control = Recipes.Input.style({})
// `view` draws the native fieldset: a legend that names the group, an optional
// description, and the content you drew. `disabled` turns off every control inside.
export default example({
title: 'Enabled and disabled',
slots: FieldsetSlots,
recipe: Recipes.Fieldset,
pins: { variant: 'bordered' },
view: ({ style, h }) =>
stack(
h,
[false, true].map(disabled => {
const id = disabled ? 'billing' : 'shipping'
return Fieldset.view(
{
id,
legend: disabled ? 'Billing address (locked)' : 'Shipping address',
description: 'Where the order is sent. We never share it.',
disabled,
content: [Input.view({ id: `${id}-street`, label: 'Street', style: Control }, h)],
style,
},
h,
)
}),
),
})In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.
Usage
Each example above is a module of its own, shown whole and run as shown, over the theme module Create a theme writes. The page hands it the style picked above.
Keyboard and accessibility
- A
fieldsetwith itslegend: assistive technology reads the legend as the name of the group the fields are in. - A disabled fieldset has its legend and description dimmed by the recipe.