These two modifiers—foregroundStyle and background—allow you to customize the visual styling of view content and its background, supporting a wide range of styles including solid colors, gradients, materials, and dynamic appearances for light/dark mode.
foregroundStyleSets the style of a view’s foreground content, such as the color of text, shapes, or symbols. You can pass a single style or a layered style object (primary, secondary, tertiary) to support multi-layered rendering, such as in SF Symbols or decorated text.
Use layered styles primarily with views that support multistage rendering like system icons or stylized text.
backgroundSets the background of a view. You can apply simple colors or gradients, or supply a custom shape or view as the background.
RoundedRectangle) with a style applied to it.ShapeStyle
A visual style that defines how a foreground or background is rendered—this can be a color, gradient, or material. Supports "red", "systemBlue", "#FF0000", rgba(...), and gradient definitions.
DynamicShapeStyle
A light/dark mode–aware style with separate definitions for each appearance. The system automatically applies the appropriate style based on the current UI mode.
VirtualNode
A component used as a background, such as <Image />, <RoundedRectangle />, or any view that returns a JSX.Element.
Shape
A predefined shape such as RoundedRectangle, Circle, or Capsule, used for styled background shapes.
| Property | Purpose | Value Types |
|---|---|---|
foregroundStyle |
Styles text/icons/foreground shapes | ShapeStyle, DynamicShapeStyle, layered object |
background |
Renders a styled background | ShapeStyle, DynamicShapeStyle, shape + style, view |
These properties give you fine-grained control over visual styling and are essential for building rich, adaptive interfaces in the Scripting app.