Skip to content

Label

Label displays read-only text or images.

It's a fundamental building block used for headings, captions, instructions, and status text throughout an interface.


Quick start

import bootstack as bs

app = bs.App()

bs.Label(app, text="Hello world").pack(padx=20, pady=20)

app.mainloop()

When to use

Use Label when:

  • displaying static text or images

  • providing context or instructions

  • showing status information that doesn't require user interaction

Consider a different control when...

  • User input is required — use Entry or TextEntry instead

  • You need a compact status indicator — use Badge for high-contrast pill-style labels

  • You need interactive text — use Button for clickable elements


Appearance

Styling with accent

Labels participate fully in bootstack theming:

bs.Label(app, text="Info", accent="info")
bs.Label(app, text="Muted", accent="secondary")
bs.Label(app, text="Warning", accent="warning")

Examples & patterns

Common options

  • text — the text content to display

  • image — an image to display

  • compound — how to combine text and image ("top", "bottom", "left", "right", "center")

  • anchor — where to position content within the label

  • justify — text alignment ("left", "center", "right")

  • wraplength — maximum line width before wrapping

Text alignment

bs.Label(app, text="Left aligned", anchor="w").pack(fill="x")
bs.Label(app, text="Centered", anchor="center").pack(fill="x")
bs.Label(app, text="Right aligned", anchor="e").pack(fill="x")

Image with text

bs.Label(app, text="Status", image=icon, compound="left").pack()

Behavior

Label is a static display widget. It does not respond to user interaction by default, but can be updated programmatically.


Localization

Label supports localization through the localize parameter:

bs.Label(app, text="greeting.hello", localize=True)

Reactivity

Label can be updated dynamically by binding to signals:

message = bs.Signal("Initial text")
label = bs.Label(app, text=message)
message.set("Updated text")  # Label updates automatically

Additional resources

  • Button — interactive clickable element

  • Badge — compact status indicator

  • Tooltip — contextual hover information

Framework concepts

API reference