Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hosseind88/conditional-class
A conditional classname builder util
https://github.com/hosseind88/conditional-class
classnames css html scss web
Last synced: 7 days ago
JSON representation
A conditional classname builder util
- Host: GitHub
- URL: https://github.com/hosseind88/conditional-class
- Owner: hosseind88
- License: mit
- Created: 2021-04-25T11:36:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-01T13:19:08.000Z (over 2 years ago)
- Last Synced: 2024-12-08T14:39:54.699Z (about 1 month ago)
- Topics: classnames, css, html, scss, web
- Language: TypeScript
- Homepage:
- Size: 37.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# conditional-class [![NPM version](https://img.shields.io/npm/v/conditional-class.svg?style=flat)](https://www.npmjs.com/package/conditional-class) [![NPM monthly downloads](https://img.shields.io/npm/dm/conditional-class.svg?style=flat)](https://npmjs.org/package/conditional-class) [![NPM total downloads](https://img.shields.io/npm/dt/conditional-class.svg?style=flat)](https://npmjs.org/package/iconditional-class) [![Build Status](https://travis-ci.com/hosseind88/conditional-class.svg?branch=main)](https://travis-ci.com/hosseind88/conditional-class)
> adds your conditional classnames to the base classname
Please follow me and consider starring the project to show your :heart: and support.
## Install
Install with [npm](https://www.npmjs.com/):
```sh
$ npm install --save conditional-class
```## Usage
Works with strings or numbers.
```js
import { conditionalClass } from 'conditional-class';console.log(condionalClass('some-class')); //=> some-class
console.log(condionalClass('some-class', { 'is-active': true })); //=> some-class is-active
console.log(condionalClass(undefined, { 'is-active': true })); //=> is-active
console.log(condionalClass(['class'], { 'is-active': true })); //=> class is-active
```### License
Copyright © 2021, [Hossein Dindar](https://github.com/hosseind88).
Released under the [MIT License](LICENSE).