Skip to main content
These modifiers control a component’s surface appearance. opacity sets transparency. foregroundStyle colors text and shape fills (and propagates to descendants), while tint colors interactive controls. background sits behind the component as a color, gradient, material, or another component. cornerRadius, border, and shadow shape and outline the component. They compose in chain order — padding runs before background, so the background extends to cover the padded area.

opacity

Sets the component’s opacity.
value
number
required
The opacity level, from 0 (fully transparent) to 1 (fully opaque).
Unlike .hidden(), a component with .opacity(0) still occupies layout space and remains hittable (responds to tap gestures). Use .allowsHitTesting(false) in combination with .opacity(0) to make it non-interactive. Opacity applies to the entire component subtree, including all children. Semi-transparent component
Fading an image
Animated fade
Disabled appearance

foregroundStyle

Sets the foreground style (text color, shape fill, etc.) for a component and its descendants.
style
Style
required
A Color, gradient (LinearGradient, RadialGradient, etc.), or Material to apply as the foreground style.
Color text
System color
Gradient text
Style a shape
Inherited by descendants

tint

Sets the tint color for interactive controls.
color
Color
required
The tint color to apply to interactive controls such as buttons, toggles, and links.
.tint() affects the accent color of interactive controls, not the text color. Use foregroundStyle to change text or shape fill colors. Tint propagates to child components through the environment. Tinted button
Tinted toggle
Tint a container Apply tint to a parent container to affect all interactive children.

background

Sets the background of a component to a color, gradient, material, or another component.
style
Style
Style background overload: a Color, gradient, or Material to fill the background.
content
Component
required
Component background overload: a component to render behind this component.
props
object
required
Component background with alignment overload.
content
Component
required
A component to render behind this component, positioned according to alignment.
Color background
Gradient background
Material background
Component background
Component background with alignment

cornerRadius

Rounds the corners of a component.
radius
number
required
The corner radius in points.
cornerRadius clips the content at the corners. For more control over the clipping shape, use clipShape with a RoundedRectangle. Round a card
Round an image
Pill shape with large radius

border

Adds a border around a component.
config
{ style: Style; width?: number } | Style | number
The border configuration. Can be:
  • An object with style (a Color or gradient) and optional width
  • A Style value directly (uses default width of 1)
  • A number specifying just the width (uses the foreground style)
Simple color border
Border with custom width
Gradient border
Combined with corner radius

shadow

Adds a drop shadow to a component.
props
object
Basic shadow
Offset shadow
Colored shadow

See also

  • overlay — render a component on top of this one
  • clipShape — clip the component to an arbitrary shape
  • hidden — hide a component and remove it from hit testing
  • Color — color values for foreground, background, and border
  • Material — frosted-glass background materials
  • Alignment — alignment values for component backgrounds