useActive

Commons
stable

Tracks the active (pressed / selected) state of a host element with full v-model integration. Accepts boolean, forced-on (true) and IActiveState config objects with style overrides. The `prop` argument lets callers bind non-`active` keys (e.g. `modelValue`).

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

Consumed interfaces

IActiveProps
IActiveState

API

Parameters

Input parameters accepted by this composable.

props
required
IActiveProps & Record<string, any>
Component props. Reads `props[prop]` (default: `props.active`).
prop
string
'active'
The prop key to read for the active value. Use "modelValue" for components with a v-model binding.
name
string
getCurrentInstanceName()
Component name prefix for the `{name}--active` class.

API

Return values

Properties and methods exposed by the composable return object.

isActive
Derived active state. True when forced, when the boolean prop is true, or when the internal toggle is on.
activeState
The IActiveState config object when the consumer passed one, undefined otherwise. Consumed by useStateEffect.
activeClasses
Includes `{name}--active` when isActive is true, plus the optional `activeClass` prop value.
onActive
Toggle function. Flips the v-model for boolean props, or the internal toggle for IActiveState config objects.

Usage

Examples

Ready-to-paste usage snippets.

Toggle button with v-model

vue

Forced active with style override

vue