Skip to content

Label

An accessible label associated with input elements.

Usage

Pair a <Label> with an input element to provide an accessible label. To associate the label with the form element, wrap the form element within <Label>:

import { Input } from "stylus-ui/Input";
import { Label } from "stylus-ui/Label";
export default () => (
<Label className="flex flex-col gap-2">
Email address
<Input type="email" />
</Label>
);

Alternatively, you can pass an id string to the label’s htmlFor prop:

import { Input } from "stylus-ui/Input";
import { Label } from "stylus-ui/Label";
export default () => (
<div className="flex flex-col gap-2">
<Label htmlFor="email">Email address</Label>
<Input type="email" id="email" />
</div>
);

API Reference

Label

Inherits properties from HTMLLabelElement.

Prop
Type
Default
asChild boolean false
htmlFor string
theme "dark""light" "light"