catppuccin
🐍 Soothing pastel theme for Python.
Basic Usage
Get access to the palette with the catppuccin.PALETTE constant:
from catppuccin import PALETTE
PALETTE.latte.colors.mauve.hex
# '#8839ef'
PALETTE.mocha.colors.teal.rgb
# RGB(r=148, g=226, b=213)
The Palette data structure matches the palette
JSON.
Iteration
Both Palette and FlavorColors can be iterated to yield flavors and colors
respectively:
for flavor in PALETTE:
print(flavor.name)
# Latte
# Frappé
# Macchiato
# Mocha
for color in PALETTE.latte.colors:
print(f"{color.name}: {color.hex}")
# Rosewater: #f2d5cf
# Flamingo: #eebebe
# Pink: #f4b8e4
# ...
# Base: #303446
# Mantle: #292c3c
# Crust: #232634
Dataclasses
Palette, Flavor, Color et cetera are all
dataclasses,
so you can also inspect and iterate their fields using methods from the
dataclass module.
For example, to list all color names and their hex codes:
from dataclasses import fields
from catppuccin import PALETTE
flavor = PALETTE.frappe
for field in fields(flavor.colors):
color = getattr(flavor.colors, field.name)
print(f"{field.name}: {color.hex}")
# rosewater: #f2d5cf
# flamingo: #eebebe
# pink: #f4b8e4
# ...
# base: #303446
# mantle: #292c3c
# crust: #232634
Types
This package is fully type annotated with data structures located in the models module.
Integrations
This package includes optional support for several libraries. Click a link below to see the documentation for that integration.
1"""🐍 Soothing pastel theme for Python. 2 3## Basic Usage 4 5Get access to the palette with the `catppuccin.PALETTE` constant: 6 7```python 8from catppuccin import PALETTE 9 10PALETTE.latte.colors.mauve.hex 11# '#8839ef' 12PALETTE.mocha.colors.teal.rgb 13# RGB(r=148, g=226, b=213) 14``` 15 16The `Palette` data structure matches [the palette 17JSON](https://github.com/catppuccin/palette/blob/main/palette.json). 18 19## Iteration 20 21Both `Palette` and `FlavorColors` can be iterated to yield flavors and colors 22respectively: 23 24```python 25for flavor in PALETTE: 26 print(flavor.name) 27 28# Latte 29# Frappé 30# Macchiato 31# Mocha 32 33for color in PALETTE.latte.colors: 34 print(f"{color.name}: {color.hex}") 35 36# Rosewater: #f2d5cf 37# Flamingo: #eebebe 38# Pink: #f4b8e4 39# ... 40# Base: #303446 41# Mantle: #292c3c 42# Crust: #232634 43``` 44 45## Dataclasses 46 47`Palette`, `Flavor`, `Color` et cetera are all 48[`dataclasses`](https://docs.python.org/3/library/dataclasses.html), 49so you can also inspect and iterate their fields using methods from the 50dataclass module. 51 52For example, to list all color names and their hex codes: 53 54```python 55from dataclasses import fields 56from catppuccin import PALETTE 57 58flavor = PALETTE.frappe 59for field in fields(flavor.colors): 60 color = getattr(flavor.colors, field.name) 61 print(f"{field.name}: {color.hex}") 62 63# rosewater: #f2d5cf 64# flamingo: #eebebe 65# pink: #f4b8e4 66# ... 67# base: #303446 68# mantle: #292c3c 69# crust: #232634 70``` 71 72## Types 73 74This package is fully type annotated with data structures located in [the models 75module](./catppuccin/models.html). 76 77## Integrations 78 79This package includes optional support for several libraries. Click a link below 80to see the documentation for that integration. 81 82- [matplotlib](./catppuccin/extras/matplotlib.html) 83- [pygments](./catppuccin/extras/pygments.html) 84- [rich](./catppuccin/extras/rich_ctp.html) 85 86""" 87 88import importlib.util 89 90from catppuccin.palette import PALETTE as PALETTE 91 92# Attempt to register styles and colormaps if matplotlib is available 93if importlib.util.find_spec("matplotlib") is not None: 94 from catppuccin.extras.matplotlib import _register_colormap_list, _register_styles 95 96 _register_styles() 97 _register_colormap_list()