Socket
Socket
Sign inDemoInstall

tailwind-variants

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwind-variants

🦄 Tailwindcss first-class variant API


Version published
Weekly downloads
333K
decreased by-7.03%
Maintainers
1
Weekly downloads
 
Created

What is tailwind-variants?

The tailwind-variants npm package is designed to help developers create and manage variants of Tailwind CSS classes more efficiently. It allows for the dynamic generation of class names based on different states, conditions, and themes, making it easier to maintain and scale Tailwind CSS projects.

What are tailwind-variants's main functionalities?

Dynamic Class Generation

This feature allows you to dynamically generate class names based on different variants. In this example, the `button` object can generate classes for different sizes and colors of a button.

const button = tv({ base: 'px-4 py-2 font-bold', variants: { size: { small: 'text-sm', large: 'text-lg' }, color: { primary: 'text-white bg-blue-500', secondary: 'text-gray-700 bg-gray-200' } } });

Conditional Class Application

This feature allows you to apply classes conditionally based on the provided variants. In this example, the `buttonClass` will generate the appropriate class string based on the `size` and `color` variants.

const buttonClass = button({ size: 'large', color: 'primary' }); // 'px-4 py-2 font-bold text-lg text-white bg-blue-500'

Theme Support

This feature allows you to define and apply different themes to your components. In this example, the `themedButton` object can generate classes for light and dark themes.

const themedButton = tv({ base: 'px-4 py-2 font-bold', variants: { theme: { light: 'text-black bg-white', dark: 'text-white bg-black' } } });

Other packages similar to tailwind-variants

Keywords

FAQs

Package last updated on 15 Mar 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc