useColor

Commons
stable

Resolve background and text colors from intent tokens or raw CSS values. Part of the classes-first strategy: tokenised intents emit utility classes, custom hex/rgb values emit inline styles.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

useColor is the low-level building block. Most components should prefer useColorEffect which adds state-aware (hover/active/disabled) resolution.

Interfaces consommées

IBgColorProps
IColorProps

API

Paramètres

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

colors
requis
ComputedRef<{ background?: TColor, text?: TColor }>
A computed ref wrapping both the background and text color values. Either key may be omitted.

API

Valeurs de retour

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

colorClasses
Utility class names to bind via :class. Populated when the value is a tokenised intent (e.g. "primary"). Empty for gradients and raw hex/rgb.
colorStyles
Inline CSS declarations to bind via :style. Populated for gradients, raw CSS colors, and auto-contrast foreground pairing.

Usage

Exemples

Extraits de code prêts à coller.

Basic intent color

vue

Gradient foreground (background-clip: text)

vue