### Install Catppuccin Palette for Node.js Source: https://github.com/catppuccin/palette/blob/main/README.md Install the library using npm. This is the first step to using the Catppuccin palettes in your Node.js project. ```bash npm install @catppuccin/palette ``` -------------------------------- ### Accessing Catppuccin Flavors and Colors Source: https://context7.com/catppuccin/palette/llms.txt Demonstrates how to import and access specific Catppuccin flavors and their colors in various formats. Ensure the library is installed via npm or available in your Deno environment. ```typescript import { flavors } from "@catppuccin/palette"; // Access a flavor directly const mocha = flavors.mocha; console.log(mocha.name); // "Mocha" console.log(mocha.emoji); // "🌿" console.log(mocha.dark); // true console.log(mocha.order); // 3 // Access a specific color in all formats const blue = mocha.colors.blue; console.log(blue.hex); // "#89b4fa" console.log(blue.rgb); // { r: 137, g: 180, b: 250 } console.log(blue.hsl); // { h: 217.17, s: 0.9187, l: 0.7588 } console.log(blue.oklch); // { l: 0.7664, c: 0.1113, h: 259.88 } console.log(blue.accent); // true console.log(blue.order); // 12 // Check the light flavor (Latte) const latte = flavors.latte; console.log(latte.dark); // false console.log(latte.colors.base.hex); // "#eff1f5" console.log(latte.colors.text.hex); // "#4c4f69" ``` -------------------------------- ### Working with Color Formats and Generating CSS Source: https://context7.com/catppuccin/palette/llms.txt Illustrates how to access color values in hex, RGB, HSL, and oklch formats from a Catppuccin flavor and how to use these values to generate CSS strings. Requires the library to be installed. ```typescript import { flavors } from "@catppuccin/palette"; const { colors } = flavors.macchiato; // hex (string, e.g. "#c6a0f6") const hexValue: string = colors.mauve.hex; // rgb (r/g/b each 0–255) const { r, g, b } = colors.mauve.rgb; // { r: 198, g: 160, b: 246 } // hsl (h: 0–360, s/l: 0–1) const { h, s, l } = colors.mauve.hsl; // { h: 266.51, s: 0.827, l: 0.796 } // oklch (l: 0–1, c: 0–0.4, h: 0–360) const ok = colors.mauve.oklch; // { l: 0.7715, c: 0.1259, h: 303.90 } // Generate a CSS rgba() value from rgb const cssRgba = `rgba(${r}, ${g}, ${b}, 0.85)`; // "rgba(198, 160, 246, 0.85)" // Generate a CSS oklch() value const cssOklch = `oklch(${ok.l.toFixed(4)} ${ok.c.toFixed(4)} ${ok.h.toFixed(2)})`; // "oklch(0.7715 0.1259 303.90)" ``` -------------------------------- ### Import Catppuccin Palettes in CSS Source: https://github.com/catppuccin/palette/blob/main/docs/css.md Demonstrates various methods to import the Catppuccin CSS palette. Choose the method that best suits your project setup, whether using NPM, jsDelivr, or unpkg. ```css @import "@catppuccin/palette/style"; ``` ```css @import url('https://cdn.jsdelivr.net/npm/@catppuccin/palette/css/catppuccin.css'); ``` ```css @import url('https://unpkg.com/@catppuccin/palette/css/catppuccin.css'); ``` -------------------------------- ### Iterating Over Catppuccin Flavors and Colors Source: https://context7.com/catppuccin/palette/llms.txt Utilizes `flavorEntries` for type-safe iteration over all Catppuccin flavors and their colors. This is useful for generating dynamic UIs or configurations. Ensure the library is installed. ```typescript import { flavorEntries } from "@catppuccin/palette"; // Print a summary of every flavor and its colors flavorEntries.forEach(([flavorName, flavor]) => { console.log(`\n=== ${flavor.name} ${flavor.emoji} (dark: ${flavor.dark}) ===`); // Iterate accent colors only flavor.colorEntries .filter(([, color]) => color.accent) .forEach(([colorName, color]) => { console.log(` ${colorName.padEnd(12)} hex=${color.hex} rgb(${color.rgb.r},${color.rgb.g},${color.rgb.b})`); }); }); // Expected output (excerpt): // === Latte 🌻 (dark: false) === // rosewater hex=#dc8a78 rgb(220,138,120) // flamingo hex=#dd7878 rgb(221,120,120) // ... // === Mocha 🌿 (dark: true) === // rosewater hex=#f5e0dc rgb(245,224,220) // ... ``` -------------------------------- ### Getting the Catppuccin Palette Library Version Source: https://context7.com/catppuccin/palette/llms.txt Retrieves the current specification version of the Catppuccin palette library. This is useful for version checking, cache busting, or runtime validation. Ensure the library is installed. ```typescript import { version } from "@catppuccin/palette"; console.log(version); // "1.8.0" // Example: guard against an outdated palette at runtime const REQUIRED_VERSION = "1.8.0"; if (version !== REQUIRED_VERSION) { throw new Error(`Expected palette v${REQUIRED_VERSION}, got v${version}`); } ``` -------------------------------- ### Getting the Library Version with `version` Source: https://context7.com/catppuccin/palette/llms.txt The `version` export provides a string representing the current specification version of the Catppuccin palette library. This is useful for logging, debugging, or implementing version checks. ```APIDOC ## `version` β€” Library version string A plain string containing the current Catppuccin palette spec version, useful for cache-busting, logging, or confirming the data revision in use. ```ts import { version } from "@catppuccin/palette"; console.log(version); // "1.8.0" // Example: guard against an outdated palette at runtime const REQUIRED_VERSION = "1.8.0"; if (version !== REQUIRED_VERSION) { throw new Error(`Expected palette v${REQUIRED_VERSION}, got v${version}`); } ``` ``` -------------------------------- ### Import from JSR and Deno.land/x Source: https://context7.com/catppuccin/palette/llms.txt Import palette data using the recommended JSR package for Deno or the legacy deno.land/x import. Ensure Deno's file permissions are set if needed. ```typescript // JSR (recommended for Deno) import { flavors, flavorEntries, version } from "jsr:@catppuccin/palette"; // deno.land/x (legacy) import { flavors, flavorEntries, version } from "https://deno.land/x/catppuccin/mod.ts"; import { bgRgb24, bold } from "https://deno.land/std/fmt/colors.ts"; console.log(`Catppuccin palette v${version}`); // Render a color swatch for each flavor using terminal RGB colors flavorEntries.forEach(([, flavor]) => { console.log(` ${flavor.name} ${flavor.emoji}`); flavor.colorEntries.forEach(([colorName, { rgb, hex, accent }]) => { const label = ` ${hex} ${colorName.padEnd(12)} ${accent ? "accent" : " "} `; console.log(bgRgb24(bold(label), rgb)); }); }); ``` -------------------------------- ### Import Single SCSS Flavor Source: https://context7.com/catppuccin/palette/llms.txt Import SCSS variables for a specific Catppuccin flavor. Ensure the path to the SCSS files is correctly aliased or relative. ```scss /* --- Single flavor import --- */ @use "~@catppuccin/palette/scss/catppuccin/mocha"; .button-primary { background-color: $blue; /* #89b4fa */ color: $base; /* #1e1e2e */ &:hover { background-color: $sapphire; /* #74c7ec */ } } ``` -------------------------------- ### Use Catppuccin Palette in Node.js Source: https://github.com/catppuccin/palette/blob/main/README.md Import and utilize Catppuccin flavors and colors in your Node.js application. Requires chalk for colored output. ```typescript 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}`) ); }); }); ``` -------------------------------- ### Using Catppuccin CSS Custom Properties Source: https://context7.com/catppuccin/palette/llms.txt Shows how to import and use the pre-built Catppuccin CSS stylesheet, which declares color variables as CSS custom properties. The stylesheet is available at `@catppuccin/palette/css/catppuccin.css`. ```css /* Installation */ /* npm install @catppuccin/palette */ /* Import via bundler / CSS loader */ @import "@catppuccin/palette/style"; /* Or via CDN */ @import url('https://cdn.jsdelivr.net/npm/@catppuccin/palette/css/catppuccin.css'); /* --- Variable naming convention --- --ctp-{flavor}-{color} hex value --ctp-{flavor}-{color}-rgb "R G B" (space-separated for modern CSS) --ctp-{flavor}-{color}-hsl "H S% L%" --ctp-{flavor}-{color}-oklch "L C H" */ .card { /* Use hex directly */ color: var(--ctp-mocha-text); background-color: var(--ctp-mocha-base); border-color: var(--ctp-mocha-surface0); } .card--transparent { /* Use RGB triple for rgba() with alpha */ background: rgba(var(--ctp-macchiato-base-rgb) / 0.85); } .badge--warning { /* Use HSL triple for hsla() with alpha */ background: hsla(var(--ctp-frappe-yellow-hsl) / 0.6); } .highlight { /* Use oklch for perceptually uniform color manipulation */ color: oklch(var(--ctp-mocha-mauve-oklch)); } ``` -------------------------------- ### Iterating Flavors with `flavorEntries` Source: https://context7.com/catppuccin/palette/llms.txt The `flavorEntries` export provides a typed iterable, similar to `Object.entries`, for easily looping through all available Catppuccin flavors and their associated colors. This is useful for dynamic processing or generating configurations. ```APIDOC ## `flavorEntries` β€” Typed iterable over all flavors A `[FlavorName, CatppuccinFlavor][]` array produced by a typed `Object.entries` helper, designed for clean iteration with full TypeScript inference over both flavor names and color names. ```ts import { flavorEntries } from "@catppuccin/palette"; // Print a summary of every flavor and its colors flavorEntries.forEach(([flavorName, flavor]) => { console.log(`\n=== ${flavor.name} ${flavor.emoji} (dark: ${flavor.dark}) ===`); // Iterate accent colors only flavor.colorEntries .filter(([, color]) => color.accent) .forEach(([colorName, color]) => { console.log(` ${colorName.padEnd(12)} hex=${color.hex} rgb(${color.rgb.r},${color.rgb.g},${color.rgb.b})`); }); }); // Expected output (excerpt): // === Latte 🌻 (dark: false) === // rosewater hex=#dc8a78 rgb(220,138,120) // flamingo hex=#dd7878 rgb(221,120,120) // ... // === Mocha 🌿 (dark: true) === // rosewater hex=#f5e0dc rgb(245,224,220) // ... ``` ``` -------------------------------- ### Import All Sass Flavors from Single Map Source: https://github.com/catppuccin/palette/blob/main/docs/sass.md Import all four Catppuccin flavors from a single Sass file using `_catppuccin.scss`. Note that web-safe colors must be explicitly cast as strings to ensure proper generation. ```scss @use "sass:map"; @use "catppuccin"; // sass is also part of the npm package: // @use "~@catppuccin/palette/scss/catppuccin"; @each $flavor, $color in catppuccin.$palette { .my-#{$flavor}-class { // you need surround the catppuccin color names with quotes background: #{map.get($color, 'base')}; color: #{map.get($color, 'blue')}; } } ``` ```css .my-mocha-class { background: #1e1e2e; color: #cdd6f4; } .my-macchiato-class { background: #24273a; color: #cad3f5; } .my-frappe-class { background: #303446; color: #c6d0f5; } .my-latte-class { background: #eff1f5; color: #4c4f69; } ``` -------------------------------- ### Use Catppuccin Palette in Deno Source: https://github.com/catppuccin/palette/blob/main/README.md Import and utilize Catppuccin flavors and colors in your Deno application. Uses Deno's built-in color formatting. ```typescript 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"); }); ``` -------------------------------- ### Use Catppuccin Colors in CSS Source: https://github.com/catppuccin/palette/blob/main/docs/css.md Shows how to apply Catppuccin color variables to CSS properties like color, background, and border. Supports direct color values, RGBA with base colors, and HSLA with accent colors. ```css .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); } ``` -------------------------------- ### Import Single Sass Flavor Source: https://github.com/catppuccin/palette/blob/main/docs/sass.md Import a single Catppuccin flavor like Mocha. This method is straightforward for using one specific theme. ```scss @use "mocha"; // sass is also part of the npm package: // @use "~@catppuccin/palette/scss/catppuccin/mocha"; .my-mocha-class { background: $base; color: $text; } ``` ```css .my-mocha-class { background: #1e1e2e; color: #cdd6f4; } ``` -------------------------------- ### Accessing ANSI Colors via ansiColors and ansiColorEntries Source: https://context7.com/catppuccin/palette/llms.txt Demonstrates direct access to normal and bright ANSI color variants and how to iterate through all ANSI color entries to generate escape sequences or build lookup tables. Requires importing `flavors` from `@catppuccin/palette`. ```typescript import { flavors } from "@catppuccin/palette"; const { ansiColors, ansiColorEntries } = flavors.mocha; // Direct access const normalBlue = ansiColors.blue.normal; const brightBlue = ansiColors.blue.bright; console.log(normalBlue.hex); // "#89b4fa" console.log(normalBlue.code); // 4 console.log(brightBlue.hex); // "#74a8fc" console.log(brightBlue.code); // 12 // Iterate all ANSI colors and emit escape sequences ansiColorEntries.forEach(([name, group]) => { const { normal, bright } = group; console.log(`\x1b[${normal.code}m Normal ${name} \x1b[0m hex=${normal.hex}`); console.log(`\x1b[${bright.code}m Bright ${name} \x1b[0m hex=${bright.hex}`); }); // Build a 16-color ANSI lookup table const ansiTable: Record = {}; ansiColorEntries.forEach(([, group]) => { ansiTable[group.normal.code] = group.normal.hex; ansiTable[group.bright.code] = group.bright.hex; }); console.log(ansiTable[0]); // "#45475a" (normal black in Mocha) console.log(ansiTable[8]); // "#585b70" (bright black in Mocha) ``` -------------------------------- ### Accessing Flavors with `flavors` Source: https://context7.com/catppuccin/palette/llms.txt The `flavors` export provides direct access to each of the four Catppuccin palettes (Latte, FrappΓ©, Macchiato, Mocha). You can retrieve a specific flavor and access its metadata, all 26 named colors in various formats, and ANSI color mappings. ```APIDOC ## `flavors` β€” All four Catppuccin palettes An object keyed by `FlavorName` (`"latte"`, `"frappe"`, `"macchiato"`, `"mocha"`), each value being a `CatppuccinFlavor` with metadata, all 26 colors in four formats, and ANSI mappings. ```ts import { flavors } from "@catppuccin/palette"; // Access a flavor directly const mocha = flavors.mocha; console.log(mocha.name); // "Mocha" console.log(mocha.emoji); // "🌿" console.log(mocha.dark); // true console.log(mocha.order); // 3 // Access a specific color in all formats const blue = mocha.colors.blue; console.log(blue.hex); // "#89b4fa" console.log(blue.rgb); // { r: 137, g: 180, b: 250 } console.log(blue.hsl); // { h: 217.17, s: 0.9187, l: 0.7588 } console.log(blue.oklch); // { l: 0.7664, c: 0.1113, h: 259.88 } console.log(blue.accent); // true console.log(blue.order); // 12 // Check the light flavor (Latte) const latte = flavors.latte; console.log(latte.dark); // false console.log(latte.colors.base.hex); // "#eff1f5" console.log(latte.colors.text.hex); // "#4c4f69" ``` ``` -------------------------------- ### Color Formats on `ColorFormat` Source: https://context7.com/catppuccin/palette/llms.txt Each color within the Catppuccin palettes is available in multiple formats: hex, RGB, HSL, and oklch. Additionally, metadata like name, order, and accent status is provided. ```APIDOC ## Color formats on `ColorFormat` Every color in every flavor exposes four formats β€” `hex`, `rgb`, `hsl`, and `oklch` β€” plus `name`, `order`, and `accent` metadata. ```ts import { flavors } from "@catppuccin/palette"; const { colors } = flavors.macchiato; // hex (string, e.g. "#c6a0f6") const hexValue: string = colors.mauve.hex; // rgb (r/g/b each 0–255) const { r, g, b } = colors.mauve.rgb; // { r: 198, g: 160, b: 246 } // hsl (h: 0–360, s/l: 0–1) const { h, s, l } = colors.mauve.hsl; // { h: 266.51, s: 0.827, l: 0.796 } // oklch (l: 0–1, c: 0–0.4, h: 0–360) const ok = colors.mauve.oklch; // { l: 0.7715, c: 0.1259, h: 303.90 } // Generate a CSS rgba() value from rgb const cssRgba = `rgba(${r}, ${g}, ${b}, 0.85)`; // "rgba(198, 160, 246, 0.85)" // Generate a CSS oklch() value const cssOklch = `oklch(${ok.l.toFixed(4)} ${ok.c.toFixed(4)} ${ok.h.toFixed(2)})`; // "oklch(0.7715 0.1259 303.90)" ``` ``` -------------------------------- ### Using Type Exports for Exhaustive Type-Checking Source: https://context7.com/catppuccin/palette/llms.txt Illustrates how to use exported union types like `FlavorName`, `ColorName`, and `AccentName` for precise type-checking and autocompletion when developing theme engines. Imports are required from `@catppuccin/palette`. ```typescript import type { FlavorName, ColorName, AccentName, MonochromaticName, CatppuccinFlavor, CatppuccinColors, ColorFormat, Flavors, } from "@catppuccin/palette"; import { flavors } from "@catppuccin/palette"; // FlavorName: "latte" | "frappe" | "macchiato" | "mocha" function getFlavorBase(name: FlavorName): string { return flavors[name].colors.base.hex; } console.log(getFlavorBase("mocha")); // "#1e1e2e" console.log(getFlavorBase("latte")); // "#eff1f5" // ColorName: AccentName | MonochromaticName (26 total) function getColor(flavorName: FlavorName, colorName: ColorName): ColorFormat { return flavors[flavorName].colors[colorName]; } const color = getColor("frappe", "lavender"); console.log(color.hex); // "#babbf1" // Build a Flavors map of all base hex values const bases: Flavors = { latte: flavors.latte.colors.base.hex, frappe: flavors.frappe.colors.base.hex, macchiato: flavors.macchiato.colors.base.hex, mocha: flavors.mocha.colors.base.hex, }; // { latte: "#eff1f5", frappe: "#303446", macchiato: "#24273a", mocha: "#1e1e2e" } ``` -------------------------------- ### Generate SCSS Theme Classes from Map Source: https://context7.com/catppuccin/palette/llms.txt Iterate over the combined SCSS palette map to generate theme classes for all flavors. This requires Sass map functions. ```scss /* --- Multi-flavor with combined map --- */ @use "sass:map"; @use "~@catppuccin/palette/scss/catppuccin"; // Generate theme classes for every flavor @each $flavor, $color in catppuccin.$palette { .theme-#{$flavor} { background-color: #{map.get($color, 'base')}; color: #{map.get($color, 'text')}; accent-color: #{map.get($color, 'blue')}; a { color: #{map.get($color, 'mauve')}; } code { background: #{map.get($color, 'surface0')}; } } } /* Output (excerpt): .theme-mocha { background-color: #1e1e2e; color: #cdd6f4; accent-color: #89b4fa; } .theme-macchiato { background-color: #24273a; color: #cad3f5; accent-color: #8aadf4; } .theme-frappe { background-color: #303446; color: #c6d0f5; accent-color: #8caaee; } .theme-latte { background-color: #eff1f5; color: #4c4f69; accent-color: #1e66f5; } */ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.