useList

List
stable

Provides access to the nearest OrigamList context. Returns the hasPrepend / hasAppend reactive flags that list items use to coordinate their icon gutter alignment. Returns null when called outside an OrigamList provider — safe to call in standalone items.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

useList returns null when called outside an OrigamList — always null-check the result before accessing its members. To create a list context use useCreateList() which both provides the new context and returns the parent one.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

hasPrepend
True when at least one sibling list item has a prepend slot or icon. Used to align text in items that have no prepend.
hasAppend
True when at least one sibling list item has an append slot or icon.
updateHasPrepend
Called by each list item to register whether it contributes a prepend element. The parent list aggregates this into hasPrepend.
updateHasAppend
Called by each list item to register whether it contributes an append element.

Usage

Exemples

Extraits de code prêts à coller.

Read list context in a custom item

vue

Create a list context (useCreateList)

vue