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

airstyle

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airstyle

A lightweight JS library to style elements. Compatible with almost every modern JS Framework and library

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-62.5%
Maintainers
1
Weekly downloads
 
Created
Source

Airstyle

A lightweight 275 bytes ( airstyle.min.js ) JavaScript library to style HTML elements with JS as easy as possible.

Installation

With npm and Browserify do:

$ npm install -g browserify

Alternatively install it via unpkg

<script src="https://unpkg.com/airstyle"></script>

Basic Usage

<div class="myClass">
	<p id="myText">airstyle.js</p>
</div>
const airstyle = require("airstyle")

// basic syntax
airstyle(element, style)

// style:string
airstyle(".myClass", "width: 200px; height: 200px; border: 1px solid #000000")

// style:object
airstyle("#myText", {
	color: "red",
    "font-size": "40px",
    "font-family": "Arial"
})

Extended usage

You can select an element also with a longer selector.

airstyle("div.user-panel.main input[name=login]", style)

Airstyle is also compatible with almost every JS Framework. Tested in Angular, React and Vue.

Vue example
<div id="root">
	<div class="container">
    	<p>Hi!</p>
    </div>
</div>
const style = require("airstyle")
new Vue({
    el: "#root",
	data: {
    	color: "red",
        size: "20px"
    },
    methods: {
    	setStyle(){
        	style(".container p", {
            	color: this.color,
                "font-size": this.size
            });
        }
    },
    mounted(){
    	this.setStyle();
    }
})
React example
<div id="root"></div>
const style = require("airstyle")
class App extends React.Component {
	constructor(){
    	super();
        this.state = {
        	color: "red",
            size: "20px"
        }
    }
    componentDidMound(){
    	style(".container p", {
        	color: this.state.color,
            "font-size": this.state.size
        });
    }
    render(){
    	return (
        	<div className="container">
            	<p>Hi!</p>
            </div>
        )
    }
}

Keywords

FAQs

Package last updated on 05 Jan 2018

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