Skip to content
Klarhimmel UI

Input group

krper night
npx shadcn add @klarhimmel/input-group @klarhimmel/input

Examples

  • Currency

  • Url

  • States

DetailsAbout, usage, props and more

One field made of parts: a prefix or suffix, the input and a button, sharing one border and one focus ring.

When to use

  • Use for

    A value with its unit, scheme or action beside it: kr, https://, a copy button, a search icon.

  • Not for

    A plain field. Use Input. A choice from a list. Use Select.

  • Pairs with

    Field, Kbd, Button.

Preview

krper night

Including VAT.

input-group.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { Field } from '@/components/klarhimmel/ui/input';
import { InputGroup, InputGroupAddon, InputGroupInput } from '@/components/klarhimmel/ui/input-group';

export default function Example() {
  return (
    <Theme theme="brand">
      <Field label="Price per night">
        {(p) => (
          <InputGroup>
            <InputGroupAddon>kr</InputGroupAddon>
            <InputGroupInput {...p} inputMode="numeric" />
          </InputGroup>
        )}
      </Field>
    </Theme>
  );
}

Import

Import

import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupButton } from '@/components/klarhimmel/ui/input-group';
Files
input-group.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
InputGroup.invalidboolean-
InputGroup.disabledboolean-Draws the red border or the disabled look on the whole group. Put aria-invalid or disabled on the input too.
InputGroup.classNamestring-Extra classes, merged after the component's own.
InputGroup.childrenReactNoderequired
InputGroupAddon.align'start' | 'end''start'
InputGroupAddon.classNamestring-Extra classes, merged after the component's own.
InputGroupAddon.childrenReactNoderequired
native attributesHTMLAttributes-Every native attribute of the element passes through, className included.

Accessibility

KeyDoes
TabMoves through the input and the buttons in the group
Enter / SpacePresses a focused button

The group draws the frame and the focus ring; the input is named by its Field label. Text addons are read in order, so write them as part of the question.

Accessibility