useSelectLink

Commons
stable

Bridges a router link and a group selection: when the link becomes active (current route matches), it automatically selects its group item. Used internally by navigation components (NavList, BottomNav, Tabs) so that a hard navigation or a programmatic router push keeps the selected state in sync without a manual v-model update.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

useSelectLink is a side-effect-only composable — it returns nothing. Its entire contract is the watcher that calls select() on next tick when link.isActive flips to true. The next-tick deferral avoids a synchronous group mutation during the router navigation cycle.

Consumed interfaces

IUseLink

API

Parameters

Input parameters accepted by this composable.

link
required
IUseLink
The link object returned by useRouter/useLink. Exposes isLink (whether an href/to prop is present) and isActive (whether the current route matches the link target). Watched by the composable to trigger selection.
select
(value: boolean, e?: Event) => void
The group selection callback injected by useGroup. When the link becomes active, this is called with value=true on the next tick. When undefined, the composable becomes a no-op.

Usage

Examples

Ready-to-paste usage snippets.

Navigation item that auto-selects on route match

vue