Gathering detailed insights and metrics for pandacss-preset-typography
Gathering detailed insights and metrics for pandacss-preset-typography
Gathering detailed insights and metrics for pandacss-preset-typography
Gathering detailed insights and metrics for pandacss-preset-typography
npm install pandacss-preset-typography
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
24 Stars
70 Commits
2 Forks
1 Watching
1 Branches
2 Contributors
Updated on 27 Sept 2024
Minified
Minified + Gzipped
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
-55.6%
76
Compared to previous day
Last week
-6.3%
820
Compared to previous week
Last month
3.2%
2,906
Compared to previous month
Last year
341.9%
32,132
Compared to previous year
2
1
4
A 🐼 PandaCSS typography preset inspired by the TailwindCSS typography plugin
1npm install --save-dev pandacss-preset-typography
Add the preset to your PandaCSS configuration (panda.config.ts
)
1import { defineConfig } from "@pandacss/dev"; 2 3// Import the preset. The name can be anything you want 4import typographyPreset from "pandacss-preset-typography"; 5 6export default defineConfig({ 7 presets: [ 8 typographyPreset(), 9 // Re-add the panda presets if you want to keep 10 // the default keyframes, breakpoints, tokens 11 // and textStyles provided by PandaCSS 12 "@pandacss/dev/presets", 13 ], 14});
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.
You can provide 5 different sizes: sm
, base
, lg
, xl
and 2xl
. If you provide no options, the default size is set as base
or as whatever you've set it as in the options.
1// Import it from wherever you export panda to, also make sure 2// you change the name 'prose' if you've set a custom name. 3import { prose } from "@pandacss/out/recipes"; 4 5export function Page() { 6 return <div className={prose({ size: "lg" })}></div>; 7}
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.
You can change the default options as shown below.
1... 2presets: [ 3 typographyPreset({ 4 recipe: { 5 // Name of the recipe export 6 name: "prose", 7 className: "prose", 8 // Sizes you want to include 9 sizes: ["sm", "base", "lg", "xl", "2xl"], 10 defaultSize: "base", 11 // Enable/disable not-prose functionality 12 // just like in TailwindCSS 13 notProse: false, 14 // notProse: true, 15 // notProse: { 16 // className: "not-prose", 17 // }, 18 semanticTokens: { 19 // defaults: true, 20 defaults: { 21 // Set a color palette to use for the defaults. 22 // It only works with colors that have a numeric scale (11x) 23 // from 50 to 950. (50, 100, 200, ..., 800, 900, 950). 24 colorPalette: "slate", 25 }, 26 // The prefix to use for semantic tokens. 27 // ex: --colors-<prefix>-body 28 prefix: "prose", 29 }, 30 }, 31 }), 32],
Colors are currently being handled by CSS variables. The default colors are as followed:
1{ 2 semanticTokens: { 3 colors: { 4 // Or whatever name you've set as the semantic tokens 5 // prefix or recipe name 6 prose: { 7 body: { 8 value: "{colors.slate.700}", 9 }, 10 heading: { 11 value: "{colors.slate.900}", 12 }, 13 lead: { 14 value: "{colors.slate.600}", 15 }, 16 link: { 17 value: "{colors.slate.900}", 18 }, 19 bold: { 20 value: "{colors.slate.900}", 21 }, 22 counter: { 23 value: "{colors.slate.500}", 24 }, 25 bullet: { 26 value: "{colors.slate.300}", 27 }, 28 hrBorder: { 29 value: "{colors.slate.200}", 30 }, 31 quote: { 32 value: "{colors.slate.900}", 33 }, 34 quoteBorder: { 35 value: "{colors.slate.200}", 36 }, 37 caption: { 38 value: "{colors.slate.500}", 39 }, 40 kbd: { 41 value: "{colors.slate.900}", 42 }, 43 kbdShadow: { 44 // Expects an RGB value 45 value: "0 0 0", 46 }, 47 code: { 48 value: "{colors.slate.900}", 49 }, 50 preCode: { 51 value: "{colors.slate.200}", 52 }, 53 preBg: { 54 value: "{colors.slate.800}", 55 }, 56 thBorder: { 57 value: "{colors.slate.300}", 58 }, 59 tdBorder: { 60 value: "{colors.slate.200}", 61 }, 62 }, 63 }, 64 }, 65}
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.
1{ 2 semanticTokens: { 3 colors: { 4 // Or whatever name you've set as the semantic tokens 5 // prefix or recipe name 6 prose: { 7 body: { 8 value: "{colors.slate.12}", 9 }, 10 heading: { 11 value: "{colors.slate.12}", 12 }, 13 lead: { 14 value: "{colors.slate.12}", 15 }, 16 link: { 17 value: "{colors.blue.11}", 18 }, 19 bold: { 20 value: "{colors.slate.12}", 21 }, 22 counter: { 23 value: "{colors.slate.11}", 24 }, 25 bullet: { 26 value: "{colors.slate.11}", 27 }, 28 hrBorder: { 29 value: "{colors.slate.6}", 30 }, 31 quote: { 32 value: "{colors.slate.11}", 33 }, 34 quoteBorder: { 35 value: "{colors.slate.6}", 36 }, 37 caption: { 38 value: "{colors.slate.11}", 39 }, 40 kbd: { 41 value: "{colors.slate.11}", 42 }, 43 kbdShadow: { 44 // Expects an RGB value 45 value: "0 0 0", 46 }, 47 code: { 48 value: "{colors.amber.11}", 49 }, 50 preCode: { 51 value: "{colors.slate.12}", 52 }, 53 preBg: { 54 value: "{colors.slate.2}", 55 }, 56 thBorder: { 57 value: "{colors.slate.6}", 58 }, 59 tdBorder: { 60 value: "{colors.slate.6}", 61 }, 62 }, 63 }, 64 }, 65}
No vulnerabilities found.
No security vulnerabilities found.