Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sannajammeh/tw-classed
https://github.com/sannajammeh/tw-classed
components css-in-js css-in-ts react reactjs tailwind
Last synced: about 4 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/sannajammeh/tw-classed
- Owner: sannajammeh
- License: mit
- Created: 2022-05-27T22:28:11.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T21:16:29.000Z (about 1 month ago)
- Last Synced: 2025-01-04T12:41:02.897Z (7 days ago)
- Topics: components, css-in-js, css-in-ts, react, reactjs, tailwind
- Language: TypeScript
- Homepage: https://tw-classed.vercel.app
- Size: 186 MB
- Stars: 524
- Watchers: 2
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-typesafe - sannajammeh/tw-classed - Make your Tailwind components re-usable. (**1. Libraries** / Styles)
README
![tw-classed](https://raw.githubusercontent.com/sannajammeh/tw-classed/master/tw-classed.jpg)
# TW Classed
Monorepo of the TW Classed project. Consists of Core and React packages.
[Full Documentation](https://tw-classed.vercel.app)
## React
The react package is a wrapper around the core package that provides an easy to way to create classed components. See the [React Docs](https://tw-classed.vercel.app)
```tsx
// Button.tsx
import { classed } from "@tw-classed/react";const Button = classed.button("px-4 py-2", {
variants: {
color: {
primary: "bg-blue-500 text-white",
secondary: "bg-gray-500 text-white",
},
},
});// In your App
const App = () => {
return (
<>
Primary
Secondary
>
);
};
```## Core
The core package is a library that provides a set of functions to help you build your own classed components.
See the [Core Docs](https://tw-classed.vercel.app/core/Introduction)
```ts
import { classed } from "@tw-classed/core";const button = classed("px-4 py-2", {
variants: {
color: {
primary: "bg-blue-500 text-white",
secondary: "bg-gray-500 text-white",
},
},
});// In your template
const Button = document.createElement("button");
Button.className = button({ color: "primary" });// Or with a framework (Like lit-html)
const Button = () => html``;
```## License
MIT
#### Discord community
![Discord Banner 2](https://discordapp.com/api/guilds/1049812722319118416/widget.png?style=banner2)