Skip to content
Haze UI

Input group

Input with a leading and trailing add-on, such as https:// or an icon, where the outer box takes the border and focus ring.

pnpm dlx shadcn@latest add @haze/input-group
Open preview in a new tab
Liveno JavaScript

When to use

  • Showing a fixed prefix or suffix, like a domain, currency or unit
  • A search box with a magnifier icon inside the field
  • Values where the user should only type the changing part

When not to use

  • An add-on that is clickable, such as a Copy button; place a button next to an input instead
  • Plain text with no prefix or suffix; use input

Installation

Add the Haze registry to components.json once, then install Input group with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/input-group
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
id*string–Input id; reference it from a label or Field.
namestringidForm field name.
type"text" | "email" | "password" | "search" | "url" | "tel" | "number""text"Input type.
placeholderstring–Example value shown while empty.
leadingstring–Text add-on before the input, on a quiet fill.
trailingstring–Text add-on after the input, on a quiet fill.
classstring–Extra classes on the bordered wrapper.
leading slotslot–Replaces the leading text, for example with an icon. Styled as an icon add-on with no fill.
trailing slotslot–Replaces the trailing text.
...restattributes–Any other input attribute, for example value, required, disabled or aria-invalid.

Keyboard interactions

Tab
Focuses the input; the add-ons are not focusable

Accessibility

  • Text add-ons sit on a quiet fill with a hairline; icon add-ons have no fill.
  • The wrapper draws the focus ring through focus-within, so the whole box lights up while the real input holds focus. A destructive border shows when the input has aria-invalid=true.
  • Add-on text is not part of the input's accessible name; repeat the unit in the label or description, for example "Monthly budget in dollars".
  • Icons in the slots should be aria-hidden; a meaningful add-on needs text.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI component "Input group" with `npx shadcn@latest add @haze/input-group`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import InputGroup from "@/components/haze/ui/input-group.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/input-group.md

  • Customize with real content

    Adapt the Haze input-group ui for our product. Replace the demo values of these props with our real content: id, name, type, placeholder, leading, trailing, class, leading slot, trailing slot, ...rest. Keep the layout, the heading level rules and these accessibility details: Text add-ons sit on a quiet fill with a hairline; icon add-ons have no fill. The wrapper draws the focus ring through focus-within, so the whole box lights up while the real input holds focus. A destructive border shows when the input has aria-invalid=true. Add-on text is not part of the input's accessible name; repeat the unit in the label or description, for example "Monthly budget in dollars". Icons in the slots should be aria-hidden; a meaningful add-on needs text. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using input-group, check it fits: use it when showing a fixed prefix or suffix, like a domain, currency or unit; a search box with a magnifier icon inside the field; values where the user should only type the changing part. Avoid it when an add-on that is clickable, such as a copy button; place a button next to an input instead; plain text with no prefix or suffix; use input. Alternatives: @haze/input, @haze/field, @haze/button-group.

Dependencies

  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog