Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

one-spaces

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

one-spaces

A tiny module for making className 😎

  • 1.3.7
  • npm
  • Socket score

Version published
Weekly downloads
49
increased by19.51%
Maintainers
1
Weekly downloads
 
Created
Source

build npm license

One Spaces

A tiny module for making className 😎
We are striving for the best performance and lightweight.
Please check our benchmark result!!!

Installation

npm (commonjs)

npm install one-spaces

browser (iife)

Please download this file.
And embed script tag in your document.

<script src="./dist/one-spaces.js"></script>

Example

VanillaJS

var el = document.getElementById('my-element');

// arguments
el.className = OneSpaces('cls1', 'cls2', 'cls3');
// array
el.className = OneSpaces(['cls1', 'cls2'], ['cls3']);
// exclude falsy
el.className = OneSpaces('cls1', null, 'cls2', false && 'none', true && 'cls3', []);
// mix
el.className = OneSpaces(['cls1', 'cls2'], null, 'cls3');
// without one-spaces
el.className = 'cls1 cls2' + ' cls3';

React (jsx)

import React, { useState } from 'react';
import spaces from 'one-spaces';
import styles from './Page.css';

export default () => {
  const [isActive, setActive] = useState(false);
  return (
    <div className={styles.container}>
      <span className={spaces(styles.text, isActive && styles.active)}>
        Hello React!
      </span>
      <button onClick={() => setActive(!isActive)}>Toggle</button>
    </div>
  );
};

Angular & Vue

Angular and Vue have their own system for className.
Of course you can use this module with them but not recommended.

Keywords

FAQs

Package last updated on 17 Jul 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc