Fieldset | jaspr_daisyui_components
jaspr_daisyui_components
pub.dev ↗

Fieldset

Fieldset is a container for grouping related form elements. It includes fieldset-legend as a title and label as a description.

Class name Type Description
fieldset Component for the fieldset container
label Component label for inputs
fieldset-legend Part for the title of the fieldset

Fieldset fieldset-legend and label

Page title

You can edit page title later on from settings

<fieldset class="fieldset">
  <legend class="fieldset-legend">Page title</legend>
  <input type="text" class="input" placeholder="My awesome page" />
  <p class="label">You can edit page title later on from settings</p>
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Page title')]),
    Input(const [], placeholder: 'My awesome page'),
    Label([Component.text('You can edit page title later on from settings')]),
  ],
);

Fieldset with background and border

Page title

You can edit page title later on from settings

<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
  <legend class="fieldset-legend">Page title</legend>
  <input type="text" class="input" placeholder="My awesome page" />
  <p class="label">You can edit page title later on from settings</p>
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Page title')]),
    Input(const [], placeholder: 'My awesome page'),
    Label([Component.text('You can edit page title later on from settings')]),
  ],
  classes: 'bg-base-200 border-base-300 rounded-box w-xs border p-4',
);

Fieldset with multiple inputs

Add proper id and for attributes for accessibility. The id must be unique and depends on your context.
Page details
<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
  <legend class="fieldset-legend">Page details</legend>
  <label class="label">Title</label>
  <input type="text" class="input" placeholder="My awesome page" />
  <label class="label">Slug</label>
  <input type="text" class="input" placeholder="my-awesome-page" />
  <label class="label">Author</label>
  <input type="text" class="input" placeholder="Name" />
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Page details')]),
    label([Component.text('Title')], classes: 'label'),
    Input(const [], placeholder: 'My awesome page'),
    label([Component.text('Slug')], classes: 'label'),
    Input(const [], placeholder: 'my-awesome-page'),
    label([Component.text('Author')], classes: 'label'),
    Input(const [], placeholder: 'Name'),
  ],
  classes: 'bg-base-200 border-base-300 rounded-box w-xs border p-4',
);

Fieldset with multiple join items

Settings
<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
  <legend class="fieldset-legend">Settings</legend>
  <div class="join">
    <input type="text" class="input join-item" placeholder="Product name" />
    <button class="btn join-item">save</button>
  </div>
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Settings')]),
    Join(
      [
        Input(const [], classes: 'join-item', placeholder: 'Product name'),
        JoinItem([Component.text('save')], classes: 'btn'),
      ],
    ),
  ],
  classes: 'bg-base-200 border-base-300 rounded-box w-xs border p-4',
);

Login form with fieldset

Add proper id and for attributes for accessibility. The id must be unique and depends on your context.
Login
<fieldset class="fieldset bg-base-200 border-base-300 rounded-box w-xs border p-4">
  <legend class="fieldset-legend">Login</legend>
  <label class="label">Email</label>
  <input type="email" class="input" placeholder="Email" />
  <label class="label">Password</label>
  <input type="password" class="input" placeholder="Password" />
  <button class="btn btn-neutral mt-4">Login</button>
</fieldset>
Fieldset(
  [
    FieldsetLegend([Component.text('Login')]),
    label([Component.text('Email')], classes: 'label'),
    Input(const [], placeholder: 'Email', type: 'email'),
    label([Component.text('Password')], classes: 'label'),
    Input(const [], placeholder: 'Password', type: 'password'),
    Btn([Component.text('Login')], classes: 'mt-4', color: BtnColor.neutral),
  ],
  classes: 'bg-base-200 border-base-300 rounded-box w-xs border p-4',
);