useAdjacent
Commons
stable
Resolve the presence of prepend and append slots/icons for a component. Exposes computed flags (hasPrepend, hasAppend) that combine both the slot content and the icon/avatar props, plus click-event emitters for the clickable prepend/append areas. A companion composable useAdjacentInner handles the inner prepend/append surface (inside an input field).
API
Signature
Signature TypeScript complète extraite du fichier du composable.
Interfaces consommées
IAdjacentProps
IAdjacentInnerProps
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsrequisIAdjacentProps
- Props carrying prependIcon, appendIcon, prependAvatar, and appendAvatar values. The composable reads these to determine whether the outer prepend/append regions should render.
- prependIconRef | ComputedRef
- Optional reactive icon override for the prepend slot. When provided, takes precedence over props.prependIcon, enabling status-aware icon swapping without prop mutation.
- appendIconRef | ComputedRef
- Optional reactive icon override for the append slot. Same semantics as prependIcon but for the trailing position.
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- hasPrependMedia
- True when a prepend avatar or icon (resolved from prop or override ref) is present, regardless of the prepend slot.
- hasPrepend
- True when either the prepend slot is filled OR hasPrependMedia is true. Use this to conditionally render the prepend wrapper.
- hasAppendMedia
- True when an append avatar or icon (resolved from prop or override ref) is present.
- hasAppend
- True when either the append slot is filled OR hasAppendMedia is true.
- onClickPrepend
- Click handler to bind on the prepend area. Emits the click:prepend event from the component instance.
- onClickAppend
- Click handler to bind on the append area. Emits the click:append event from the component instance.
Usage
Exemples
Extraits de code prêts à coller.
Component with prepend/append icons
Status-aware prepend icon override