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
Signature TypeScript complète extraite du fichier du composable.
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.
Interfaces consommées
IColorProps
IBgColorProps
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsrequisIColorProps & IBgColorProps
- Component props containing color, bgColor, hoverColor, hoverBgColor, activeColor, activeBgColor.
- isHoverRef<boolean> | ComputedRef<boolean>ref(false)
- Reactive hover state from useHover. When true, resolves the hover color slot (bgHover token rung or -20% darken).
- isActiveRef<boolean> | ComputedRef<boolean>ref(false)
- Reactive active state from useActive. When true, resolves the active color slot (bgActive token rung or -30% darken).
- isDisabledRef<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
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- 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
Exemples
Extraits de code prêts à coller.
State-aware surface component