Skip to content
Klarhimmel UI

Field

As it appears on invoices.

npx shadcn add @klarhimmel/input
DetailsAbout, usage, props and more

Label, control and a hint or error, with the ids wired for assistive tech.

When to use

  • Use for

    Around every form control: it owns the label, the hint and the error.

  • Not for

    Grouping several controls. Use a fieldset.

  • Pairs with

    Input, Textarea, Switch.

Preview

We only use it to reply.

field.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Input, Field } from '@/components/klarhimmel/ui/input';

export default function Example() {
  return (
    <Theme theme="brand">
      <Field label="Company" error="Enter the company name.">
        {(p) => <Input {...p} />}
      </Field>
    </Theme>
  );
}

Import

Import

import { Field } from '@/components/klarhimmel/ui/input';
Files
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
labelReactNoderequiredRequired. The visible label.
labelHiddenboolean-The label is read by assistive tech but not drawn: for a field whose context already says what it is.
hintReactNode-Help text under the control.
errorReactNode-Error text; replaces the hint and marks the control invalid.
children(p: { id: string; 'aria-describedby'?: string; 'aria-invalid'?: true }) =>…requiredRender prop: spread p onto the control.
classNamestring-Extra classes, merged after the component's own.

Accessibility

KeyDoes
TabMoves to the control; the label is read with it
Screen readerReads label, hint and error together

Field wires the label, hint and error to the control with htmlFor and aria-describedby.

Accessibility