Renders an accessible caption for a form control. Link it to a control with for, or wrap the control inside it. Styled with theme tokens like the shadcn label.
<script lang="ts">
import { Label } from "#lib/components/ui/label/index.js";
import { Input } from "#lib/components/ui/input/index.js";
</script>
<Label for="email">Email</Label>
<Input id="email" type="email" placeholder="[email protected]" />pnx remote0 add https://plainsv.com/r/label.jsonSet size to xs, sm, md, or lg. The default is md. Every size uses --text-sm except xs, which uses --text-xs, so the label can match a control of the same size.
<Label size="xs" for="name">Name</Label>
<Input size="xs" id="name" />Place an icon before or after the text. Icons scale with the label text.
<script lang="ts">
import { Label } from "#lib/components/ui/label/index.js";
import { MailIcon } from "@lucide/svelte";
</script>
<Label for="email"><MailIcon />Email</Label>The label dims and shows a not-allowed cursor when it wraps a disabled control, comes after a disabled sibling control, or sits inside an element with data-disabled="true".
<Input id="email" disabled />
<Label for="email">Email</Label>
<Label><input type="checkbox" disabled />Remember me</Label>The Label props extend the native label attributes, such as for.
interface Props extends CompPropsWithChild<"label"> {
/** Text size on the shared scale */
size?: UiSize;
/** Classes merged onto the label */
class?: CompPropsWithChild<"label">["class"];
}