Skip to main content
.padding(edges?: EdgeSet, length?: number): Component;
.padding(length: number): Component;

Parameters

edges
EdgeSet
default:"all"
The edge(s) to apply padding to. The default is allCan be an array or a single value of Edge
length
number
An amount, given in points, to pad this view on the specified edges. If the value is set to null, a platform-specific default amount will be used. The default value of this parameter is null.

Support

Usage

Default padding (all edges)

Text("Padded text")
    .padding()

Uniform padding with custom length

Text("Custom padding")
    .padding(20)

Specific edge padding

Text("Top padding only")
    .padding("top", 16)

Multiple edges padding

Text("Horizontal padding")
    .padding("horizontal", 24)

Text("Multiple edges")
    .padding(["top", "bottom"], 12)

Examples

Combining multiple padding calls

Text("Layered padding")
    .padding("horizontal", 20)
    .padding("vertical", 10)

Asymmetric padding

Text("Custom layout")
    .padding(["top", "leading"], 16)
    .padding(["bottom", "trailing"], 8)