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...
-
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")
Design System
See Design System for color tokens and theming guidelines.
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)
Localization
See Localization for translation setup.
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
Signals
See Signals for reactive programming patterns.
Additional resources
Related widgets
-
Button — interactive clickable element
-
Badge — compact status indicator
-
Tooltip — contextual hover information
Framework concepts
-
Design System — colors, typography, and theming
-
Signals — reactive data binding
-
Localization — translation support