Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Input Group for Astro

Astro inputs with attached text, icons, and action controls.

⌘K
@gnosticai.com
Shift + Enter for newline

Installation

bunx --bun shadcn@latest add @gnostic/input-group

Usage

import {
    InputGroup,
    InputGroupAddon,
    InputGroupButton,
    InputGroupInput,
    InputGroupText,
    InputGroupTextarea,
} from "@/components/ui/input-group"
<InputGroup>
  <InputGroupInput placeholder="Search..." />
  <InputGroupAddon align="inline-start">
    <InputGroupText>⌘K</InputGroupText>
  </InputGroupAddon>
</InputGroup>

Composition

Arrange the parts as shown for an InputGroup:

InputGroup
├── InputGroupInput or InputGroupTextarea
├── InputGroupAddon
├── InputGroupButton
└── InputGroupText

Align

Place InputGroupAddon after InputGroupInput or InputGroupTextarea in the DOM, then use the align prop to position it visually.

  • inline-start places the addon at the start of an input.
  • inline-end places the addon at the end of an input.
  • block-start places the addon above a textarea or stacked control.
  • block-end places the addon below a textarea or stacked control.

Custom Controls

If you use a custom input component, make sure it follows the same sizing and focus behavior as the built-in input group controls.

Notes

  • Use InputGroupInput or InputGroupTextarea inside InputGroup instead of mixing in the plain Input or Textarea components directly.
  • Keep InputGroupAddon next to the control it belongs to so focus and spacing stay consistent.

Sizes and states

/sites/
Required

Use lowercase letters and hyphens.

https://
Handoff notes

API Reference

Read the installed source for the complete prop types.

When to use Input Group

Compose an InputGroupInput or InputGroupTextarea with addons inside InputGroup. Use addons for units, prefixes, or actions that belong to the same value. Keep a separate label for the whole field.

Keyboard and behavior

The native control supplies form behavior. Addon click handling can focus the control, while buttons inside addons keep their own action. Give icon buttons accessible names and avoid placing a second independent field inside the same visual group.

Theme and layout

The root owns the border and focus surface; the inner control clears its own border and shadow. Use the addon alignment options for multiline content. Check invalid and disabled appearances on the complete group.