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
+37-8Lines changed: 37 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,49 +4,78 @@ A Tailwind CSS plugin to create themes using CSS classes and variables.
4
4
5
5
# Overview
6
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.
7
+
Tailwind offers a "[dark mode](https://tailwindcss.com/docs/dark-mode)" feature, but that's not a true design system theme. CSS variable theming simplifies color management and developer experience by mapping semantic color names to existing design system color scales. Changing a theme becomes as simple as changing one CSS classes.
In the "dark mode" approach, every color classes needs a `dark:` alternative color, resulting in twice the number of classes across your entire code base.
This card example is styled using Tailwind color values that were set up for
44
48
you when you installed the plugin.
45
49
</p>
50
+
<buttonclass="text-action">Action text</button>
46
51
</div>
47
52
```
48
53
49
-
This system avoids dark classes altogether in favor of the theme classes. If you design your app using semantic color names, you get theming for free. This results in a significant reduction in CSS styling because you're not writing color values directly into components.
54
+
In the theme approach, we avoid `dark:` classes altogether in favor of the semantic theme class names with a single theme class to define the color mapping. The 2 components above share the same HTML, but the theme class name on the parent div sets the right theme values for all of the nested semantic class names.
55
+
56
+
Here's the same example in React TypeScript:
57
+
58
+
```tsx
59
+
function Card({ theme }: { theme:"theme--light"|"theme--dark" }) {
0 commit comments