# @destacks/tc

> Hassle-Free Merging & Sorting of Tailwind Classes

Latest version **0.6.0** (published 2023-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @destacks/tc
pnpm add @destacks/tc
yarn add @destacks/tc
bun add @destacks/tc
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2023-11-23 |
| First published | 2023-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alexis Michaltsis |
| Maintainers | 4lm |
| Keywords | tailwind, classnames, jsx, tsx, react, utility, merge, clsx, tailwind-merge, styles, css |

## Links

- npm: https://www.npmjs.com/package/@destacks/tc
- Repository: https://github.com/destacks/core-ts.git#main
- Homepage: https://github.com/destacks/core-ts/tree/main/packages/tc
- Issues: https://github.com/destacks/core-ts/issues
- npm.io page: https://npm.io/package/@destacks/tc

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2023-11-23
- 0.5.0 — 2023-11-08
- 0.4.1 — 2023-09-29
- 0.4.0 — 2023-09-29
- 0.3.1 — 2023-09-29
- 0.3.0 — 2023-09-29
- 0.2.0 — 2023-09-29

## README

# TC: Hassle-Free Merging & Sorting of Tailwind Classes

## Introduction

TC is designed to merge & sort Tailwind CSS class names in JavaScript and TypeScript. It's ideal for usage within JSX and TSX components. TC combines the power of [`clsx`](https://github.com/lukeed/clsx) and [`tailwind-merge`](https://github.com/dcastil/tailwind-merge).

Key features of TC include:

- Efficiently merges strings, conditionals, arrays, & nested objects.
- Trims extra spaces in strings.
- Sorts Tailwind CSS classes without causing style conflicts.

## Installation

`@destacks/tc` relies on `clsx` and `tailwind-merge` as its peer dependencies. You need to install all three for it to work properly:

```bash
npm install @destacks/tc clsx tailwind-merge
```

> 🔔 **Note**: It's essential to install both `clsx` and `tailwind-merge` along with `@destacks/tc` to avoid any potential issues.

## Usage

Example:

> Please note: the following example, though more complicated than a typical use-case, showcases the possibilities of using arrays and nested objects. For a deeper understanding of possible control structures, visit the [`clsx`](https://github.com/lukeed/clsx) project page.

```jsx
import tc from "@destacks/tc";

const Button = ({ isAlert, isActive }) => (
  <button
    className={tc(
      "bg-blue-600 text-white hover:bg-blue-700",
      isAlert && ["bg-red-300", "text-red-900", "hover:bg-red-400"],
      isActive ? { "cursor-pointer": true } : { "cursor-not-allowed": true }
    )}
  >
    Click Me
  </button>
);

export default Button;
```

## Auto-Complete in VS Code

1. [Install the "Tailwind CSS IntelliSense" extension.](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)

2. To enjoy autocompletion, add the following to your [VS Code `settings.json`](https://code.visualstudio.com/docs/getstarted/settings):

```json
{
  "tailwindCSS.experimental.classRegex": [
    ["tc\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
  ]
}
```

## Credits

The biggest shout-out goes to [`clsx`](https://github.com/lukeed/clsx) and [`tailwind-merge`](https://github.com/dcastil/tailwind-merge). TC acts as a super-thin wrapper around these libraries. They do the heavy lifting, accounting for more than 99.9% of the work, and deserve all the credit.

## License

MIT License.

## Links

- For TC's GitHub repo, visit: https://github.com/destacks/core-ts/tree/main/packages/tc
- To see TC's NPM package page, visit: https://www.npmjs.com/package/@destacks/tc

---
_Source: https://npm.io/package/@destacks/tc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
