Fieldset
A native fieldset element with an easily stylable legend.
<?phem
use Phem\Attribute\Component;
use Phem\Node;
use Phem\Ui\{Field, Fieldset};
use function Phem\Ui\{FieldControl, FieldLabel, FieldsetLegend};
#[Component]
function FieldsetHeroDemo(): Node
{
return (
<Fieldset>
<FieldsetLegend>Billing details</FieldsetLegend>
<Field id="company">
<FieldLabel>Company</FieldLabel>
<FieldControl placeholder="Enter company name" />
</Field>
<Field id="tax-id">
<FieldLabel>Tax ID</FieldLabel>
<FieldControl placeholder="Enter fiscal number" />
</Field>
</Fieldset>
);
}
API reference#
Import the components of the family:
use function Phem\Ui\{Fieldset, FieldsetLegend};Fieldset#
A group of fields with a legend: Base UI Fieldset.Root. --fieldset-gap is the space between the fields and after the legend: a <legend> is not a flex item, so it gets the space as a margin. Change the space with the variable, for example className="[--fieldset-gap:0.5rem]".
| Prop | Type | Default |
|---|---|---|
disabled | bool | false |
children | ?Html | null |
...rest | mixed | — |
FieldsetLegend#
The legend of a fieldset: Base UI Fieldset.Legend. It is a <legend>, so the browser names the group with it.
| Prop | Type | Default |
|---|---|---|
children | ?Html | null |
...rest | mixed | — |
The source of the examples: examples/ui/Fieldset.phem.