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
Full TypeScript signature sourced from the composable file.
Consumed interfaces
IAdjacentProps
IAdjacentInnerProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIAdjacentProps
- 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
Return values
Properties and methods exposed by the composable return object.
- 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
Examples
Ready-to-paste usage snippets.
Component with prepend/append icons
Status-aware prepend icon override