Skip to main content
.padding(length: number): Component
.padding(edges?: EdgeSet, length?: number): Component
length
number
The padding amount in points. When called with a single number, applies equal padding on all edges.
edges
EdgeSet
Which edges to apply padding to. See EdgeSet. When omitted, padding is applied to all edges.

Support

Usage

Uniform padding

Text("Hello")
    .padding(16)

Edge-specific padding

Text("Horizontal only")
    .padding("horizontal", 20)

Vertical padding

Text("Vertical spacing")
    .padding("vertical", 12)

Single edge

Text("Bottom only")
    .padding("bottom", 24)

Combined with background

Padding is applied before the background, so the background extends to cover the padded area.
Text("Padded card")
    .padding(16)
    .background(Color("blue"))
    .cornerRadius(12)