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

nano-css

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nano-css

Smallest 5th gen CSS-in-JS library

  • 5.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
increased by0.99%
Maintainers
1
Weekly downloads
 
Created

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

Keywords

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

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