🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

nano-css

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
n

nano-css

Smallest 5th gen CSS-in-JS library

5.6.2
latest
99

Supply Chain Security

100

Vulnerability

93

Quality

77

Maintenance

100

License

Version published
Weekly downloads
1.7M
-7.53%
Maintainers
1
Weekly downloads
 
Created
Issues
31

What is nano-css?

nano-css is a lightweight CSS-in-JS library that allows you to write CSS styles directly in your JavaScript code. It is designed to be minimal and efficient, making it suitable for performance-critical applications.

What are nano-css's main functionalities?

Basic Styling

This feature allows you to define basic CSS styles using JavaScript objects. The `rule` function generates a class name that can be applied to HTML elements.

const { create } = require('nano-css');
const { addon: addonRule } = require('nano-css/addon/rule');
const nano = create();
addonRule(nano);
const { rule } = nano;
const button = rule({
  backgroundColor: 'blue',
  color: 'white',
  padding: '10px 20px',
  border: 'none',
  borderRadius: '5px'
});
console.log(button); // Outputs the generated class name

Keyframes

This feature allows you to define CSS keyframes for animations. The `keyframes` function generates a name for the keyframes that can be used in your styles.

const { create } = require('nano-css');
const { addon: addonKeyframes } = require('nano-css/addon/keyframes');
const nano = create();
addonKeyframes(nano);
const { keyframes } = nano;
const fadeIn = keyframes({
  from: { opacity: 0 },
  to: { opacity: 1 }
});
console.log(fadeIn); // Outputs the generated keyframes name

Global Styles

This feature allows you to define global CSS styles that apply to the entire document. The `global` function takes an object where the keys are selectors and the values are style objects.

const { create } = require('nano-css');
const { addon: addonGlobal } = require('nano-css/addon/global');
const nano = create();
addonGlobal(nano);
const { global } = nano;
global({
  body: {
    margin: 0,
    padding: 0,
    fontFamily: 'Arial, sans-serif'
  }
});

Other packages similar to nano-css

FAQs

Package last updated on 20 Jul 2024

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