Kewti Location Selector
A searchable Ethiopian administrative location selector with cascading Region, Zone, and Woreda dropdowns.
const LocationExample = () => { const [address, setAddress] = useState<string[]>([]); return ( <div className="space-y-4"> <KewtiLocationSelector apiUrl="https://kewti.vercel.app" setAddress={setAddress} /> <div className="text-sm text-muted-foreground"> Selected: {address.join(", ") || "None"} </div> </div> ); }; render(<LocationExample />);
Installation
npx kewti-cli add location-selectorUsage
import { KewtiLocationSelector } from "@/kewti/ui"Basic Usage
<KewtiLocationSelector
apiUrl="[API_URL]"
/>We recommend using API_URL (https://kewti.vercel.app) to access our actively maintained and updated location data, though you can replace it with a custom endpoint if needed.
Getting the Selected Address
Use the setAddress prop to receive the selected Region, Zone, and Woreda.
const [address, setAddress] = useState<string[]>([]);
<KewtiLocationSelector
apiUrl="${process.env.NEXT_PUBLIC_LANDING_URL}"
setAddress={setAddress}
/>The resulting value will be like:
["Addis Ababa", "Region 14", "Addis Ketema Sub City"]Only selected values are included.
Custom Styling
You can pass standard className and style props to customize the outer container layout:
<KewtiLocationSelector
className="my-4 max-w-xl"
style={{ padding: "1rem" }}
/>Using a Custom API
By default, the component fetches location data from our API endpoint which we try to constantly update.
<KewtiLocationSelector
apiUrl="https://example.com"
/>The component requests:
GET https://example.com/api/locationsYour endpoint should return data in the following format:
[
{
"admin1_name": "Afar",
"admin2_name": "Kilbati /Zone 2",
"admin3name": "Dalol"
},
....
]Cascading Selection
Selections are hierarchical.
- Select a Region
- Available Zones are automatically filtered.
- Select a Zone
- Available Woredas are automatically filtered.
Changing a Region resets both the Zone and Woreda.
Changing a Zone resets the Woreda.
Search
Each dropdown includes built-in search.
Simply open a dropdown and start typing to filter the available options.
Features
- Searchable Region, Zone, and Woreda selectors.
- Cascading filtering between administrative levels.
- Automatic reset of dependent selections.
- Fully responsive layout with support for custom
classNameandstyle. - Keyboard accessible.
- Memoized filtering for improved performance.
- Supports controlled parent state through
setAddress.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
apiUrl | string | "{process.env.NEXT_PUBLIC_LANDING_URL}" | Base URL of the location API. The component fetches from /api/locations. |
setAddress | React.Dispatch<React.SetStateAction<string[]>> | — | Receives the currently selected address as [region, zone, woreda]. |
className | string | — | Additional CSS classes applied to the root container element. |
style | React.CSSProperties | — | Inline style object applied to the root container element. |
API Response Format
The component expects an array of objects with the following structure:
interface Location {
admin1_name: string;
admin2_name: string;
admin3name: string;
}Example:
[
{
"admin1_name": "Amhara",
"admin2_name": "North Shewa",
"admin3name": "Debre Berhan"
}
]Behavior
- Location data is fetched once when the component mounts.
- Duplicate Regions, Zones, and Woredas are automatically removed.
- Options are sorted alphabetically.
- While data is loading, all dropdowns are disabled.
- Zone selection is disabled until a Region is selected.
- Woreda selection is disabled until a Zone is selected.
Accessibility
- Fully keyboard navigable.
- Search input supports instant filtering.
- Supports screen readers through proper combobox semantics.
Kewti Time
An Ethiopian & Standard 12-hour time picker component supporting dynamic Amharic time periods (ጠዋት, ከሰዓት, ምሽት, ሌሊት), standard AM/PM modes, 24-hour time state conversion, and custom styling.
Kewti Numerals
A lightweight Ethiopian numeral formatter and conversion component supporting traditional Ge'ez numerals (፩, ፲, ፻, ፼), Hindu-Arabic formatting with locale support, standalone utility functions, and custom styling.