# @sunpietro/css-classnames

> A tiny helper to generate CSS classes based on provided conditions

Latest version **1.0.1** (published 2019-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sunpietro/css-classnames
pnpm add @sunpietro/css-classnames
yarn add @sunpietro/css-classnames
bun add @sunpietro/css-classnames
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-08-07 |
| First published | 2019-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Piotr Nalepa |
| Maintainers | sunpietro |
| Keywords | css, classnames, helper |

## Links

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

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-08-07
- 1.0.0 — 2019-08-07

## README

# css-classnames
A simple helper to generate CSS class names string based on provided conditions

## Usage sample

First of all you need to install the package in your project by running:

`npm install @sunpietro/css-classnames`

or 

`yarn install @sunpietro/css-classnames`

or by downloading files from this repository and including the file `css-classnames.min.js` in your HTML code using `script` tag:

`<script async src="./js/css-classnames.min.js"></script>`

Then if you installed it using either NPM or Yarn, you can start using it the following way:

```javascript
import * as classnames from '@sunpietro/css-classnames';

const isFluid = true;
const items = [1, 2, 3];
const classNameString = classnames({
    'container': true,
    'container--fluid': isFluid,
    'container--filled': items.length > 1,
    'container--empty': false
});

console.log(classNamesString);
// The output: 'container container--fluid container--filled'
```

Otherwise, the script above will slightly change to:

```javascript
const isFluid = true;
const items = [1, 2, 3];
const classNameString = window.classnames({
    'container': true,
    'container--fluid': isFluid,
    'container--filled': items.length > 1,
    'container--empty': false
});

console.log(classNamesString);
// The output: 'container container--fluid container--filled'
```

## Feedback and issues

If you have any feedback, please create an issue in this repository

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