useStateEffect
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
Full TypeScript signature sourced from the composable file.
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.
Consumed interfaces
API
Parameters
Input parameters accepted by this composable.
- propsrequiredTStateEffectProps
- 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).
- isHoverRef<boolean> | ComputedRef<boolean>noopRef
- Reactive hover state from useHover. When true, the composable applies the override values from hoverState for each axis.
- isActiveRef<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.
- hoverStateComputedRef<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.
- activeStateComputedRef<IActiveState | undefined>computed(() => undefined)
- State config object from useActive. Same shape as IHoverState — per-axis overrides applied while the item is selected/active.
- isDisabledRef<boolean> | ComputedRef<boolean>noopRef
- When true, colorClasses is emptied (utility classes suppressed) so the disabled opacity veil is not overridden by a tokenised background.
- flatRef<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
Return values
Properties and methods exposed by the composable return object.
- 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
Examples
Ready-to-paste usage snippets.
Card with hover elevation + bg swap
Active nav item with full state override