Beta /api/states

Country, state, and city selector

Three dependent selectors that progressively narrow the dataset without loading every city up front.

Dependent loading Country-code filtering Small responses Reset-safe state

Installation

Install once, use everywhere.

composer require nnjeim/world
php artisan world:install

React, Angular, and Vue consume the same Laravel API; no frontend package is required.

Playground

Live behavior and copy-ready code.

Country, state, and city selector

Connecting to the World API…

Live preview

Selected location

Romania · Cluj County · Cluj-Napoca

component.blade.php
Loading example…

API reference

Request only the fields you need.

GET /api/states?filters[country_code]=RO&fields=country_code
Endpoint
/api/states
Fields used
country.id, country.iso2, state.id, city.id

Component contract

Props

NameTypeDefaultDescription
country number|null null Initially selected country ID.
state number|null null Initially selected state ID.
city number|null null Initially selected city ID.
required boolean false Requires every enabled level.

Events

country-change Country

Resets state and city before loading states.

state-change State

Resets city before loading cities.

change Location

Emits the complete selected location.

Validation guidance

  • Validate each ID independently.
  • Confirm the state belongs to the submitted country.
  • Confirm the city belongs to the submitted state.

Accessibility checklist

  • ✓Keep disabled dependent fields in the tab order only when actionable.
  • ✓Announce loading before enabling the next field.
  • ✓Preserve visible labels for all three selectors.
  • ✓Move focus only when the user explicitly requests it.