Contents

Components

Input and Field

A single-line text field, its label, and the Field that ties label, help and error to the control.

Direct video files and YouTube links work best.

Props
import { Field } from "@sideby/ui/field";
import { Input } from "@sideby/ui/input";

<Field label="Video link" description="Direct video files and YouTube links work best.">
  {#snippet control(attrs)}
    <Input {...attrs} type="url" name="link" />
  {/snippet}
</Field>

When to use it

Use an Input for one line of text: a link to watch, a display name, a room code. Wrap it in a Field almost every time. Field renders the label, an optional description and an error slot, and wires all three to the control, so you never hand-write for, aria-describedby or aria-invalid.

Field gives its control snippet an attrs object: id, aria-describedby, aria-invalid and required. Spread it onto the control with {...attrs} and pass any other attributes after it. The same snippet works for an Input, a Textarea or a Select trigger.

Display name

Display name

Everyone in the room sees this name.

import { Field } from "@sideby/ui/field";
import { Input } from "@sideby/ui/input";

<Field label="What should we call you?" description="Everyone in the room sees this name.">
  {#snippet control(attrs)}
    <Input {...attrs} name="display-name" autocomplete="nickname" maxlength="32" />
  {/snippet}
</Field>

Placeholder

A placeholder shows the shape of the answer, in muted text that disappears as soon as someone types. It is never the label: it is gone the moment it would help, and many screen readers skip it.

Placeholder

import { Field } from "@sideby/ui/field";
import { Input } from "@sideby/ui/input";

<Field label="Video link">
  {#snippet control(attrs)}
    <Input {...attrs} type="url" placeholder="https://example.com/movie.mp4" />
  {/snippet}
</Field>

Error

Set error and Field marks the control aria-invalid, which turns its edge red, and writes the message under it with a small mark in front. The message lives in a polite live region that is always in the page, so a screen reader announces a new error without stealing focus. Clear error and both go away.

The same field in the dark and the light theme:

Error in both themes

That link is playing hard to get. Try a direct video file or a YouTube link.

That link is playing hard to get. Try a direct video file or a YouTube link.

import { Field } from "@sideby/ui/field";
import { Input } from "@sideby/ui/input";

<Field label="Video link" error="That link is playing hard to get. Try a direct video file or a YouTube link.">
  {#snippet control(attrs)}
    <Input {...attrs} type="url" value="https://example.com/watch" />
  {/snippet}
</Field>

Label on its own

Label is the label voice on a native label. Field already renders one, so reach for it alone only when a layout cannot use Field. Its for must match the control’s id.

Label and Input
import { Input } from "@sideby/ui/input";
import { Label } from "@sideby/ui/label";

<Label for="room-code">Room code</Label>
<Input id="room-code" name="room" autocomplete="off" />

Accessibility

  • A label is required. Field always renders a visible one tied to the control through for and id, so clicking the words focuses the field and the field has a name.
  • Text is 16px. Every input uses text-input, so iOS Safari never zooms the page when the field takes focus.
  • Errors are announced. The error text sits in an aria-live="polite" region and is linked through aria-describedby, so it is read when it appears and again when the field takes focus.
  • The words carry the meaning, not the red edge. The border colour is a second cue for sighted people; the error text says what went wrong and what to do.
  • Required is a word. required shows the word “required” in the label voice, never an asterisk alone. The word is hidden from screen readers because the input’s own required attribute is already announced.
  • Tab moves to the field and shows the ring outline. The edge uses border-control, which holds 3:1 against the page in both themes.

Copy

  • Labels name the thing: “Video link”, “Room code”, “What should we call you?“. Keep them short; uppercase comes from CSS, so write them in sentence case.
  • Descriptions say what works: “Direct video files and YouTube links work best.” Tell people what to put in, not what they did wrong.
  • Errors follow the voice guide: say what happened and what to do next, never blame. “That link is playing hard to get. Try a direct video file or a YouTube link.” beats “Invalid URL”.