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
Full TypeScript signature sourced from the composable file.
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
Return values
Properties and methods exposed by the composable return object.
- 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
Examples
Ready-to-paste usage snippets.
Read list context in a custom item
Create a list context (useCreateList)