Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Address Autocomplete Dialog Block for React

A meal-kit delivery page with its address dialog shown open: typing filters eight addresses of an invented town into an inline list you can arrow through, a choice fills four editable fields, and Enter it manually offers the same four, empty.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Help people find their address instead of typing all of it, with this address dialog for React with Base UI. It opens from the Delivery page of Hampertide, a meal-kit service: the page's header holds an outline Change address Button, and the page, a Deliver to row with the address in force and a week of delivery slots, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The dialog starts with one search Input. As you type, the addresses that hold every word you typed, from eight on invented streets in the invented town of Harrowmere, list under it in a Listbox that is part of the dialog, not a popup, with a count under the field that is spoken once you stop typing. Down arrow takes you into the list and Enter chooses; Enter in the field takes the top match. A choice swaps the space for four fields, street, flat, town and postcode, filled and still editable, and Enter it manually offers the same four empty. Use this address, the only Shine Button, checks them and reprints the Deliver to row. For preview the dialog is drawn open in place when the page loads; the header button opens the real Dialog, with the same search and the same state. For deliveries, checkouts, profiles and any form that takes an address.

FAQ

Why is the dialog already open, and what do I keep?

So you can see it without a click. On load the dialog is a copy drawn in place over the page: a native dialog element that isn't modal, so nothing is trapped, hidden or focused, and the page around the preview keeps working. The Change address button opens the real Dialog, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same AddressSearch component and share the block's state, so a search typed in the copy is there in the real one. In your app keep the Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.

Why is the list inline and not a popup?

A popup that opens from inside a modal fights the modal's focus trap, and on some libraries it can't be reached at all, so the suggestions are part of the dialog's own content: a fixed-height area under the field, the same on every base and port. It shows the matches, a dashed empty state that names what you typed, or a hint before you start, so nothing moves when the results change, and the dialog is as tall when you have typed as when you haven't.

What does Use this address check?

In the search panel, that you chose a match or opted to type, with a sentence that says which. In the fields panel, a street, a town and a postcode that has the shape of one, each with its own sentence under its field; focus goes to the first problem and the dialog stays open. The flat is optional. Once a message shows, it follows your typing and clears when the field is right. The Deliver to row behind the dialog then prints the new address, and the polite status message says nothing was saved.

Is it accessible from the keyboard?

Yes. The real dialog is named by its title and described by its sentence, focus starts in the search field and stays inside until it closes, and Escape, Cancel and the close button all return focus to Change address. The trigger is passed to DialogTrigger through render, and the dialog is controlled with open and onOpenChange. The list is a labelled listbox that Down arrow reaches from the field, with Up and Down to move and Enter to choose; the count is spoken after a pause, never on every key, through one polite status message. The copy shown on load moves no focus; Escape inside it, Cancel and its close button close it and put focus on the header button.

How does it look on a phone?

The copy shown on load docks to the foot of the page as a bottom sheet, its actions pinned at the bottom with Use this address on top, and the search, the list and the fields scroll above them. The real dialog keeps the Dialog's own phone layout, a sheet stuck to the bottom of the screen.

  • Pro

    Billing Address Dialog

    Payments and plans

    An invoice page with its billing-address dialog shown open: the form relabels, reorders and revalidates for the United States, the United Kingdom, Germany and Japan, a switch fills the company's address, and the address is printed the way an envelope would carry it.

  • Pro

    A courier's pickup dialog shown open: a search field with Saved, Recent and Nearby places in an inline list, a drawn street map with a pin you drop or move with the arrow keys, and a latitude and longitude readout.

  • Pro

    Guest Checkout Dialog

    Payments and plans

    A cart with its identify-step dialog shown open: Guest, Sign in and Create account swap the fields under a segmented control, one button names the mode, and the cart's stepper moves on to Shipping once you continue.

  • Pro

    Command Palette Dialog

    Pickers and search

    A docs workspace's command palette shown open over its page: Recent and Pages when the field is empty, and a typed greater-than, at or hash turns it to Actions, People or Pages, each with its own groups and count, and each choice edits the drawn page.

  • Pro

    Contact Picker Dialog

    Pickers and search

    A compose window with its recipient picker shown open: a search over fourteen contacts, four recent ones as toggles, an alphabetical list with pinned letters, a To panel of removable chips, and an Add recipients button that fills the message's To line.

  • Pro

    Quick Reply Dialog

    Pickers and search

    A helpdesk ticket with its saved-replies dialog shown open: a searchable list of eight replies, a preview filled from the ticket, a flag and a field for each variable it cannot fill, an SMS character count and an Insert reply button that writes into the composer.