1.0.0 • Published 5 months ago
moroccan-cities-autocomplete-input v1.0.0
Moroccan Cities Autocomplete Input
A React component for Moroccan cities autocomplete with TypeScript support and Next.js compatibility.
Features
- 🌟 Full TypeScript support
- ⚡ Next.js compatible (App Router & Pages Router)
- 📱 Responsive and customizable
- 🎨 Tailwind CSS ready
- 🔍 Smart search with suggestions
- ⌨️ Keyboard navigation support
Installation
npm install moroccan-cities-autocomplete-input
# or
yarn add moroccan-cities-autocomplete-input
# or
bun add moroccan-cities-autocomplete-input
Usage
With Next.js (App Router)
// app/components/CitySelector.tsx
"use client";
import { MoroccanCityInput } from "moroccan-cities-autocomplete-input";
export default function CitySelector() {
const [city, setCity] = useState("");
return (
<MoroccanCityInput
value={city}
onChange={setCity}
label="City"
required
className="block w-full rounded-lg border p-2.5 text-sm"
/>
);
}
With Next.js (Pages Router)
import { MoroccanCityInput } from "moroccan-cities-autocomplete-input";
export default function CheckoutPage() {
const [city, setCity] = useState("");
return (
<MoroccanCityInput
value={city}
onChange={setCity}
label="City"
required
className="block w-full rounded-lg border p-2.5 text-sm"
/>
);
}
Props
Prop | Type | Default | Description |
---|---|---|---|
value | string | required | The current value of the input |
onChange | (value: string) => void | required | Callback when value changes |
placeholder | string | "Enter a city name" | Input placeholder text |
className | string | "" | CSS classes for the input element |
required | boolean | false | Whether the input is required |
label | string | undefined | Label text for the input |
labelClassName | string | "" | CSS classes for the label |
suggestionsClassName | string | "" | CSS classes for the suggestions container |
suggestionItemClassName | string | "" | CSS classes for individual suggestion items |
License
MIT
Author
Yassin Slati
1.0.0
5 months ago