Color / Gradient
Provide colors and gradients for text, background, and stroke. Paint can be a color or a value created by the gradient constructor.
Color
Use color names, hexadecimal colors, or { r, g, b, a } objects. RGB components and opacity range from 0 to 1; clear is transparent. $env.foreground and $env.accent provide ordinary colors that follow the theme.
HDR(color) adds an HDR tag to a color string. Explicit ordinary colors remain SDR: for example, color={$env.foreground} is not enhanced automatically. Use color={HDR($env.foreground)} when you want enhancement. The table below describes omitted colors.
HDR defaults when colors are omitted
When a drawing color is omitted, the following defaults carry HDR tags.
| Content | Omitted color |
|---|---|
| Text, symbols and template images | HDR($env.foreground); a symbol using palette mode with an explicit palette keeps its palette colors. |
| Rectangle, circle, ellipse and bar-chart fills | HDR($env.dark ? 'white' : 'black'). |
| Line, arc, polyline, path and line-chart strokes | HDR($env.dark ? 'white' : 'black'). |
| Chart axes and labels | HDR foreground by default. Explicit chart fills or strokes do not change the labels’ default color. |
| Enabled glow, inner shadow and drop shadow | When the effect’s color is omitted, glow uses HDR white; inner and drop shadows use HDR black. Omitting the effect itself does not enable it. |
Container backgrounds remain transparent. Original images, maps and system materials keep their own colors and rendering. Explicit ordinary colors, gradient stops and symbol palettes are not converted to HDR as a whole; tag each color you want to enhance.
When HDR enhancement applies
An HDR tag does not guarantee brightness. Enhancement requires iOS 26 or later, a supported display, HUD mode and HDR enhancement enabled. The current display environment also affects the result. Ordinary dashboard mode, editor previews and exported PNGs use the standard display range; a preview image cannot demonstrate the brightness of a supported device.
The three lines below respectively omit the color, set an ordinary color explicitly and mark a color as HDR explicitly. They may look the same in a preview; enhancement appears in a supported HUD environment.
function main() {
return (
<VStack spacing={8}>
<Text fontSize={22}>Default HDR</Text>
<Text fontSize={22} color={$env.foreground}>
Explicit SDR
</Text>
<Text fontSize={22} color={HDR($env.accent)}>
Explicit HDR
</Text>
</VStack>
);
}
Gradient
LinearGradient changes along a straight line, RadialGradient spreads out from the center, and AngularGradient changes angularly around the center. When constructing, you can pass a color array or a color array with color and location. Use 0–1 for color patch location and center coordinates, points for radial radius, and degrees for angles.
The created gradient can be passed to background, stroke and other attributes that support Paint. Attributes that only accept Color still need to use single color. The specific available types are subject to the attribute definition.
Example: Background and Stroke Gradient
Linear background, radial fill, angular stroke and HDR text are shown below respectively.
function main() {
return (
<VStack spacing={12}>
<Rectangle
height={48}
background={LinearGradient(['#B9E883', '#30B3A2'], { angle: 30 })}
/>
<Circle
width={100}
height={100}
background={RadialGradient(['white', '#30B3A2'])}
/>
<Circle
width={100}
height={100}
stroke={AngularGradient(['#B9E883', '#30B3A2', '#B9E883'])}
lineWidth={8}
background="clear"
/>
<Text color={HDR('white')}>CapDrive</Text>
</VStack>
);
}
Constructor
HDR(color: string) → HDRColorMark a color for HDR enhancement while preserving its base SDR color.
LinearGradient(colors: GradientColors, options?: LinearGradientOptions) → GradientCreate a gradient paint. Call directly or with new.
RadialGradient(colors: GradientColors, options?: RadialGradientOptions) → GradientCreate a gradient paint. Call directly or with new.
AngularGradient(colors: GradientColors, options?: AngularGradientOptions) → GradientCreate a gradient paint. Call directly or with new.