Socket
Socket
Sign inDemoInstall

@mollahdev/cssom-lite

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mollahdev/cssom-lite

Generate css with javascript


Version published
Maintainers
1
Install size
10.5 kB
Created

Readme

Source

Installation

CSSOM-Lite

CSSOM-Lite is available as an npm package.

npm:

npm i @mollahdev/cssom-lite

Import and register device:

import CSSOMLite from '@mollahdev/cssom-lite';

const sheet = new CSSOMLite();

// register devices
sheet.addDevice('mobile', 575);
sheet.addDevice('tablet', 768);
sheet.addDevice('laptop', 911);

Add custom plain css text

sheet.addCSS(`
    @import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
    * {
        margin: 0;
        padding: 0;
    }
`)

Add rule

CSSOM-lite ignores these properties/values, undefined, null, false, true, NaN, ''

sheet.addRule('.selector-a', 'background: orange');
sheet.addRule('.selector-a', 'color: white; text-decoration:none');

Add rule and remove old value

By using "remove" property like the example, you can remove already added value, note: remove property will be ignored in the final css ouput

sheet.addRule('.selector-a', 'background: orange');
sheet.addRule('.selector-a', `
    color: white; text-decoration:none;
    remove: background, border, fill;
`);

Add responsive rule

sheet.addRule('.selector-a', 'text-decoration: underline', {max: 'mobile'});
sheet.addRule('.selector-heading', 'font-size: 24px', {min: 'mobile', max: 'tablet'});

Clear everything

sheet.clear();

Get output

sheet.output()

Keywords

FAQs

Last updated on 16 Dec 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc