Skip to Content
dk-address

shadcn/ui

AddressInput styled with your shadcn/ui theme, as a component you copy into components/ui and own.

shadcn/uiCombobox
Loading demo…

The same headless AddressInput as everywhere else, styled the way shadcn/ui styles its own inputs and comboboxes. It uses your theme's tokens (bg-popover, text-muted-foreground, ring-ring, border-input…), so it follows your colours, radius and dark mode.

Install the block

  1. Install the package and the icons. lucide-react is already there in most shadcn/ui projects.

    npm i @dk-address/react lucide-react
  2. Copy the Code tab into components/ui/address-input.tsx. It imports cn from @/lib/utils, which shadcn/ui sets up for you.

Use the parts

import { MapPinIcon } from "lucide-react";
import {
  AddressInput,
  AddressInputClear,
  AddressInputContent,
  AddressInputControl,
  AddressInputEmpty,
  AddressInputHint,
  AddressInputInput,
  AddressInputLabel,
  AddressInputList,
  AddressInputStatus,
} from "@/components/ui/address-input";

export function DeliveryAddress() {
  return (
    <AddressInput onSelect={(selection) => console.log(selection.details)}>
      <AddressInputLabel>Delivery address</AddressInputLabel>
      <AddressInputControl>
        <MapPinIcon />
        <AddressInputInput placeholder="Vesterbrogade 28, st. 1" />
        <AddressInputClear />
      </AddressInputControl>
      <AddressInputHint />
      <AddressInputContent>
        <AddressInputStatus />
        <AddressInputEmpty />
        <AddressInputList />
      </AddressInputContent>
    </AddressInput>
  );
}

What each part wraps

PartWrapsStyled like
AddressInputAddressInput(renders nothing)
AddressInputLabel.LabelLabel
AddressInputControl.ControlInput: border, focus ring, aria-invalid state; icons inside are muted and sized
AddressInputInput.InputThe text inside Input
AddressInputClear.ClearA muted icon button; shows an X unless given children
AddressInputHintuseAddressInput()Muted helper text: what to type into the gap
AddressInputContent.PopupPopoverContent, as wide as the control, animated in and out
AddressInputStatus.StatusScreen-reader-only search status
AddressInputEmpty.EmptyCommandEmpty
AddressInputList.ListRenders an AddressInputItem per suggestion unless given children
AddressInputItem.ItemCommandItem, with an icon per suggestion type

Every part merges your className over its own with cn, so className="h-10" replaces the default height instead of fighting it. The AddressInput reference lists each part's props and state.

Validate it in a form

Mark the field invalid with aria-invalid on AddressInputInput; the control turns red like shadcn/ui's Input. To submit the address id and require a real pick, see Styling AddressInput → Wire it into forms.