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

Signature TypeScript complète extraite du fichier du composable.

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.

Interfaces consommées

IUseLink

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

link
requis
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

Exemples

Extraits de code prêts à coller.

Navigation item that auto-selects on route match

vue