Skip to content

Commit 8672b2e

Browse files
committed
readme update: clarify usage
1 parent fd48ca2 commit 8672b2e

File tree

1 file changed

+48
-16
lines changed

1 file changed

+48
-16
lines changed

README.md

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,52 @@
22

33
A Tailwind CSS plugin to create themes using CSS classes and variables.
44

5+
# Overview
6+
7+
Tailwind CSS doesn't support themes by default, but they offer a "[dark mode](https://tailwindcss.com/docs/dark-mode)" feature. This is a utility for specifying dark mode styles, not creating themes. This plugin aims to simplify adding themes with semantic color names that can be updated by passing in theme CSS classes to override styles.
8+
9+
### Tailwind CSS "theming" with Dark Mode
10+
11+
```html
12+
<!-- Card example w/ Tailwind CSS dark mode -->
13+
14+
<div class="bg-gray-900 dark:bg-gray p-12">
15+
<h3>Card w/ light theme</h3>
16+
<p class="text-white dark:text-black">
17+
This card example is styled using Tailwind color values that were set up for
18+
you when you installed the plugin.
19+
</p>
20+
</div>
21+
```
22+
23+
### Tailwind CSS theming with this plugin
24+
25+
```html
26+
<!-- Card example w/ light theme -->
27+
28+
<div class="theme--light bg-background-primary p-12">
29+
<h3>Card w/ light theme</h3>
30+
<p class="text-white">
31+
This card example is styled using Tailwind color values that were set up for
32+
you when you installed the plugin.
33+
</p>
34+
</div>
35+
```
36+
37+
```html
38+
<!-- Card example w/ dark theme -->
39+
40+
<div class="theme--dark bg-background-primary p-12">
41+
<h3>Card w/ light theme</h3>
42+
<p class="text-white">
43+
This card example is styled using Tailwind color values that were set up for
44+
you when you installed the plugin.
45+
</p>
46+
</div>
47+
```
48+
49+
This system significantly reduces CSS styling by avoiding dark classes altogether in favor of the theme classes. If you design your app using semantic color names, you can theming for free.
50+
551
# Usage
652

753
## Installation
@@ -24,7 +70,7 @@ npm install -D tailwind-plugin-css-themes
2470
plugins: [require("tailwind-plugin-css-themes").default({})];
2571
```
2672

27-
The plugin ships with light and dark themes by default. Once added to your config, you can start using it in your HTML.
73+
The plugin ships with a very basic light and dark theme by default. Once you add the plugin to your config, you can start using it in your HTML.
2874

2975
```html
3076
<!-- Card example w/ light theme -->
@@ -38,20 +84,6 @@ The plugin ships with light and dark themes by default. Once added to your confi
3884
</div>
3985
```
4086

41-
This is powerful because it enables you to switch themes by simply changing the theme class. Here's the same example above in a dark theme.
42-
43-
```html
44-
<!-- Card example w/ dark theme -->
45-
46-
<div class="theme--dark bg-background-primary">
47-
<h3>Card w/ dark theme</h3>
48-
<p class="text-content-primary">
49-
This card example is styled using Tailwind color values that were set up for
50-
you when you installed the plugin.
51-
</p>
52-
</div>
53-
```
54-
5587
## Themes
5688

5789
Themes are created similar to how you would [add colors to your Tailwind config](https://tailwindcss.com/docs/text-color#customizing-your-theme). Pass an object into the plugin containing a `themes` function. Create themes by returning an object of theme names containing custom color names (tokens) and values.
@@ -83,7 +115,7 @@ plugins: [
83115
];
84116
```
85117
86-
The plugin turns your themes into [Tailwind component styles](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes), which lets us apply the themes using CSS classes. The resulting CSS looks like this:
118+
Behind the scenes, the plugin turns your themes into [Tailwind component styles](https://tailwindcss.com/docs/adding-custom-styles#adding-component-classes), which lets us apply the themes using CSS classes. The resulting CSS looks like this:
87119
88120
```css
89121
.theme--light {

0 commit comments

Comments
 (0)