Skip to main content
.monospaced(isActive?: boolean): Component
isActive
boolean
default:"true"
Whether to use the monospaced variant. Pass false to explicitly disable.

Support

Usage

Code-style text

Text("let x = 42").monospaced()

Tabular numbers

Useful for aligning numbers in columns, since each digit takes the same width.
VStack([
    Text("$1,234.56").monospaced(),
    Text("$   99.00").monospaced(),
    Text("$    5.50").monospaced()
])

Conditionally monospaced

const body = () => {
    const [isCode, setIsCode] = useState(false)

    return Text("Hello World")
        .monospaced(isCode)
}

See Also

  • fontDesign — sets the font design (including "monospaced")
  • bold — makes text bold
  • italic — makes text italic