Accessible form labels with color variants for default, success, and error states.
Setup
<script lang="ts">
import { Label } from '@cailabs/components.forms';
</script> Default
<script lang="ts">
import { Label, Input } from '@cailabs/components.forms';
</script>
<Label for="email" class="mb-2">Your email</Label>
<Input id="email" type="email" placeholder="name@bitblue.com" /> Colors
Theme colors: disabled, primary, secondary, green, emerald, red, blue, yellow, orange, gray (typical default), teal, cyan, sky, indigo, lime, amber, violet, purple, fuchsia, pink, rose.
<Label color="gray">Gray</Label>
<Label color="green">Success</Label>
<Label color="red">Error</Label>
<Label color="primary">Primary</Label>
<Label color="disabled">Disabled</Label> Show prop
When show={false}, only children render (no <label> wrapper)—useful when nesting interactive content that already has a label.
<script lang="ts">
import { Label, Input } from '@cailabs/components.forms';
</script>
<Label show={false}>
<span class="mb-2 block text-sm font-medium">Custom wrapper</span>
<Input placeholder="…" />
</Label> Accessibility
- Always associate labels with controls via
for/id, or wrap the control. - Use color as reinforcement only; include text that states the status.
- Prefer visible labels over placeholder-only fields.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | Snippet | required | Label content |
color | theme color | — | Text color token |
show | boolean | true | Render <label> or only children |
for | string | — | Associated control id |
class | ClassValue | — | Extra classes |
...rest | HTML label attrs | — | Other label attributes |