Scrollbar
Scrollbar is the themed scrollbar primitive used to scroll content such as Text, Canvas, and ttk widgets that support
xview / yview.
It wraps bs.Scrollbar and participates in bootstack styling.
Quick start
With a Text widget
import tkinter as tk
import bootstack as bs
app = bs.App()
frame = bs.Frame(app)
frame.pack(fill="both", expand=True, padx=20, pady=20)
text = tk.Text(frame, wrap="none")
text.grid(row=0, column=0, sticky="nsew")
ys = bs.Scrollbar(frame, orient="vertical", command=text.yview)
ys.grid(row=0, column=1, sticky="ns")
xs = bs.Scrollbar(frame, orient="horizontal", command=text.xview)
xs.grid(row=1, column=0, sticky="ew")
text.configure(xscrollcommand=xs.set, yscrollcommand=ys.set)
frame.rowconfigure(0, weight=1)
frame.columnconfigure(0, weight=1)
app.mainloop()
When to use
Use Scrollbar when:
-
you need explicit scroll control for a widget that supports view commands
-
you're wiring scroll behavior manually (Text, Canvas, custom composites)
Consider a different control when:
-
you want a scrollable container for arbitrary widgets -- use ScrollView
-
you need multi-line text with built-in scrolling -- use ScrolledText
Appearance
Styling
Use accent (or style=) to match your theme:
bs.Scrollbar(app, accent="secondary")
Design System
For theming details and color tokens, see Design System.
Examples & patterns
orient
bs.Scrollbar(app, orient="vertical")
bs.Scrollbar(app, orient="horizontal")
command
Hook to the target widget's view method (xview or yview).
bs.Scrollbar(app, orient="vertical", command=widget.yview)
Behavior
-
Scrollbars are driven by the target widget's view commands.
-
The target widget must also set
xscrollcommand/yscrollcommandto update the scrollbar thumb. -
If you want an out-of-the-box scrollable container, prefer ScrollView or ScrolledText (for text content).
Additional resources
Related widgets
-
ScrollView -- scroll container for arbitrary widgets
-
ScrolledText -- scrollable text control