Ariakit
/

CollectionProvider

Provides a collection store to CollectionItem components.

Code examples

Optional Props


defaultItems

T[] | undefined = []

The defaut value for the items state.


items

T[]

Lists all items along with their metadata. This state is automatically updated when an item is registered or unregistered using the registerItem function.


setItems

BivariantCallback<(items: T[]) => void> | undefined

A callback that gets called when the items state changes.

Code examples

const [items, setItems] = useState([]);
const collection = useCollectionStore({ items, setItems });

store

Store<Partial<S>> | undefined

Another store object that will be kept in sync with the original store.

Live examples

Stay tuned

Join 1,000+ subscribers and receive monthly tips & updates on new Ariakit content.

No spam. Unsubscribe anytime. Read latest issue