Components

Input Group

A React input group built on shadcn/ui: attach icons, prefixes, units, keyboard hints and buttons to an input or textarea, with one shared hover state, focus ring and invalid state — plus Motion blocks for a copy-to-clipboard field with a morphing check and a URL input whose protocol addon rolls between https and http.

  • Drop-in shadcn API
  • Input & textarea
  • Inline and block addons
  • Group focus ring
  • Motion blocks

Installation

$ npx shadcn@latest add https://duskui.com/r/input-group.json

Builds on the DuskUI Button, Input and Textarea, which the CLI installs for you.

Usage

search.tsx
import { SearchIcon } from "lucide-react"
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group"

export function Search() {
  return (
    <InputGroup>
      <InputGroupInput placeholder="Search…" aria-label="Search" />
      <InputGroupAddon>
        <SearchIcon />
      </InputGroupAddon>
    </InputGroup>
  )
}

Examples

Icons, text & keys

Addons go on inline-start (the default) or inline-end. Put the addon after the input in the markup — CSS order places it — so focus order stays natural. Icons brighten while the field is focused, and aria-invalid on the input turns the whole group red.

⌘K
.dusk.dev
$
USD

With a button

InputGroupButton is a compact DuskUI Button, so loading keeps its width while it shows a spinner.

Textarea with a toolbar

block-end stacks the addon under the control — handy for toolbars and counters. The textarea still grows with its content.

280 characters left

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Copy Input

A read-only field for API keys, invite links and install commands. On copy the icon swaps to a check and the label rolls to “Copied” without changing the button's width. Focus selects the whole value.

$ npx shadcn@latest add https://duskui.com/r/copy-input.json
PropTypeDefaultDescription
valuestring—The text to show and copy. Required.
onCopy(value: string) => void—Fires after a successful copy.
timeoutnumber2000How long the copied state lasts (ms).
addonReactNode—Leading icon or text.
copyLabel / copiedLabelstring"Copy" / "Copied"Button labels. copyLabel="" makes it icon-only.

URL Input

Paste a full address and the protocol lifts out of the text into the addon. Click the addon to switch between https and http — the padlock unlocks and the protocol rolls over — and a check or warning fades in as you type. The value always includes the protocol.

Value: https://duskui.com

$ npx shadcn@latest add https://duskui.com/r/url-input.json
PropTypeDefaultDescription
value / onValueChangestring / (url: string) => void—Full URL with protocol; empty string when empty.
showStatusbooleantrueShow the valid / invalid icon.
namestring—Submits the full URL with a hidden input.
groupClassNamestring—Classes for the group; className goes to the input.

API Reference

Each part accepts the props of the element it renders.

PropTypeDefaultDescription
InputGroupAddon align"inline-start" | "inline-end" | "block-start" | "block-end""inline-start"Where the addon sits relative to the control.
InputGroupButton size"xs" | "sm" | "icon-xs" | "icon-sm""xs"Compact sizes that fit inside the group. variant defaults to ghost.
InputGroup data-disabledboolean—Dims the whole group.
InputGroupInput / InputGroupTextareainput / textarea props—The DuskUI controls with their own border and ring removed.

Accessibility

  • The group has role="group"; still give the control a <label> or aria-label.
  • Icon-only buttons need an aria-label. Clicking an addon focuses the control.
  • Copy Input and URL Input announce their result through a polite live region; the protocol toggle says which protocol it switches to.
  • Icon and label swaps respect prefers-reduced-motion.