Ariakit
/

Collection

Track a collection of DOM elements in the exact order they're rendered in the DOM and watch the DOM for any change to their order.

Items count: 0
🍎 Apple
🍇 Grape
🍊 Orange
import * as Ariakit from "@ariakit/react";
import "./style.css";
export default function Example() {
const collection = Ariakit.useCollectionStore();
const length = Ariakit.useStoreState(
collection,
(state) => state.renderedItems.length,
);
return (
<Ariakit.Collection store={collection} className="collection">
<div>Items count: {length}</div>
);
}

Stay tuned

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

No spam. Unsubscribe anytime. Read latest issue