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.The opacity level, from
0 (fully transparent) to 1 (fully opaque)..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
foregroundStyle
Sets the foreground style (text color, shape fill, etc.) for a component and its descendants.A Color, gradient (LinearGradient, RadialGradient, etc.), or Material to apply as the foreground style.
tint
Sets the tint color for interactive controls.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
background
Sets the background of a component to a color, gradient, material, or another component.Component background overload: a component to render behind this component.
Component background with alignment overload.
A component to render behind this component, positioned according to
alignment.cornerRadius
Rounds the corners of a component.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
border
Adds a border around a component.shadow
Adds a drop shadow to a component.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