New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

cn-func

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cn-func

A simple helper function to merge class names using clsx and tailwind-merge.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

cn-func

A simple helper function to merge class names using clsx and tailwind-merge.

Why This Library?

In many projects, developers often need to combine class names conditionally and ensure that Tailwind CSS classes are merged correctly. Instead of copying the same utility function from project to project, this library was published to provide a reusable, easy-to-install solution. It simplifies the process of merging class names, making your code cleaner and more maintainable.

Installation

Install the package via npm:

npm install cn-func

Usage

import { cn } from "cn-func";

const className = cn("text-sm", "block", condition && "rounded");

// Output classes:
// text-sm block rounded (if condition is true)

Documentation

This package uses the following libraries under the hood:

clsx: A tiny utility for constructing className strings conditionally.
tailwind-merge: A utility for merging Tailwind CSS classes in a predictable manner.

License

This project is licensed under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication. You can see the license here.

Keywords

tailwindcss

FAQs

Package last updated on 28 May 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