1 | <div align="center">
|
2 |
|
3 | <img src="https://twind.dev/assets/twind-logo-animated.svg" height="125" width="125" />
|
4 | <a href="https://twind.dev" align="center"><h1>Twind</h1></a>
|
5 |
|
6 | <p align="center">
|
7 | The smallest, fastest, most feature complete Tailwind-in-JS solution in existence
|
8 | </p>
|
9 |
|
10 | [![MIT License](https://flat.badgen.net/github/license/tw-in-js/twind)](https://github.com/tw-in-js/twind/blob/main/LICENSE)
|
11 | [![Latest Release](https://flat.badgen.net/npm/v/twind?icon=npm&label&cache=10800&color=blue)](https://www.npmjs.com/package/twind)
|
12 | [![Bundle Size](https://flat.badgen.net/bundlephobia/minzip/twind?icon=packagephobia&label&color=blue&cache=10800)](https://bundlephobia.com/result?p=twind 'gzip bundle size (including dependencies)')
|
13 | [![Package Size](https://flat.badgen.net/badgesize/brotli/https://cdn.jsdelivr.net/npm/twind/twind.min.js?icon=jsdelivr&label&color=blue&cache=10800)](https://unpkg.com/twind/twind.js 'brotli package size (without dependencies)')
|
14 | [![Documentation](https://flat.badgen.net/badge/icon/Documentation?icon=awesome&label)](https://twind.dev)
|
15 | [![Github](https://flat.badgen.net/badge/icon/tw-in-js%2Ftwind?icon=github&label)](https://github.com/tw-in-js/twind)
|
16 | [![Discord](https://flat.badgen.net/badge/icon/discord?icon=discord&label)](https://discord.com/invite/2aP5NkszvD)
|
17 | [![CI](https://github.com/tw-in-js/twind/workflows/CI/badge.svg)](https://github.com/tw-in-js/twind/actions?query=workflow%3Aci)
|
18 | [![Coverage Status](https://flat.badgen.net/coveralls/c/github/tw-in-js/twind/main?icon=codecov&label&cache=10800)](https://coveralls.io/github/tw-in-js/twind?branch=main)
|
19 |
|
20 | </div>
|
21 |
|
22 | 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.
|
23 |
|
24 | ## [Documentation](https://twind.dev)
|
25 |
|
26 | Frequently viewed docs:
|
27 |
|
28 | - [Quick Reference](https://twind.dev/handbook/quick-reference.html) – fast overview
|
29 | - [Getting Started](https://twind.dev/handbook/getting-started.html) – how to install `twind`
|
30 | - [Shim](https://twind.dev/handbook/the-shim.html) – seamless integration with existing Tailwind HTML
|
31 | - [Styling with Twind](https://twind.dev/handbook/styling-with-twind.html) – how to style with Twind
|
32 | - [Grouping](https://twind.dev/handbook/grouping-syntax.html) – how to optimize rules size
|
33 | - [Theming](https://twind.dev/handbook/configuration.html#theme) – how to apply your theme
|
34 | - [CSS-in-JS](https://twind.dev/handbook/css-in-twind.html) – how to apply custom CSS
|
35 | - [Tailwind Extensions](https://twind.dev/handbook/extended-functionality.html) – which additional features are available
|
36 |
|
37 | ## [Features](http://twind.dev/handbook/introduction.html#features)
|
38 |
|
39 | **⚡️ No build step**
|
40 |
|
41 | Get all the benefits of Tailwind without the need for Tailwind, PostCSS, configuration, purging, or autoprefixing.
|
42 |
|
43 | **🚀 Framework agnostic**
|
44 |
|
45 | If your app uses HTML and JavaScript, it should work with Twind. This goes for server-rendered apps too.
|
46 |
|
47 | **😎 One low fixed cost**
|
48 |
|
49 | Twind ships the compiler, not the CSS. This means unlimited styles and variants for one low fixed cost of ~13kB.
|
50 |
|
51 | Other features include:
|
52 |
|
53 | - 🎨 Seamless integration with Tailwind
|
54 | - 🎯 Extended variants, directives, and syntax
|
55 | - ✈️ Tailwind preflight by default
|
56 | - 🤝 Feature parity with Tailwind
|
57 | - 🚓 Escape hatch for arbitrary CSS
|
58 | - 🤖 Built in support for conditional rule combining
|
59 | - 🧐 Improved readability with multiline styles
|
60 | - ❄️ Optional hashing of class names ensuring no conflicts
|
61 | - 🔌 Language extension via plugins
|
62 | - 🎩 No runtime overhead with static extraction
|
63 | - 🚅 Faster than most CSS-in-JS libraries
|
64 | - and more!
|
65 |
|
66 | ## ⚡️ [Quick Start](http://twind.dev/handbook/getting-started.html)
|
67 |
|
68 | Copy and paste this code into your favorite sandbox to get started with Twind right away:
|
69 |
|
70 | ```js
|
71 | import { tw } from 'https://cdn.skypack.dev/twind'
|
72 |
|
73 | document.body.innerHTML = `
|
74 | <main class="${tw`h-screen bg-purple-400 flex items-center justify-center`}">
|
75 | <h1 class="${tw`font-bold text(center 5xl white sm:gray-800 md:pink-700)`}">This is Twind!</h1>
|
76 | </main>
|
77 | `
|
78 | ```
|
79 |
|
80 | 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).
|
81 |
|
82 | Twind is also available as an [NPM package](https://www.npmjs.com/package/twind):
|
83 |
|
84 | ```
|
85 | npm i twind
|
86 | ```
|
87 |
|
88 | For seamless integration with existing Tailwind HTML you can use [twind/shim](https://twind.dev/handbook/the-shim.html):
|
89 |
|
90 | ```html
|
91 | <script type="module" src="https://cdn.skypack.dev/twind/shim"></script>
|
92 |
|
93 | <main class="h-screen bg-purple-400 flex items-center justify-center">
|
94 | <h1 class="font-bold text(center 5xl white sm:gray-800 md:pink-700)">This is Twind!</h1>
|
95 | </main>
|
96 | ```
|
97 |
|
98 | Try `twind/shim` in the 🚀 [live and interactive shim demo](https://esm.codes/#aW1wb3J0ICdodHRwczovL2Nkbi5za3lwYWNrLmRldi90d2luZC9zaGltJwoKZG9jdW1lbnQuYm9keS5pbm5lckhUTUwgPSBgCiAgPG1haW4gY2xhc3M9Imgtc2NyZWVuIGJnLXB1cnBsZS00MDAgZmxleCBpdGVtcy1jZW50ZXIganVzdGlmeS1jZW50ZXIiPgogICAgPGgxIGNsYXNzPSJmb250LWJvbGQgdGV4dChjZW50ZXIgNXhsIHdoaXRlIHNtOmdyYXktODAwIG1kOnBpbmstNzAwKSI+CiAgICAgIFRoaXMgaXMgVHdpbmQhCiAgICA8L2gxPgogIDwvbWFpbj4KYA==)
|
99 |
|
100 | 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.
|
101 |
|
102 | ## 💡 Inspiration
|
103 |
|
104 | 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.
|
105 |
|
106 | - [Tailwind](https://tailwindcss.com/): created a wonderfully thought out API on which the compiler's grammar was defined.
|
107 | - [styled-components](https://styled-components.com/): implemented and popularized the advantages of doing CSS-in-JS.
|
108 | - [htm](https://github.com/developit/htm): a JSX compiler that proved there is merit in doing runtime compilation of DSLs like JSX.
|
109 | - [goober](https://github.com/cristianbote/goober): an impossibly small yet efficient CSS-in-JS implementation that defines critical module features.
|
110 | - [otion](https://github.com/kripod/otion): the first CSS-in-JS solution specifically oriented around handling CSS in an atomic fashion.
|
111 | - [clsx](https://github.com/lukeed/clsx): a tiny utility for constructing class name strings conditionally.
|
112 | - [style-vendorizer](https://github.com/kripod/style-vendorizer): essential CSS prefixing helpers in less than 1KB of JavaScript.
|
113 | - [CSSType](https://github.com/frenic/csstype): providing autocompletion and type checking for CSS properties and values.
|
114 |
|
115 | ## 🙏🏾 Sponsors
|
116 |
|
117 | Support us with a monthly donation and help us continue our activities.
|
118 |
|
119 | [[GitHub Sponsor](https://github.com/sponsors/tw-in-js) | [Open Collective](https://opencollective.com/twind)]
|
120 |
|
121 | <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>
|
122 | <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>
|
123 | <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>
|
124 | <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>
|
125 | <a href="https://opencollective.com/twind/backer/0/website" target="_blank"><img src="https://opencollective.com/twind/backer/0/avatar.svg"></a>
|
126 | <a href="https://opencollective.com/twind/backer/1/website" target="_blank"><img src="https://opencollective.com/twind/backer/1/avatar.svg"></a>
|
127 | <a href="https://opencollective.com/twind/backer/2/website" target="_blank"><img src="https://opencollective.com/twind/backer/2/avatar.svg"></a>
|
128 |
|
129 | <a href="https://opencollective.com/twind/sponsor/0/website" target="_blank"><img src="https://opencollective.com/twind/sponsor/0/avatar.svg"></a>
|
130 | <a href="https://opencollective.com/twind/sponsor/1/website" target="_blank"><img src="https://opencollective.com/twind/sponsor/1/avatar.svg"></a>
|
131 |
|
132 | ## 🤝 Contributing
|
133 |
|
134 | We are excited that you are interested in contributing to this project! We've put together a whole [contribution guide](https://twind.dev/handbook/contributing.html) to get you started.
|
135 |
|
136 | ## ⚖️ License
|
137 |
|
138 | The [MIT license](https://github.com/tw-in-js/twind/blob/main/LICENSE) governs your use of Twind.
|