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

Full TypeScript signature sourced from the composable file.

typescript

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

Consumed interfaces

IBgColorProps
IColorProps

API

Parameters

Input parameters accepted by this composable.

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

API

Return values

Properties and methods exposed by the composable return object.

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

Examples

Ready-to-paste usage snippets.

Basic intent color

vue

Gradient foreground (background-clip: text)

vue