grocery-app/frontend/src/components/items/SuggestionList.tsx
2026-01-02 17:26:20 -08:00

39 lines
768 B
TypeScript

interface Props {
suggestions: string[];
onSelect: (value: string) => void;
}
export default function SuggestionList({ suggestions, onSelect }: Props) {
if (!suggestions.length) return null;
return (
<ul
className="suggestion-list"
style={{
background: "#fff",
border: "1px solid #ccc",
maxHeight: "150px",
overflowY: "auto",
listStyle: "none",
padding: 0,
margin: 0,
}}
>
{suggestions.map((s) => (
<li
key={s}
onClick={() => onSelect(s)}
style={{
padding: "0.5em",
cursor: "pointer",
borderBottom: "1px solid #eee",
}}
>
{s}
</li>
))}
</ul>
);
}