M Majid DS mds
GitHub

Flux components

Field

Wire a label, description and validation error to an input.

Most inputs take label and description props directly. Reach for flux:field when you need to compose the parts yourself.

Mobile number A verification code will be sent to this number.
<flux:field>
    <flux:label>Mobile number</flux:label>
    <flux:description>A verification code will be sent to this number.</flux:description>

    <flux:input type="tel" placeholder="0912 345 6789" />

    <flux:error name="phone" />
</flux:field>

Inline

variant="inline" puts the label beside the control — the usual shape for a switch or a single checkbox.

Free shipping In stock only
<div class="space-y-3">
    <flux:field variant="inline">
        <flux:label>Free shipping</flux:label>
        <flux:switch checked />
    </flux:field>

    <flux:field variant="inline">
        <flux:label>In stock only</flux:label>
        <flux:switch />
    </flux:field>
</div>

Required and badges

A label can carry a badge, or aside content on the trailing edge.

Full name
<flux:field>
    <flux:label badge="Required">Full name</flux:label>
    <flux:input />
</flux:field>

Fieldset

Group several fields under one legend.

Shipping address
Street
City
<flux:fieldset>
    <flux:legend>Shipping address</flux:legend>

    <div class="space-y-4">
        <flux:input label="Street" />
        <flux:input label="City" value="Tehran" />
    </div>
</flux:fieldset>

Reference

flux:field

PropDescription
variantOptions: block, inline. Default: block.

flux:label

PropDescription
badgeBadge text after the label, e.g. Required.
asideContent pinned to the trailing edge of the label row.
trailingContent directly after the label text.
sr-onlyHides the label visually but keeps it for screen readers.

flux:description

PropDescription
sr-onlyHides the description visually but keeps it for screen readers.

flux:error

PropDescription
nameThe validation key to show errors for.
messageAn explicit message instead of one from the error bag.
bagError bag name. Default: default.
iconIcon name. Default: exclamation-triangle.

flux:fieldset

PropDescription
legendShorthand for flux:legend.
descriptionDescription under the legend.

flux:legend

The fieldset caption. Takes no props.

Related