Catppuccin Palette

repository·main·Indexed 20 days ago

https://github.com/catppuccin/palette

Programmatic access to the Catppuccin color scheme. Provides color data (hex, RGB, ANSI) for various flavors via Node.js, Deno, CSS custom properties, and Sass. Includes support for graphics editors like Adobe Suite, Affinity Suite, Gimp, and Procreate.

Tokens
2.2K
Snippets
7
Records
8
Agent score
71%

What's inside @catppuccin/palette

  1. Import all Catppuccin flavors using the single-map file

    main

    To access all four flavors at once, import _catppuccin.scss. This provides a $palette map containing all flavor color maps. You can iterate over this map using Sass @each loops to generate styles for every flavor.

    Important: When retrieving colors from the map using map.get, you must wrap the color name in quotes (e.g., 'blue' instead of blue). This prevents Sass from confusing color names with predefined CSS web-safe colors.

    If using the @catppuccin/palette npm package, use the path: @catppuccin/palette/scss/catppuccin.

    @use "sass:map";
    @use "catppuccin";
    // or via npm:
    // @use "~@catppuccin/palette/scss/catppuccin";
    
    @each $flavor, $color in catppuccin.$palette {
        .my-#{$flavor}-class {
            // wrap color names in quotes to ensure proper generation
            background: #{map.get($color, 'base')};
            color: #{map.get($color, 'blue')};
        }
    }
  2. Import Catppuccin palettes for CSS

    main

    You can integrate Catppuccin color palettes into your CSS projects using NPM (with a CSS loader) or via a CDN.

    Using NPM

    If you have the @catppuccin/palette package installed via NPM and a CSS loader configured, use:

    @import "@catppuccin/palette/style";

    Using a CDN

    Alternatively, you can import the palette directly from a CDN:

    jsdelivr:

    @import url('https://cdn.jsdelivr.net/npm/@catppuccin/palette/css/catppuccin.css');

    unpkg:

    @import url('https://unpkg.com/@catppuccin/palette/css/catppuccin.css');
    /* if you have it installed via NPM & a CSS loader configured */
    @import "@catppuccin/palette/style";
    
    /* alternatively via jsdelivr */
    @import url('https://cdn.jsdelivr.net/npm/@catppuccin/palette/css/catppuccin.css');
    
    /* alternatively via unpkg */
    @import url('https://unpkg.com/@catppuccin/palette/css/catppuccin.css');
  3. Access Catppuccin palette for graphics editors

    main

    For graphics software, download the specific color files from the latest GitHub Release. The files are organized by directory based on the target program:

    ProgramsDirectory
    Adobe Suite, Affinity Suite, Sipase/
    Aseprite, Gimp, Inkscape, Kritagimp/
    Procreateprocreate/
    Apple Color List (.clr)clr/
  4. Import a single Catppuccin flavor in Sass

    main

    To use a specific flavor (latte, frappe, macchiato, or mocha) without loading the entire palette, import its corresponding SCSS file directly. This provides access to the color variables defined for that flavor (e.g., $base, $text).

    If using the @catppuccin/palette npm package, use the path: @catppuccin/palette/scss/catppuccin/[flavor].

    @use "mocha";
    // or via npm:
    // @use "~@catppuccin/palette/scss/catppuccin/mocha";
    
    .my-mocha-class {
        background: $base;
        color: $text;
    }
  5. Use Catppuccin color variables in CSS

    main

    Once the palette is imported, you can use Catppuccin colors via CSS custom properties (variables). The variables follow a naming convention that allows for direct color usage, as well as RGB and HSL formats for advanced styling like transparency.

    Usage Patterns

    • Direct Color: Use var(--ctp-[flavor]-[color]) for standard hex colors.
    • RGB with Alpha: Use var(--ctp-[flavor]-[color]-rgb) inside rgba() to apply opacity.
    • HSL with Alpha: Use var(--ctp-[flavor]-[color]-hsl) inside hsla() to apply opacity.

    Note: Replace [flavor] with one of the Catppuccin flavors (e.g., mocha, macchiato, frappe, latte) and [color] with the desired color name (e.g., text, base, red).

    .my-div {
      color:        var(--ctp-mocha-text);
      background:   rgba(var(--ctp-macchiato-base-rgb) / 0.9);
      border-color: hsla(var(--ctp-frappe-red-hsl) / 0.75);
    }
  6. Use @catppuccin/palette in Node.js

    main

    Import flavors, flavorEntries, and version from @catppuccin/palette.

    • version: A string containing the library version.
    • flavors: An object containing all Catppuccin flavors.
    • flavorEntries: A typed helper for iterating through flavors. Each entry provides access to the flavor's name, theme type (dark/light), colorEntries (hex, rgb, and accent information), and ansiColorEntries (normal and bright ANSI codes).
    import { flavors, flavorEntries, version } from "@catppuccin/palette";
    import chalk from "chalk";
    
    // a string containing the version of the library
    console.log(version);
    
    // an object containing all catppuccin flavors
    console.log(flavors);
    
    // typed helper when iterating flavors
    flavorEntries.map(([_, flavor]) => {
      console.log(`${flavor.name} is a ${flavor.dark ? "dark" : "light"} theme.`);
      console.log(`It has ${flavor.colorEntries.length} colors:`);
    
      // same for the colors
      flavor.colorEntries.map(([colorName, { hex, rgb, accent }]) => {
        console.log(
          chalk.bgRgb(rgb.r, rgb.b, rgb.g)(` ${hex} `),
          colorName,
          accent
        );
      });
      console.log("\n");
    
      // same for the ansi colors
      flavor.ansiColorEntries.map(([colorName, ansi]) => {
        console.log(
          chalk.hex(ansi.normal.hex)(`[${ansi.normal.code}] Normal ${colorName}`)
        );
        console.log(
          chalk.hex(ansi.bright.hex)(`[${ansi.bright.code}] Bright ${colorName}`)
        );
      });
    });
  7. Use @catppuccin/palette in Deno

    main

    In Deno, you can import the library via deno.land/x/catppuccin/mod.ts or through JSR. The exported members flavors, flavorEntries, and version function similarly to the Node.js version.

    import {
      flavors,
      flavorEntries,
      version,
    } from "https://deno.land/x/catppuccin/mod.ts";
    import { bgRgb24 } from "https://deno.land/std/fmt/colors.ts";
    
    // a string containing the version of the library
    console.log(version);
    
    // an object containing all catppuccin flavors
    console.log(flavors);
    
    // typed helper when iterating flavors
    flavorEntries.map(([_, flavor]) => {
      console.log(`${flavor.name} is a ${flavor.dark ? "dark" : "light"} theme.`);
      console.log(`It has ${flavor.colorEntries.length} colors:`);
    
      // same for the colors
      flavor.colorEntries.map(([colorName, { hex, rgb, accent }]) => {
        console.log(bgRgb24(`  ${hex}  `, { ...rgb }), colorName, accent);
      });
      console.log("\n");
    });