Copy
Capsule(): Shape;
Support
Usage
Basic capsule
Copy
Capsule()
.fill(Color("blue"))
.frame({ width: 100, height: 50 })
Capsule button style
Copy
Capsule()
.fill(Color("blue"))
.frame({ width: 120, height: 40 })
.overlay(
Text("Button")
.foregroundStyle(Color("white"))
.bold()
)
Progress bar style
Copy
ZStack({ alignment: "leading" }, [
Capsule()
.fill(Color("gray").opacity(0.3))
.frame({ width: 200, height: 8 }),
Capsule()
.fill(Color("green"))
.frame({ width: 120, height: 8 })
])
Capsule with stroke
Copy
Capsule()
.stroke({ style: Color("purple"), lineWidth: 3 })
.frame({ width: 150, height: 60 })
Pill-shaped badge
Copy
Capsule()
.fill(Color("orange"))
.frame({ width: 50, height: 20 })
.overlay(
Text("New")
.font("caption")
.foregroundStyle(Color("white"))
)
