class UIColor
A class that represents a single color value.
class UIColor;
Notes
- Use the constructor with a CSS color string, or reference a preset using UIColor.getColor.
- Use instance methods like alpha(), brighten(), and mix() to create derived colors.
- The output() method returns a UIColor.Output with structured color values.
Description
Instances can be used with style properties and UI element color properties. Named colors are available through UI.colors and can be customized using setColors() or the global theme (e.g. WebTheme).
Examples
// Create colors directly
new UIColor("#000")
new UIColor("rgba(0,0,0,0.5)")
UIColor.oklch(0.5, 0.15, 240)
// Use preset colors
UI.colors.black
UI.colors.green.alpha(0.5)
UI.colors.accent.text()
// Create gradients
UIColor.linearGradient(180, UI.colors.blue, UI.colors.green)
UIColor.radialGradient(UI.colors.white, UI.colors.black)
// Create mapped background values
UIColor.mappedValue("background", bg =>
UIColor.isBrightColor(bg as UIColor)
? UI.colors.white
: UIColor.linearGradient(180, darkGray, black)
)
Constructor
new UIColor()
Creates a new UIColor instance.
Type members
interface UIColor.Output static
An interface that represents the output of a resolved UIColor.type UIColor.ColorName static
A type that represents color names, supporting both standard names and custom strings.type UIColor.BackgroundType static
A type that represents any valid background value: a UIColor, UIColor.Gradient, UIColor.MappedValue, or a color name string.class Gradient static
A class that represents a color gradient.class MappedValue static
A class that represents a derived color or gradient value.
Static members
UIColor.setColors() static
Sets colors in the global color registry.UIColor.getColor() static
Returns a color reference by name.UIColor.oklch() static
Creates a UIColor from OKLCH values directly.UIColor.rgb() static
Creates a UIColor from sRGB values, converting to OKLCH internally.UIColor.isBrightColor() static
Determines whether a color has high perceived brightness.UIColor.linearGradient() static
Creates a linear gradient.UIColor.radialGradient() static
Creates a radial gradient (center outward).UIColor.conicGradient() static
Creates a conic gradient (sweep around center).UIColor.mappedValue() static
Creates a lazily-evaluated mapped color or gradient value.UIColor.defaults static
An object containing all standard color references.UIColor.lightTextColor static
The light text color reference, typically white.UIColor.darkTextColor static
The dark text color reference, typically black.
Instance members
output()
Returns a UIColor.Output with structured color values.alpha()
Returns a new UIColor with increased transparency.brighten()
Returns a new UIColor with adjusted brightness.contrast()
Returns a new UIColor with adjusted contrast relative to mid-grey.map()
Returns a new UIColor derived from this color.text()
Returns a new UIColor for a contrasting text color.mix()
Returns a new UIColor mixed with the specified color.
