Skip to content
Klarhimmel UI

Label

npx shadcn add @klarhimmel/label @klarhimmel/input

Examples

  • 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

label.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Input } from '@/components/klarhimmel/ui/input';
import { Label } from '@/components/klarhimmel/ui/label';

export default function Example() {
  return (
    <Theme theme="brand">
      <Label htmlFor="email" required>Email address</Label>
      <Input id="email" type="email" required />
    </Theme>
  );
}

Import

Import

import { Label } from '@/components/klarhimmel/ui/label';
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

PropTypeDefaultDescription
requiredboolean-Adds a visible "required" mark. It does not set `required` on the control: do that on the control itself.
native attributesLabelHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
ClickFocuses the control it names

A label must be connected with htmlFor, or wrap the control.

Accessibility