InstallComponentsExample

Form elements

Inputs, selects, textareas, checkboxes, radios, ranges and fieldsets. Wrap a field in its <label>.

How it helpsA label wrapping its field gives you accessible names and layout together. Errors use aria-invalid, which is the attribute assistive tech reads anyway.

Full form

Notifications
"use client";

import { toast } from "sidedish";

export default function Example() {
  return (
    <>
      <form className="flex flex-col gap-3" style={{ maxWidth: "440px" }} onSubmit={(event) => { event.preventDefault(); toast('Submitted',{tone:'good'}); }}>
        <label>Email <input type="email" placeholder="you@example.com" required /></label>
        <label>Password <input type="password" aria-invalid="true" defaultValue="123" /><span className="error">At least 8 characters.</span></label>
        <label>Account type
          <select><option>Savings</option><option>Current</option><option>Credit card</option></select>
        </label>
        <label>Notes <textarea placeholder="Anything we should know?" /><span className="hint">Optional</span></label>
        <fieldset>
          <legend>Notifications</legend>
          <label><input type="checkbox" defaultChecked /> Email me statements</label>
          <label><input type="radio" name="freq" defaultChecked /> Weekly</label>
          <label><input type="radio" name="freq" /> Monthly</label>
        </fieldset>
        <label>Risk appetite <input type="range" min="0" max="10" defaultValue="6" /></label>
        <button>Create account</button>
      </form>
    </>
  );
}
<form class="flex flex-col gap-3" style="max-width:440px" onsubmit="event.preventDefault();Sidedish.toast('Submitted',{tone:'good'})">
  <label>Email <input type="email" placeholder="you@example.com" required></label>
  <label>Password <input type="password" aria-invalid="true" value="123"><span class="error">At least 8 characters.</span></label>
  <label>Account type
    <select><option>Savings</option><option>Current</option><option>Credit card</option></select>
  </label>
  <label>Notes <textarea placeholder="Anything we should know?"></textarea><span class="hint">Optional</span></label>
  <fieldset>
    <legend>Notifications</legend>
    <label><input type="checkbox" checked> Email me statements</label>
    <label><input type="radio" name="freq" checked> Weekly</label>
    <label><input type="radio" name="freq"> Monthly</label>
  </fieldset>
  <label>Risk appetite <input type="range" min="0" max="10" value="6"></label>
  <button>Create account</button>
</form>

API

NameTypeDescription
label > inputmarkupLabel wraps its field, stacked.
label > [type=checkbox|radio]markupInline row.
.hint / .errorclassHelper and error text.
aria-invalid="true"attrRed border.
fieldset, legendtagGrouped controls.