A design system in a box. hip-ui.tngl.io/docs/introduction
at main 33 lines 881 B view raw
1"use client"; 2 3import { useFilter } from "react-aria-components"; 4 5import { AutocompleteInput } from "@/components/autocomplete"; 6import { ListBoxItem } from "@/components/listbox"; 7 8const options = [ 9 { id: "apple", handle: "Apple" }, 10 { id: "apricot", handle: "Apricot" }, 11 { id: "banana", handle: "Banana" }, 12 { id: "blueberry", handle: "Blueberry" }, 13 { id: "cherry", handle: "Cherry" }, 14 { id: "grape", handle: "Grape" }, 15 { id: "orange", handle: "Orange" }, 16 { id: "strawberry", handle: "Strawberry" }, 17]; 18 19export function Basic() { 20 const { contains } = useFilter({ sensitivity: "base" }); 21 22 return ( 23 <AutocompleteInput 24 filter={contains} 25 label="Fruit" 26 placeholder="Type to search..." 27 items={options} 28 onAction={() => {}} 29 > 30 {(item) => <ListBoxItem id={item.id}>{item.handle}</ListBoxItem>} 31 </AutocompleteInput> 32 ); 33}