Skip to content
RoxyAPI
Get API Key

Helper

Location search

Debounced city search input, emits roxy-location-select

<roxy-location-search>

Preview and code

Loading the component...

Attributes

AttributeTypeDescription
api-keystring
publishable-keystringBrowser-safe publishable key (pk_) the search sends with its request. A secret key is refused client-side and never sent. Leave unset when endpoint or submitUrl points at your own server route.
endpointstringWhere the search sends its GET while the visitor types, as an absolute URL or a page-relative path such as "/api/roxy/location". Wins over submitUrl. Unset with no submitUrl, the search calls the RoxyAPI location search.
submit-urlstringYour own backend route, which holds the secret key. With no endpoint set, each search is POSTed there as { path: "/location/search", method: "GET", query: { q, limit } }, the shape every component request takes there.
submit-contextstringAn object of your own, sent to your submitUrl route as context beside the search. Passed through untouched and never read.
placeholderstringInput placeholder. The default renders in the page language; a caller-supplied one is printed as given.
default-valuestringInitial text in the input, for restoring a previous search.

Sections you can hide

Pass any of these to hide-sections, or style them with ::part().

inputoptionresults

Events

Each event bubbles out of the component, so listen on the element or any ancestor.

EventDescription
roxy-location-selectProvides the selected city with its coordinates and timezone.
roxy-validation-errorReports missing required inputs or a refused client-side API key.