Professional forms with location-aware features using Google Places autocomplete. Perfect for service businesses that need to verify service areas, calculate travel fees, or collect accurate customer addresses.
The Address Input control is ideal for:
Every code snippet below is fully editable! Feel free to modify the code, experiment with different values, and see your changes reflected instantly in the live preview on the right.
Use the play button to run different snippet, or the refresh button to restore the original example.
Add a simple address input with Google Places autocomplete. Users start typing and see address suggestions appear automatically.
addAddress() to add an address field. The autocomplete powered by Google Places API provides accurate, real-world addresses with coordinates. Limit address suggestions to specific countries. This is useful when you only serve certain regions.
restrictToCountries with ISO 3166-1 alpha-2 country codes. For example: 'US' (United States), 'GB' (United Kingdom), 'CA' (Canada), 'DE' (Germany). Calculate the distance from your business location to the customer's address. Essential for service area verification and travel fee calculations.
referenceAddress to your business location and showDistance: true to display the distance. Access the distance programmatically with address('id')?.distance(). Automatically validate that customers are within your service area. The form will show an error if the address is too far from your location.
maxDistance to set your service radius. Check address('id')?.isWithinRange() to conditionally show content based on whether the customer is in your service area. Create pricing tiers based on distance. This lawn care example charges a travel fee for customers farther away.
distance() to implement tiered pricing logic. Common pattern: free delivery within X miles, fee for X-Y miles, no service beyond Y miles. Show an interactive map with markers for both the reference location and the selected address. A line connects them, colored green or red based on distance.
showMap: true to display an interactive Leaflet map below the address input. The map automatically zooms to show both locations when an address is selected. Build a complete house cleaning quote calculator that combines address validation with pricing based on square footage, frequency, and travel distance.
Learn how to access all the data returned by the address selection: full address, coordinates, country, and Google Place ID.
AddressValue type includes: formattedAddress, coordinates (lat/lng), country, countryCode, and placeId. Use these for CRM integration, analytics, or custom logic. | Property | Type | Description |
|---|---|---|
placeholder | string | Placeholder text for the input |
restrictToCountries | string[] | ISO 3166-1 alpha-2 country codes (e.g., ['US', 'CA']) |
showMap | boolean | Display interactive map with markers (default: false) |
showDistance | boolean | Show distance badge from reference (default: false) |
referenceAddress | AddressValue | Reference point for distance calculation (your business location) |
maxDistance | number | Maximum allowed distance from reference (validation) |
distanceUnit | 'km' | 'miles' | Unit for distance display and calculation (default: 'km') |
| Method | Returns | Description |
|---|---|---|
value() | AddressValue | null | Current address value with all details |
distance() | number | null | Distance from reference in configured unit |
isWithinRange() | boolean | Whether address is within maxDistance |
You've mastered address input with distance-based features! This is powerful for service businesses that need to verify coverage areas and calculate pricing.
Continue to Computed Values TutorialOther learning paths: