
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@derozn/tailwind-variants
Advanced tools
The power of Tailwind combined with a first-class variant API.
For full documentation, visit tailwind-variants.org
yarn add tailwind-variants
# or
npm i tailwind-variants
import {tv} from "tailwind-variants";
const button = tv({
base: "font-medium bg-blue-500 text-white rounded-full active:opacity-80",
variants: {
color: {
primary: "bg-blue-500 text-white",
secondary: "bg-purple-500 text-white",
},
size: {
sm: "text-sm",
md: "text-base",
lg: "px-4 py-3 text-lg",
},
},
compoundVariants: [
{
size: ["sm", "md"],
class: "px-3 py-1",
},
],
defaultVariants: {
size: "md",
color: "primary",
},
});
return <button className={button({size: "sm", color: "secondary"})}>Click me</button>;
wrapper
to your TailwindCSS config file tailwind.config.js
.// tailwind.config.js
const {withTV} = require("tailwind-variants/transformer");
/** @type {import('tailwindcss').Config} */
module.exports = withTV({
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
});
If you're using a custom path to import Tailwind variants, such as creating a custom tv instance with createTV
, it's recommended to include this path in the transformer configuration:
// tailwind.config.js
const {withTV} = require("tailwind-variants/transformer");
/** @type {import('tailwindcss').Config} */
module.exports = withTV(
{
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
},
{
aliases: ["@/lib/tv"],
},
);
cva (Joe Bell)
This project as started as an extension of Joe's work on cva
– a great tool for generating variants for a single element with Tailwind CSS. Big shoutout to Joe Bell and contributors you guys rock! 🤘 - we recommend to use cva
if don't need any of the Tailwind Variants features listed here.
Stitches (Modulz)
The pioneers of the variants
API movement. Inmense thanks to Modulz for their work on Stitches and the community around it. 🙏
We're excited to see the community adopt NextUI, raise issues, and provide feedback. Whether it's a feature request, bug report, or a project to showcase, please get involved!
Contributions are always welcome!
Please follow our contributing guidelines.
Please adhere to this project's CODE_OF_CONDUCT.
Licensed under the MIT License.
See LICENSE for more information.
FAQs
🦄 Tailwindcss first-class variant API
We found that @derozn/tailwind-variants demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.