# @whitetrefoil/classnames-bind-tag

> A tiny wrapper of `classnames` which exports a "template tag" plus a bound function just like the original `classnames/bind`.

Latest version **0.5.0** (published 2020-05-06) · Unlicense license · 0 weekly downloads

## Install

```sh
npm install @whitetrefoil/classnames-bind-tag
pnpm add @whitetrefoil/classnames-bind-tag
yarn add @whitetrefoil/classnames-bind-tag
bun add @whitetrefoil/classnames-bind-tag
```

## 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.5.0 |
| Published | 2020-05-06 |
| First published | 2018-12-05 |
| Weekly downloads | 0 |
| License | Unlicense |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | WhiteTrefoil |
| Maintainers | whitetrefoil |

## Links

- npm: https://www.npmjs.com/package/@whitetrefoil/classnames-bind-tag
- Repository: https://github.com/whitetrefoil/classnames-bind-tag
- Homepage: https://github.com/whitetrefoil/classnames-bind-tag#readme
- Issues: https://github.com/whitetrefoil/classnames-bind-tag/issues
- npm.io page: https://npm.io/package/@whitetrefoil/classnames-bind-tag

## Dependencies (1)

- [classnames](https://npm.io/package/classnames.md) ^2.2.6

## Recent versions

- 0.5.0 (latest) — 2020-05-06
- 0.4.0 — 2019-11-07
- 0.3.0 — 2018-12-10
- 0.2.0 — 2018-12-05
- 0.1.0 — 2018-12-05

## README

classnames-bind-tag
=====================================================

A tiny wrapper of [`classnames`](https://github.com/JedWatson/classnames) which exports a ["template tag"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates) plus a bound function just like the original [`classnames/bind`](https://github.com/JedWatson/classnames#alternate-bind-version-for-css-modules).

Important
---------

If your code isn't targeting the latest syntax spec of JS / ES,
please use something like babel to transfer this library.

Usage
-----

For example, we have a module CSS file "MyComp.css" exports `.my-comp` as `QWERTYASDFGZXCVB` and `.another` as `ZCXZCZXC`.

```tsx
import bindCss from '@whitetrefoil/classnames-bind-tag'
import * as css from './MyComp.css'

// "c" is a template tag
// "cs" is same as "c" but will drop unresolved classes
// "cx" is same as the original `classnames/bind`
const { c, cs, cx } = bindCss(css);
const classNameFromProps = 'another';

console.log(c`my-comp ${classNameFromProps} non-existing "xxx"`)
// => "QWERTYASDFGZXCVB ZCXZCZXC non-existing xxx"

console.log(cs`my-comp ${classNameFromProps} non-existing 'xxx'`)
// => "QWERTYASDFGZXCVB ZCXZCZXC xxx"

// `my-comp` will be resolved to actual class name.
// `${classNameFromProps}` will first resolve to `another` then actual class name.
// `non-existing` will be preserved in `c()` but not in `cs()`.
// texts in quotes (`"` or `'`) will be output as-is.
```

Changelog & Roadmap
-------------------

### v0.5.0

* Update a lot of stuff to latest.

### v0.4.0

* Add a new `cs()` as a "stricter `c()`", which will drop non-existing classes.
* Don't add variable name in the output.
* Texts in quotes will be preserved.
* Upgrade dependencies.

### v0.3.0

* Even a mapped value is found in css module, the original string will be preserved.

### v0.2.0

* Add support for templates with inline expressions.

### v0.1.0

* Initial release.

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