Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/milandekruijf/pandacss-preset-typography
Typography preset for PandaCSS
https://github.com/milandekruijf/pandacss-preset-typography
chakra-ui css pandacss preset styling typography
Last synced: about 1 month ago
JSON representation
Typography preset for PandaCSS
- Host: GitHub
- URL: https://github.com/milandekruijf/pandacss-preset-typography
- Owner: milandekruijf
- License: mit
- Created: 2023-07-18T14:24:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-08T12:21:19.000Z (5 months ago)
- Last Synced: 2024-09-30T13:21:47.237Z (about 2 months ago)
- Topics: chakra-ui, css, pandacss, preset, styling, typography
- Language: TypeScript
- Homepage: https://milandekruijf.com/work/pandacss-preset-typography
- Size: 268 KB
- Stars: 24
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Downloads][npm-shield]][npm-url]
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]# πΌ PandaCSS preset for typography
A [πΌ PandaCSS](https://panda-css.com/) typography preset inspired by the [TailwindCSS typography plugin](https://tailwindcss.com/docs/typography-plugin)
## Installation
```bash
npm install --save-dev pandacss-preset-typography
```## Usage
Add the preset to your PandaCSS configuration (`panda.config.ts`)
```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 presets if you want to keep
// the default keyframes, breakpoints, tokens
// and textStyles provided by PandaCSS
"@pandacss/dev/presets",
],
});
```## 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` or as whatever you've set it as in the options.
```tsx
// 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 "@pandacss/out/recipes";export function Page() {
;
return
}
```### 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 options as shown below.
```ts
...
presets: [
typographyPreset({
recipe: {
// Name of the recipe export
name: "prose",
className: "prose",
// Sizes you want to include
sizes: ["sm", "base", "lg", "xl", "2xl"],
defaultSize: "base",
// Enable/disable not-prose functionality
// just like in TailwindCSS
notProse: false,
// notProse: true,
// notProse: {
// className: "not-prose",
// },
semanticTokens: {
// defaults: true,
defaults: {
// Set a color palette to use for the defaults.
// It only works with colors that have a numeric scale (11x)
// from 50 to 950. (50, 100, 200, ..., 800, 900, 950).
colorPalette: "slate",
},
// The prefix to use for semantic tokens.
// ex: --colors--body
prefix: "prose",
},
},
}),
],
```### Colors
Colors are currently being handled by CSS variables. The default colors are
as followed:```ts
{
semanticTokens: {
colors: {
// Or whatever name you've set as the semantic tokens
// prefix or recipe name
prose: {
body: {
value: "{colors.slate.700}",
},
heading: {
value: "{colors.slate.900}",
},
lead: {
value: "{colors.slate.600}",
},
link: {
value: "{colors.slate.900}",
},
bold: {
value: "{colors.slate.900}",
},
counter: {
value: "{colors.slate.500}",
},
bullet: {
value: "{colors.slate.300}",
},
hrBorder: {
value: "{colors.slate.200}",
},
quote: {
value: "{colors.slate.900}",
},
quoteBorder: {
value: "{colors.slate.200}",
},
caption: {
value: "{colors.slate.500}",
},
kbd: {
value: "{colors.slate.900}",
},
kbdShadow: {
// Expects an RGB value
value: "0 0 0",
},
code: {
value: "{colors.slate.900}",
},
preCode: {
value: "{colors.slate.200}",
},
preBg: {
value: "{colors.slate.800}",
},
thBorder: {
value: "{colors.slate.300}",
},
tdBorder: {
value: "{colors.slate.200}",
},
},
},
},
}
```If you have the [Radix Colors](https://www.npmjs.com/package/pandacss-preset-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.
```ts
{
semanticTokens: {
colors: {
// Or whatever name you've set as the semantic tokens
// prefix or recipe name
prose: {
body: {
value: "{colors.slate.12}",
},
heading: {
value: "{colors.slate.12}",
},
lead: {
value: "{colors.slate.12}",
},
link: {
value: "{colors.blue.11}",
},
bold: {
value: "{colors.slate.12}",
},
counter: {
value: "{colors.slate.11}",
},
bullet: {
value: "{colors.slate.11}",
},
hrBorder: {
value: "{colors.slate.6}",
},
quote: {
value: "{colors.slate.11}",
},
quoteBorder: {
value: "{colors.slate.6}",
},
caption: {
value: "{colors.slate.11}",
},
kbd: {
value: "{colors.slate.11}",
},
kbdShadow: {
// Expects an RGB value
value: "0 0 0",
},
code: {
value: "{colors.amber.11}",
},
preCode: {
value: "{colors.slate.12}",
},
preBg: {
value: "{colors.slate.2}",
},
thBorder: {
value: "{colors.slate.6}",
},
tdBorder: {
value: "{colors.slate.6}",
},
},
},
},
}
```## Attributions
- [Chakra](https://github.com/chakra-ui) team for creating [πΌ PandaCSS](https://panda-css.com/)
- [Tailwind](https://github.com/tailwindlabs) team for creating the styles[contributors-shield]: https://img.shields.io/github/contributors/milandekruijf/pandacss-preset-typography.svg?style=for-the-badge
[contributors-url]: https://github.com/milandekruijf/pandacss-preset-typography/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/milandekruijf/pandacss-preset-typography.svg?style=for-the-badge
[forks-url]: https://github.com/milandekruijf/pandacss-preset-typography/network/members
[stars-shield]: https://img.shields.io/github/stars/milandekruijf/pandacss-preset-typography.svg?style=for-the-badge
[stars-url]: https://github.com/milandekruijf/pandacss-preset-typography/stargazers
[issues-shield]: https://img.shields.io/github/issues/milandekruijf/pandacss-preset-typography.svg?style=for-the-badge
[issues-url]: https://github.com/milandekruijf/pandacss-preset-typography/issues
[license-shield]: https://img.shields.io/github/license/milandekruijf/pandacss-preset-typography.svg?style=for-the-badge
[license-url]: https://github.com/milandekruijf/pandacss-preset-typography/blob/main/LICENSE
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/milandekruijf
[npm-shield]: https://img.shields.io/npm/dw/pandacss-preset-typography?style=for-the-badge
[npm-url]: https://www.npmjs.com/package/pandacss-preset-typography