You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-16Lines changed: 48 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,52 @@
2
2
3
3
A Tailwind CSS plugin to create themes using CSS classes and variables.
4
4
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
+
<divclass="bg-gray-900 dark:bg-gray p-12">
15
+
<h3>Card w/ light theme</h3>
16
+
<pclass="text-white dark:text-black">
17
+
This card example is styled using Tailwind color values that were set up for
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.
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.
28
74
29
75
```html
30
76
<!-- Card example w/ light theme -->
@@ -38,20 +84,6 @@ The plugin ships with light and dark themes by default. Once added to your confi
38
84
</div>
39
85
```
40
86
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
-
<divclass="theme--dark bg-background-primary">
47
-
<h3>Card w/ dark theme</h3>
48
-
<pclass="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
-
55
87
## Themes
56
88
57
89
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: [
83
115
];
84
116
```
85
117
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:
0 commit comments