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

Follow updates

Join 1,000+ subscribers and receive monthly updates with the latest improvements on API Reference.

Read latest issue

No Spam. Unsubscribe at any time.