useColorEffect

Commons
stable

State-aware (hover / active / disabled) color resolution for components that paint a surface. Resolves bg and fg independently per state axis. Auto-contrasts foreground when only `bgColor` is set. Used by Btn, Card, Chip and ~49 other components.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

The bgColor disabled path is intentionally a no-op token-swap: disabled appearance is always an opacity veil on the resting color. This keeps every btn in a row visually consistent — same color family, just dimmed.

Consumed interfaces

IColorProps
IBgColorProps

API

Parameters

Input parameters accepted by this composable.

props
required
IColorProps & IBgColorProps
Component props containing color, bgColor, hoverColor, hoverBgColor, activeColor, activeBgColor.
isHover
Ref<boolean> | ComputedRef<boolean>
ref(false)
Reactive hover state from useHover. When true, resolves the hover color slot (bgHover token rung or -20% darken).
isActive
Ref<boolean> | ComputedRef<boolean>
ref(false)
Reactive active state from useActive. When true, resolves the active color slot (bgActive token rung or -30% darken).
isDisabled
Ref<boolean> | ComputedRef<boolean>
ref(false)
When true, utility classes are suppressed (empty colorClasses). Disabled surfaces are rendered via opacity veil on the resting color, not a token swap.

API

Return values

Properties and methods exposed by the composable return object.

colorClasses
Utility class names for the resting state only. Empty during hover/active/disabled (inline styles take over).
colorStyles
Inline CSS declarations resolving bg and fg for the current state. Includes auto-contrast pairing and gradient clip-text support.
color
The effective foreground color for the current state (resting, hover or active).
bgColor
The effective background color for the current state (resting, hover or active).

Usage

Examples

Ready-to-paste usage snippets.

State-aware surface component

vue