Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including hobostyle with all npm packages installed. Try it out:

var hobostyle = require("hobostyle")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

hobostyle v1.0.0

Dynamic CSS for your web page!!!

Hobo Style

Dynamic CSS for your web page!!!

How to use?

Assuming you're using browserify:

npm install hobostyle

Then

var hobostyle = require('hobostyle');
var mystyle = hobostyle.style('body { background-color: blue; }');

Then later,

mystyle.set('body { background-color: red; }');

API

Style

var mystyle = hobostyle.style(css);

This will create a new <style> element in your <head> containing css.

mystyle.set(newCss);

This will replace the original css with newCss, in the same <style> element.

mystyle.remove();

Will remove the style element.

Link

var mystyle = hobostyle.link(cssUrl);

This will create a new <link type="stylesheet" href="..."> element in your <head> linking to cssUrl.

mystyle.set(newCssUrl);

This will set the href to newCssUrl.

mystyle.remove();

Will remove the style element.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free