Skip to content

Commit ecb7e87

Browse files
Add Tailwind v4 custom color theme example to README (#396)
* Add Tailwind v4 custom color theme example to README * Small fixes --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent ecb7d5c commit ecb7e87

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

README.md

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,46 @@ Even when using a prefix for your utilities `not-prose` should not have a prefix
249249

250250
### Adding custom color themes
251251

252-
To customize the color theme beyond simple CSS overrides, you can use the JavaScript based theme API. To do that, use the `@config` directive:
252+
To customize the color theme beyond simple CSS overrides, add a `@utility` directive to your CSS file:
253253

254-
```diff
255-
@import "tailwindcss";
256-
@plugin "@tailwindcss/typography";
257-
+ @config "./tailwind.config.js";
254+
```css
255+
@utility prose-pink {
256+
--tw-prose-body: var(--color-pink-800);
257+
--tw-prose-headings: var(--color-pink-900);
258+
--tw-prose-lead: var(--color-pink-700);
259+
--tw-prose-links: var(--color-pink-900);
260+
--tw-prose-bold: var(--color-pink-900);
261+
--tw-prose-counters: var(--color-pink-600);
262+
--tw-prose-bullets: var(--color-pink-400);
263+
--tw-prose-hr: var(--color-pink-300);
264+
--tw-prose-quotes: var(--color-pink-900);
265+
--tw-prose-quote-borders: var(--color-pink-300);
266+
--tw-prose-captions: var(--color-pink-700);
267+
--tw-prose-code: var(--color-pink-900);
268+
--tw-prose-pre-code: var(--color-pink-100);
269+
--tw-prose-pre-bg: var(--color-pink-900);
270+
--tw-prose-th-borders: var(--color-pink-300);
271+
--tw-prose-td-borders: var(--color-pink-200);
272+
--tw-prose-invert-body: var(--color-pink-200);
273+
--tw-prose-invert-headings: var(--color-white);
274+
--tw-prose-invert-lead: var(--color-pink-300);
275+
--tw-prose-invert-links: var(--color-white);
276+
--tw-prose-invert-bold: var(--color-white);
277+
--tw-prose-invert-counters: var(--color-pink-400);
278+
--tw-prose-invert-bullets: var(--color-pink-600);
279+
--tw-prose-invert-hr: var(--color-pink-700);
280+
--tw-prose-invert-quotes: var(--color-pink-100);
281+
--tw-prose-invert-quote-borders: var(--color-pink-700);
282+
--tw-prose-invert-captions: var(--color-pink-400);
283+
--tw-prose-invert-code: var(--color-white);
284+
--tw-prose-invert-pre-code: var(--color-pink-300);
285+
--tw-prose-invert-pre-bg: rgb(0 0 0 / 50%);
286+
--tw-prose-invert-th-borders: var(--color-pink-600);
287+
--tw-prose-invert-td-borders: var(--color-pink-700);
288+
}
258289
```
259290

260-
You can then create your own color theme by adding a new `tailwind.config.js` file with the `typography` section and providing your colors under the `css` key:
291+
For Tailwind v3, update the `typography` section in the JavaScript config file and provide your colors under the `css` key:
261292

262293
```js {{ filename: 'tailwind.config.js' }}
263294
/** @type {import('tailwindcss').Config} */
@@ -338,7 +369,15 @@ Now every instance of `prose` in the default class names will be replaced by you
338369

339370
### Customizing the CSS
340371

341-
If you want to customize the raw CSS generated by this plugin, first follow the steps from [adding custom color themes](#adding-custom-color-themes) to set up a JavaScript based configuration API and then add your overrides under the `typography` key in the `theme` section of your `tailwind.config.js` file:
372+
If you want to customize the raw CSS generated by this plugin, you can use the JavaScript based theme API. To do that, use the `@config` directive:
373+
374+
```diff
375+
@import "tailwindcss";
376+
@plugin "@tailwindcss/typography";
377+
+ @config "./tailwind.config.js";
378+
```
379+
380+
You can then create your own config by adding a new `tailwind.config.js` file with the `typography` section and providing your styles under the `css` key:
342381

343382
```js {{ filename: 'tailwind.config.js' }}
344383
/** @type {import('tailwindcss').Config} */

0 commit comments

Comments
 (0)