rawBgExprWithState
Commons
stable
Apply a hover or active darkening effect to a raw CSS colour value by wrapping it in a color-mix() expression. Passes through unchanged for the default and disabled roles.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- rawrequiredstring
- A raw CSS colour value (hex, rgb, hsl, or CSS custom property expression) to apply the state modification to.
- rolerequiredTBgFgRole
- The interaction state role: "default" and "disabled" return the raw value unchanged; "hover" and "active" wrap it in color-mix(in srgb, raw, black N%).
API
Return value
The value returned by this util.
- The original colour string for default/disabled roles, or a color-mix() expression with a black blend for hover/active states.
Usage
Examples
Ready-to-paste usage snippets.
Generate hover and active colour expressions