useStateEffect

Commons
stable

Unified composable that consolidates eight visual axes (color, bgColor, border, rounded, elevation, padding, margin, gap) into a single state-aware layer. Reads the hover / active state and their override objects (IHoverState / IActiveState) and emits per-axis classes + styles for each axis. Replaces the prior chain of useColorEffect + useBorder + useRounded + useElevation + usePadding + useMargin that every visual component had to repeat.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

useStateEffect is the recommended replacement for the manual chain useColorEffect + useBorder + useRounded + useElevation + usePadding + useMargin. Priority rule: hover overrides active when both are engaged simultaneously.

Interfaces consommées

IColorProps
IBgColorProps
IBorderProps
IRoundedProps
IElevationProps
IPaddingProps
IMarginProps
IHoverState
IActiveState

API

Paramètres

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

props
requis
TStateEffectProps
Component props implementing all eight axes: IColorProps & IBgColorProps & IBorderProps & IRoundedProps & IElevationProps & IPaddingProps & IMarginProps & { gap? }. Also reads props.status when present to force the matching semantic intent (overrides color/bgColor).
isHover
Ref<boolean> | ComputedRef<boolean>
noopRef
Reactive hover state from useHover. When true, the composable applies the override values from hoverState for each axis.
isActive
Ref<boolean> | ComputedRef<boolean>
noopRef
Reactive active/selected state from useActive. When true (and isHover is false), override values from activeState are applied. Hover takes priority when both are engaged simultaneously.
hoverState
ComputedRef<IHoverState | undefined>
computed(() => undefined)
State config object from useHover. Contains per-axis override values (color, bgColor, border, rounded, elevation, padding, margin, gap) to apply while hovered.
activeState
ComputedRef<IActiveState | undefined>
computed(() => undefined)
State config object from useActive. Same shape as IHoverState — per-axis overrides applied while the item is selected/active.
isDisabled
Ref<boolean> | ComputedRef<boolean>
noopRef
When true, colorClasses is emptied (utility classes suppressed) so the disabled opacity veil is not overridden by a tokenised background.
flat
Ref<boolean> | ComputedRef<boolean>
noopRef
When true, elevationClasses and elevationStyles resolve to empty. Bridges the flat prop of Btn / Card without requiring a separate useElevation call.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

colorClasses / colorStyles
Tokenised intent values emit a utility class (origam--bg-primary); custom CSS colors emit an inline style. Both are empty when disabled/hover/active is true (state-inline path takes over).
borderClasses / borderStyles
Delegated to useBorder with a reactive proxy that swaps to hoverState/activeState.border when the state is engaged.
roundedClasses / roundedStyles
Delegated to useRounded. State-aware: applies hoverState/activeState.rounded when engaged.
elevationClasses / elevationStyles
Delegated to useElevation. Cleared when flat=true. State-aware via the pickEffective resolver.
paddingClasses / paddingStyles
Delegated to usePadding via a reactive getter proxy to preserve dependency tracking across state swaps.
marginClasses / marginStyles
Delegated to useMargin via a reactive getter proxy.
gapClasses / gapStyles
Gap has no dedicated composable. Emits an inline style (gap: Npx or gap: <value>) when a gap override is present. gapClasses is always empty.

Usage

Exemples

Extraits de code prêts à coller.

Card with hover elevation + bg swap

vue

Active nav item with full state override

vue