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.
Consumed interfaces
IActiveProps
IActiveState
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIActiveProps & Record<string, any>
- Component props. Reads `props[prop]` (default: `props.active`).
- propstring'active'
- The prop key to read for the active value. Use "modelValue" for components with a v-model binding.
- namestringgetCurrentInstanceName()
- 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
Forced active with style override