# Icons and fonts

> Use about 2000 bundled Lucide icons and file-type icons in Python desktop GUIs with Pyzed, and load your own fonts such as IBM Plex.

Source: https://albakore.github.io/pyzed/theming/icons-fonts/

## Icons

Pyzed bundles the [Lucide](https://lucide.dev) icon font (~2000 icons, ISC license). Icons are drawn as text, so they
are sharp at any size and take any color:

```python
pz.icon("folder", size=16, color="#74ade8")
ui.button("Open", self.open, icon="folder-open")
ui.list_item("Settings", self.settings, icon="settings")
```

Without a `color`, `pz.icon` takes the color of the surrounding text. Icons inside `pyzed.ui` components use the
theme's `icon` and `icon_muted` [tokens](https://albakore.github.io/pyzed/theming/tokens/#text-icons-and-accent), so they follow the theme.

Look up names at [lucide.dev/icons](https://lucide.dev/icons) or from the terminal:

**uv:**

```bash
uv run pyzed icons git
# git-branch, git-commit-horizontal, git-compare, git-fork, git-merge, git-pull-request, ...
```

**pip:**

```bash title="macOS and Linux"
pyzed icons git          # or: python3 -m pyzed icons git
```

```powershell title="Windows (PowerShell)"
pyzed icons git          # or: py -m pyzed icons git
```

`pyzed.icons.names()` returns the full list and `pyzed.icons.glyph("folder")` the character,
to mix it with text using `font="icons"`.

### Searching and picking icons

`icons.search` finds icons by name and by Lucide's tags, best first, and `icons.category` groups them for browsing:

```python
from pyzed import icons

icons.search("person")      # ["person-standing", "user", "contact", ...]
icons.category("arrows")    # every arrow, chevron, undo...
```

To let the user choose one, use [`ui.IconPicker`](https://albakore.github.io/pyzed/library/icon-picker/), or `ui.icon_picker_dialog` in a
`ui.dialog_layer`: a search box, categories and a grid of every icon.

### File-type icons

```python
from pyzed import icons

icons.for_file("main.rs")       # ("file-code", "#dea584")
icons.for_file("Cargo.toml")    # ("file-cog", "#9c4221")
icons.language_for("main.py")   # "Python"
```

`ui.Tab.for_file` and `ui.tree` already use them.

## Fonts

Bundled fonts:

| Name | Font |
| --- | --- |
| `"sans"` (default) | IBM Plex Sans |
| `"mono"` | IBM Plex Mono |
| `"icons"` | Lucide |

`"serif"` uses the system's serif font. Choose a font for one text, for a block (every text inside inherits it) or
for the whole window:

```python
pz.text("fn main() {}").style(font="mono")                  # one text
pz.column([...]).style(font="serif", size=15)                # every text inside
class MyApp(pz.App):
    style = pz.Style(font="mono")                           # the whole window
```

### Your own fonts

Load a `.ttf` or `.otf` file before running the app and refer to it by its **family name** (the name the font
declares, not the file name):

```python
pz.load_font("fonts/JetBrainsMono-Regular.ttf")

pz.text("fn main() {}", font="JetBrains Mono")
pz.code_editor("buf", text, font="JetBrains Mono")
```

`load_font` also accepts the file's `bytes`. Load each weight you use (Regular, Bold...) as its own file.

**Fonts in a packaged app:**

Keep font files in your project (for example `assets/fonts/`), add the folder to `include` in
`[tool.pyzed.build]`, and resolve the path from the bundle as shown in
[Build and distribute](https://albakore.github.io/pyzed/packaging/build/#options), so the packaged app finds them.

**Licenses:**

Check that a font's license allows embedding it in an app you distribute. IBM Plex and Lucide, which Pyzed bundles,
do (SIL Open Font License and ISC).
