This website is still under construction. Please come back later.
Go back

PandaCSS preset for typography

Open Source

A 🐼 PandaCSS typography preset inspired by the TailwindCSS typography plugin

Installation

npm install --save-dev pandacss-preset-typography

Usage

Add the preset to your PandaCSS configuration (panda.config.ts)

import { defineConfig } from "@pandacss/dev";
 
// Import the preset. The name can be anything you want
import typographyPreset from "pandacss-preset-typography";
 
export default defineConfig({
  presets: [
    typographyPreset(),
    // Re-add the panda preset if you want to keep
    // the default keyframes, breakpoints, tokens
    // and textStyles provided by PandaCSS
    "@pandacss/preset-panda",
  ],
});

Prose

The preset generates a prose recipe for you that you can use to add beautiful typographic defaults to any vanilla HTML you don’t control, like HTML rendered from Markdown, or pulled from a CMS.

Usage

You can provide 5 different sizes: sm, base, lg, xl and 2xl. If you provide no options, the default size is set as base.

// Import it from wherever you export panda to, also make sure
// you change the name 'prose' if you've set a custom name.
import { prose } from "@/panda/recipes";
 
export function Page() {
  return <div className={prose({ size: "lg" })}></div>;
}

Lead

Just like in TailwindCSS, there's also an extra .lead class you can apply to any element within the scope of prose to get a nice lead paragraph.

Options

You can change the default name of the prose recipe (prose) and the default colors as shown below.

If you have the Radix Colors preset installed for example, you'll get dark mode support out of the box by providing the colors as shown below. These colors combinations aren't fully tested, so change according to preference.

...
presets: [
  typographyPreset({
    prose: {
      name: "typography",
      colors: {
        body: "slate.12",
        lead: "slate.12",
        link: "blue.11",
        counter: "slate.11",
        bullet: "slate.11",
        hrBorder: "slate.6",
        quote: "slate.11",
        quoteBorder: "slate.6",
        heading: "slate.12",
        caption: "slate.11",
        bold: "slate.12",
        code: "amber.11",
        preCode: "slate.12",
        preBackground: "slate.2",
        thBorder: "slate.6",
        tdBorder: "slate.6",
      },
      // Advanced JSX tracking:
      // https://panda-css.com/docs/concepts/recipes#advanced-jsx-tracking
      jsx: ['Button', 'Link', /Button$/]
    }
  }),
],

Attributions

GitHub

Language

TypeScript

License

MIT

Stars

24

Forks

2

Last push

6 months ago
NPM

Downloads

820 / week

Version

0.1.6

Unpacked size

33 kB

Total files

7

Last publish

6 months ago