Label
npx shadcn add @klarhimmel/label @klarhimmel/inputCopy for AIExamples
Basic
Required
Form
DetailsAbout, usage, props and more
The visible text that names a form control.
When to use
Use for
The visible name of a form control you lay out yourself.
Not for
A heading, or a hint under a field. Use Field for the whole stack.
Pairs with
Input, Textarea, Checkbox, Select.
Preview
Import
Import
- Files
- label.tsx, input.tsx, in components/klarhimmel/ui/. With it: button, editing, theme, utils.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
required | boolean | - | Adds a visible "required" mark. It does not set `required` on the control: do that on the control itself. |
native attributes | LabelHTMLAttributes | - | Every native attribute of the element passes through, className included. |
Accessibility
| Key | Does |
|---|---|
Click | Focuses the control it names |
A label must be connected with htmlFor, or wrap the control.
Accessibility