Expand description
🦀 Soothing pastel theme for Rust.
§Usage
Add Catppuccin to your project’s Cargo.toml
:
$ cargo add catppuccin
§Example
struct Button {
text: String,
background_color: String,
};
fn confirm(text: String) -> Button {
Button {
text,
background_color: catppuccin::PALETTE.mocha.colors.green.hex.to_string(),
}
}
More examples can be found here.
§Optional Features
§ANSI string painting
Enable the ansi-term
feature to add the
Color::ansi_paint
method.
This adds ansi-term as a dependency.
Example: examples/term_grid.rs
§CSS colors
Enable the css-colors
feature to enable the conversion of Catppuccin colors to
[css_colors::RGB
] instances.
This adds css-colors as a dependency.
Example: examples/css.rs
§Ratatui
Enable the ratatui
feature to enable the conversion of Catppuccin colors to
[ratatui::style::Color
] instances.
This adds ratatui as a dependency.
Example: examples/ratatui.rs
§Serde
Enable the serde
feature to enable the serialization of Catppuccin’s palette,
flavor, and color types.
This adds serde as a dependency.
Example: examples/serde.rs
Structs§
- Ansi
Color - A single ANSI color.
- Ansi
Color Iterator - An iterator over the ANSI colors in a flavor.
- Ansi
Color Pair - A pair of ANSI colors - normal and bright.
- Ansi
Color Pairs Iterator - An iterator over the ANSI color pairs in a flavor.
Obtained via
FlavorAnsiColorPairs::into_iter()
orFlavorAnsiColorPairs::iter()
. - Color
- A single color in the Catppuccin palette.
- Color
Iterator - An iterator over colors in a flavor.
Obtained via
Flavor::into_iter()
orFlavorColors::iter()
. - Flavor
- A flavor is a collection of colors. Catppuccin has four flavors; Latte, Frappé, Macchiato, and Mocha.
- Flavor
Ansi Color Pairs - All of the ANSI color pairs for a particular flavor of Catppuccin.
- Flavor
Ansi Colors - All of the ANSI colors for a particular flavor of Catppuccin.
Obtained via
Flavor::ansi_colors
. - Flavor
Colors - All of the colors for a particular flavor of Catppuccin.
Obtained via
Flavor::colors
. - Flavor
Iterator - An iterator over flavors in the palette.
Obtained via
Palette::iter()
. - Hex
- Color represented as 6-digit hexadecimal.
- Hsl
- Color represented as individual hue (0-359), saturation (0-1), and lightness (0-1) channels.
- Palette
- The top-level type that encompasses the Catppuccin palette data structure.
Primarily used via the
PALETTE
constant. - Parse
Color Name Error - Error type for parsing a
ColorName
from a string. - Parse
Flavor Name Error - Error type for parsing a
FlavorName
from a string. - Rgb
- Color represented as individual red, green, and blue channels.
Enums§
- Ansi
Color Name - Enum of all named ANSI colors. Can be used to index into a
FlavorAnsiColors
- Ansi
Color Pair Name - Enum of all ANSI color pairs. Can be used to index into a
FlavorAnsiColorPairs
. - Color
Name - Enum of all named Catppuccin colors. Can be used to index into a
FlavorColors
. - Flavor
Name - Enum of all four flavors of Catppuccin. Can be used to index
Palette
.
Constants§
- PALETTE
- The Catppuccin palette. This constant will generally be your entrypoint into using the crate.