Location Picker

A location picker component that allows users to search and select locations.

Installation

Install the Location Picker component using your preferred package manager.

npxshadcn@latest addhttps://rigidui.com/registry/location-picker

Usage

The Location Picker component provides an interface for searching and selecting locations. It supports both popover and inline variants to fit different UI contexts.

Live Preview

Discover Its Features

The Location Picker component is packed with powerful features designed to provide an exceptional user experience.

Location Search

Users can search for locations by name, address, or postal code with real-time suggestions.

Dual Variants

Choose between popover variant for compact layouts or inline variant for full-featured forms.

Autocomplete Suggestions

As users type, the component provides autocomplete suggestions for locations with debounced search.

Geolocation Support

Allows users to quickly use their current location with browser geolocation API.

API Reference

PropTypeDefaultDescription
defaultLocationstring''The default location to display
autoDetectOnLoadbooleanfalseWhether to automatically detect location on component load
variant'popover' | 'inline''popover'The display variant of the component
placeholderstring'Enter city, district, or area'Placeholder text for the search input
showLabelbooleantrueWhether to show the label section (only applies to inline variant)
onChange(location: string) => voidundefinedCallback function called when location changes
classNamestring''Additional class names for styling

Advanced Usage

Explore different configurations and use cases for the Location Picker component.

Popover Variant (Default)

Compact trigger that opens a popover with location search functionality. Perfect for navigation bars or space-constrained layouts.

Live Preview

Inline Variant

Full-featured inline interface with immediate access to search functionality. Ideal for forms or dedicated location selection pages.

Live Preview

Location

Find products near you

Auto-detect Location

Automatically detect user's current location when the component loads.

Live Preview

Custom Styling

Customize the appearance with className and custom placeholder text.

Live Preview

With Change Handler

Handle location changes with a callback function for integration with forms or state management.

Live Preview

Location

Find products near you

Check console for location changes