Parameters
A component to use as the background for this view.
Configuration object for component backgrounds.
Sets the background for this view using colors, gradients, materials, or other components.
.background(style?: Style): Component;
.background(content: Component): Component;
.background(props: { alignment: Alignment }, content: Component): Component;
Show properties
"center", "leading", "trailing", "top", "bottom", "topLeading", "topTrailing", "bottomLeading", or "bottomTrailing".Text("Hello World")
.background(Color("blue"))
Text("Gradient text")
.background(LinearGradient({
colors: [Color("red"), Color("blue")],
startPoint: "topLeading",
endPoint: "bottomTrailing"
}))
Text("Frosted glass effect")
.background(Material("thin"))
Text("Text over rectangle")
.background(Rectangle().fill(Color("gray")))
Text("Aligned background")
.background(
{ alignment: "topLeading" },
Circle().fill(Color("red")).frame(50, 50)
)
Text("Layered backgrounds")
.background(Color("white"))
.background(
RoundedRectangle(10)
.fill(Color("blue").opacity(0.3))
)
VStack([
Text("Angular Gradient")
.background(AngularGradient({
colors: [Color("red"), Color("yellow"), Color("green")],
center: "center"
})),
Text("Radial Gradient")
.background(RadialGradient({
colors: [Color("white"), Color("black")],
center: "center",
startRadius: 0,
endRadius: 100
}))
])
VStack([
Text("Regular Material").background(Material("regular")),
Text("Thin Material").background(Material("thin")),
Text("Thick Material").background(Material("thick")),
Text("Ultra Thin Material").background(Material("ultraThin"))
])