Accessible Google Places autocomplete component for React


312.2.04 years ago4 years agoMinified + gzip package size for accessible-google-places-autocomplete in KB


Accessible Google Places Autocomplete Widget for React


Google's Places autocomplete widget is extremely popular for finding addresses, but its default implementation is a simple input box that isn't accessible for people using screen-readers or other assistive devices. This leverages the Accessible Autocomplete by the UK Government Digital Service and applies it to the Google Places API to make address selection accessible to all. The Accessible Autocomplete follows the WAI-ARIA best practices and is compatible with many assistive technologies.

Installation / usage

Get a Google Places API key from Google.

Add the component to your project by running:

yarn add accessible-google-places-autocomplete

In your React application, you can import and use the component in your JSX:

import React from 'react';
import ReactDom from 'react';
import { AccessibleGooglePlacesAutocomplete } from 'accessible-google-places-autocomplete';

    <label for="address_input">Enter your address</label>


The component is distributed as ES5 code in the dist/ folder. To build the ES5 code from the src/ folder Webpack is used.

  1. make your changes in src/
  2. run yarn build
  3. commit, tag, and publish new release.


There is a demo application provided in the repo you can use to test out the component.

  1. cd demo/
  2. copy .env.example to .env and add your Google Places key.
  3. yarn install
  4. yarn start

API documentation

Required props


Type: string

The id used for the embedded input.


Type: string

Google Places API Key needed to request addresses. You'll need to [request one] and make sure it has the correct permissions to request addresses from Places API.

Other props


Type: object (default: {})

Any of the many options available for the Google Places API. See the demo for some examples.


Type: function

Callback function that returns a Google Place Result object when an address is selected. Consider using a package like parseGooglePlace to read the value.


Type: function

Callback function called when a new search is performed or the search box is cleared after an address was previously confirmed.


Type: boolean

Defaults to false. Sometimes the Google Places API details returns a partial postal code instead of a full postal code. In this case, the reverse geocode API can provide a more accurate postal code. Using this option can increase your billing cost because of the additional API call. Only use this option if full postal code matching is required.


Type: boolean (default: false)

Sets the required attribute of the <input>.



If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from