1 | <div align="center">
|
2 |
|
3 |
|
4 | <h1>
|
5 |
|
6 | Nov 18, 2022: [Twind v1](https://github.com/tw-in-js/twind/tree/main#readme) is now in stable release!
|
7 |
|
8 | </h1>
|
9 |
|
10 | <h2>
|
11 |
|
12 | Please check out the [Migration Guide](https://twind.style/migration#from-twind-v016) to upgrade and use the new [@twind/core](https://www.npmjs.com/package/@twind/core) package.
|
13 |
|
14 | <h2>
|
15 |
|
16 | </div>
|
17 |
|
18 | ----
|
19 |
|
20 | <div align="center">
|
21 |
|
22 | <img src="https://twind.dev/assets/twind-logo-animated.svg" height="125" width="125" />
|
23 | <a href="https://twind.dev" align="center"><h1>Twind</h1></a>
|
24 |
|
25 | <p align="center">
|
26 | The smallest, fastest, most feature complete Tailwind-in-JS solution in existence
|
27 | </p>
|
28 |
|
29 | [](https://github.com/tw-in-js/twind/blob/v0.16/LICENSE)
|
30 | [](https://www.npmjs.com/package/twind)
|
31 | [](https://bundlephobia.com/result?p=twind 'gzip bundle size (including dependencies)')
|
32 | [](https://unpkg.com/twind/twind.js 'brotli package size (without dependencies)')
|
33 | [](https://twind.dev)
|
34 | [](https://github.com/tw-in-js/twind)
|
35 | [](https://chat.twind.style)
|
36 | [](https://github.com/tw-in-js/twind/actions?query=workflow%3Aci)
|
37 | [](https://coveralls.io/github/tw-in-js/twind?branch=v0.16)
|
38 |
|
39 | </div>
|
40 |
|
41 | Twind is a small compiler (~13kB) that converts Tailwind classes into actual CSS rules at runtime. If you have used Tailwind or other CSS-in-JS solutions, then most of the API should feel very familiar.
|
42 |
|
43 | ## [Documentation](https://twind.dev)
|
44 |
|
45 | Frequently viewed docs:
|
46 |
|
47 | - [Quick Reference](https://twind.dev/handbook/quick-reference.html) – fast overview
|
48 | - [Getting Started](https://twind.dev/handbook/getting-started.html) – how to install `twind`
|
49 | - [Shim](https://twind.dev/handbook/the-shim.html) – seamless integration with existing Tailwind HTML
|
50 | - [Styling with Twind](https://twind.dev/handbook/styling-with-twind.html) – how to style with Twind
|
51 | - [Grouping](https://twind.dev/handbook/grouping-syntax.html) – how to optimize rules size
|
52 | - [Theming](https://twind.dev/handbook/configuration.html#theme) – how to apply your theme
|
53 | - [CSS-in-JS](https://twind.dev/handbook/css-in-twind.html) – how to apply custom CSS
|
54 | - [Tailwind Extensions](https://twind.dev/handbook/extended-functionality.html) – which additional features are available
|
55 |
|
56 | ## [Features](http://twind.dev/handbook/introduction.html#features)
|
57 |
|
58 | **⚡️ No build step**
|
59 |
|
60 | Get all the benefits of Tailwind without the need for Tailwind, PostCSS, configuration, purging, or autoprefixing.
|
61 |
|
62 | **🚀 Framework agnostic**
|
63 |
|
64 | If your app uses HTML and JavaScript, it should work with Twind. This goes for server-rendered apps too.
|
65 |
|
66 | **😎 One low fixed cost**
|
67 |
|
68 | Twind ships the compiler, not the CSS. This means unlimited styles and variants for one low fixed cost of ~13kB.
|
69 |
|
70 | Other features include:
|
71 |
|
72 | - 🎨 Seamless integration with Tailwind
|
73 | - 🎯 Extended variants, directives, and syntax
|
74 | - ✈️ Tailwind preflight by default
|
75 | - 🤝 Feature parity with Tailwind
|
76 | - 🚓 Escape hatch for arbitrary CSS
|
77 | - 🤖 Built in support for conditional rule combining
|
78 | - 🧐 Improved readability with multiline styles
|
79 | - ❄️ Optional hashing of class names ensuring no conflicts
|
80 | - 🔌 Language extension via plugins
|
81 | - 🎩 No runtime overhead with static extraction
|
82 | - 🚅 Faster than most CSS-in-JS libraries
|
83 | - and more!
|
84 |
|
85 | ## ⚡️ [Quick Start](http://twind.dev/handbook/getting-started.html)
|
86 |
|
87 | Copy and paste this code into your favorite sandbox to get started with Twind right away:
|
88 |
|
89 | ```js
|
90 | import { tw } from 'https://cdn.skypack.dev/twind'
|
91 |
|
92 | document.body.innerHTML = `
|
93 | <main class="${tw`h-screen bg-purple-400 flex items-center justify-center`}">
|
94 | <h1 class="${tw`font-bold text(center 5xl white sm:gray-800 md:pink-700)`}">This is Twind!</h1>
|
95 | </main>
|
96 | `
|
97 | ```
|
98 |
|
99 | Alternatively try the 🚀 [live and interactive demo](https://esm.codes/#aW1wb3J0IHsgdHcgfSBmcm9tICdodHRwczovL2Nkbi5za3lwYWNrLmRldi90d2luZCcKCmRvY3VtZW50LmJvZHkuaW5uZXJIVE1MID0gYAogIDxtYWluIGNsYXNzPSIke3R3YGgtc2NyZWVuIGJnLXB1cnBsZS00MDAgZmxleCBpdGVtcy1jZW50ZXIganVzdGlmeS1jZW50ZXJgfSI+CiAgICA8aDEgY2xhc3M9IiR7dHdgZm9udC1ib2xkIHRleHQoY2VudGVyIDV4bCB3aGl0ZSBzbTpncmF5LTgwMCBtZDpwaW5rLTcwMClgfSI+VGhpcyBpcyBUd2luZCE8L2gxPgogIDwvbWFpbj4KYA==) and take a look at the [installation guide](https://twind.dev/handbook/getting-started).
|
100 |
|
101 | Twind is also available as an [NPM package](https://www.npmjs.com/package/twind):
|
102 |
|
103 | ```
|
104 | npm i twind
|
105 | ```
|
106 |
|
107 | For seamless integration with existing Tailwind HTML you can use [twind/shim](https://twind.dev/handbook/the-shim.html):
|
108 |
|
109 | ```html
|
110 | <script type="module" src="https://cdn.skypack.dev/twind/shim"></script>
|
111 |
|
112 | <main class="h-screen bg-purple-400 flex items-center justify-center">
|
113 | <h1 class="font-bold text(center 5xl white sm:gray-800 md:pink-700)">This is Twind!</h1>
|
114 | </main>
|
115 | ```
|
116 |
|
117 | Try `twind/shim` in the 🚀 [live and interactive shim demo](https://esm.codes/#aW1wb3J0ICdodHRwczovL2Nkbi5za3lwYWNrLmRldi90d2luZC9zaGltJwoKZG9jdW1lbnQuYm9keS5pbm5lckhUTUwgPSBgCiAgPG1haW4gY2xhc3M9Imgtc2NyZWVuIGJnLXB1cnBsZS00MDAgZmxleCBpdGVtcy1jZW50ZXIganVzdGlmeS1jZW50ZXIiPgogICAgPGgxIGNsYXNzPSJmb250LWJvbGQgdGV4dChjZW50ZXIgNXhsIHdoaXRlIHNtOmdyYXktODAwIG1kOnBpbmstNzAwKSI+CiAgICAgIFRoaXMgaXMgVHdpbmQhCiAgICA8L2gxPgogIDwvbWFpbj4KYA==)
|
118 |
|
119 | This is just the beginning of all the awesome things you can do with Twind. [Check out the handbook](https://twind.dev/handbook/introduction.html) to learn more.
|
120 |
|
121 | ## 💡 Inspiration
|
122 |
|
123 | It would be untrue to suggest that the design here is totally original. Other than the founders' initial attempts at implementing such a module ([oceanwind](https://github.com/lukejacksonn/oceanwind) and [beamwind](https://github.com/kenoxa/beamwind)) we are truly standing on the shoulders of giants.
|
124 |
|
125 | - [Tailwind](https://tailwindcss.com/): created a wonderfully thought out API on which the compiler's grammar was defined.
|
126 | - [styled-components](https://styled-components.com/): implemented and popularized the advantages of doing CSS-in-JS.
|
127 | - [htm](https://github.com/developit/htm): a JSX compiler that proved there is merit in doing runtime compilation of DSLs like JSX.
|
128 | - [goober](https://github.com/cristianbote/goober): an impossibly small yet efficient CSS-in-JS implementation that defines critical module features.
|
129 | - [otion](https://github.com/kripod/otion): the first CSS-in-JS solution specifically oriented around handling CSS in an atomic fashion.
|
130 | - [clsx](https://github.com/lukeed/clsx): a tiny utility for constructing class name strings conditionally.
|
131 | - [style-vendorizer](https://github.com/kripod/style-vendorizer): essential CSS prefixing helpers in less than 1KB of JavaScript.
|
132 | - [CSSType](https://github.com/frenic/csstype): providing autocompletion and type checking for CSS properties and values.
|
133 |
|
134 | ## 🙏🏾 Sponsors
|
135 |
|
136 | Support us with a monthly donation and help us continue our activities.
|
137 |
|
138 | [[GitHub Sponsor](https://github.com/sponsors/tw-in-js) | [Open Collective](https://opencollective.com/twind)]
|
139 |
|
140 | <a href="https://github.com/jordwalke" target="_blank"><img style="border-radius: 50%!important" src="https://avatars.githubusercontent.com/u/977348?v=4" width="64" height="64" alt="@jordwalke"></a>
|
141 | <a href="https://github.com/tylerforesthauser" target="_blank"><img style="border-radius: 50%!important" src="https://avatars.githubusercontent.com/u/1226786?v=4" width="64" height="64" alt="@tylerforesthauser"></a>
|
142 | <a href="https://github.com/holic" target="_blank"><img style="border-radius: 50%!important" src="https://avatars.githubusercontent.com/u/508855?v=4" width="64" height="64" alt="@holic"></a>
|
143 | <a href="https://github.com/Andrewnt219" target="_blank"><img style="border-radius: 50%!important" src="https://avatars.githubusercontent.com/u/52666982?v=4" width="64" height="64" alt="@Andrewnt219"></a>
|
144 | <a href="https://opencollective.com/twind/backer/0/website" target="_blank"><img src="https://opencollective.com/twind/backer/0/avatar.svg"></a>
|
145 | <a href="https://opencollective.com/twind/backer/1/website" target="_blank"><img src="https://opencollective.com/twind/backer/1/avatar.svg"></a>
|
146 | <a href="https://opencollective.com/twind/backer/2/website" target="_blank"><img src="https://opencollective.com/twind/backer/2/avatar.svg"></a>
|
147 |
|
148 | <a href="https://opencollective.com/twind/sponsor/0/website" target="_blank"><img src="https://opencollective.com/twind/sponsor/0/avatar.svg"></a>
|
149 | <a href="https://opencollective.com/twind/sponsor/1/website" target="_blank"><img src="https://opencollective.com/twind/sponsor/1/avatar.svg"></a>
|
150 |
|
151 | ## 🤝 Contributing
|
152 |
|
153 | We are excited that you are interested in contributing to this project! We've put together a whole [contribution guide](https://github.com/tw-in-js/twind/blob/v0.16/CONTRIBUTING.md) to get you started.
|
154 |
|
155 | ## ⚖️ License
|
156 |
|
157 | The [MIT license](https://github.com/tw-in-js/twind/blob/v0.16/LICENSE) governs your use of Twind.
|