ttkbootstrap#
ttkbootstrap is a themed widget library for tkinter. It has Bootstrap icons built in, so if Bootstrap icons are all you need, you do not need this library at all.
You do need it when you want a different icon set — Material, Lucide, Font Awesome, brand marks — inside a ttkbootstrap application. Everything works, because a ttkbootstrap App is a tkinter.Tk and its widgets are ttk widgets.
Note
These examples target ttkbootstrap 2.0 and later, where ttk.App creates the root window and installs a theme in one step, and the theme is driven from the app rather than through a Style.
The basics#
import ttkbootstrap as ttk
from tkinter_icons import LucideIcon
app = ttk.App(title="Icons", theme="bootstrap-dark")
save = LucideIcon("save", size=16, color="white")
ttk.Button(app, text="Save", image=save.image, compound="left").pack(padx=20, pady=20)
app.mainloop()
That works, and it has a maintenance problem: the color is hard-coded. Switch to a light theme and the icon stays white.
Let the theme pick the color#
Icon.map renders the icon once per widget state in the color that widget’s style already uses, so a success-styled button gets a green icon without you naming green:
import ttkbootstrap as ttk
from tkinter_icons import LucideIcon
app = ttk.App(title="Icons", theme="bootstrap-dark")
icon = LucideIcon("check", size=16)
button = ttk.Button(app, text="Approve", bootstyle="success").pack(padx=20, pady=20)
icon.map(button)
app.mainloop()
The icon now follows the button through hover, pressed, and disabled — and re-renders when the theme changes, because ttkbootstrap emits <<ThemeChanged>> and mapped icons listen for it:
app.theme_use("bootstrap-light") # icons recolor themselves
app.toggle_theme() # or just flip light/dark
See Stateful icons for per-state colors and per-state icon names.
Bootstyle colors#
When you do want to name a color, read it from the theme rather than writing a hex value that only suits one theme:
colors = app.style.colors
LucideIcon("check", size=16, color=colors.success)
LucideIcon("x", size=16, color=colors.danger)
LucideIcon("info", size=16, color=colors.info)
These are the same tokens bootstyle uses, so the icon matches the widget beside it in every theme.
Alongside Bootstrap icons#
Nothing stops you using ttkbootstrap’s built-in Bootstrap icons and a pack from here in the same window. They are separate systems that both end up as Tk images, and each icon here holds its own icon set, so nothing collides.
A common reason to mix: Bootstrap for interface chrome, [simple] for brand marks that no UI set has.
pip install "tkinter-icons[simple]"
from tkinter_icons import SimpleIcon
github = SimpleIcon("github", size=16)
button = ttk.Button(app, text="Sign in with GitHub", compound="left").pack()
github.map(button)
A monochrome brand mark wants the button’s own foreground, so map it rather than naming a color. The accent tokens above are fixed for a family and survive a light/dark switch unchanged, but colors.fg inverts between the two — read once into a constructor, it would leave a near-white mark on a light background.
Which library draws your icon?#
You want |
Use |
Install |
|---|---|---|
Bootstrap icons in ttkbootstrap |
ttkbootstrap’s own |
nothing extra |
Another set in ttkbootstrap |
this library |
|
Any set in plain tkinter |
this library |
|
Migrating from ttkbootstrap-icons#
If you arrived from the old ttkbootstrap-icons package, your imports still work through a shim and the move is two lines. See Migrating from ttkbootstrap-icons.