npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stiloso

v0.5.0

Published

Create styled and classed react components

Readme

stiloso

Greenkeeper badge

Simplify creation of modules that wraps CSS frameworks with react components.

preact modules that wraps CSS frameworks often are just a collection of simple html elements components with a set of classes from the CSS framework applied.

This module simplify the creation of such react components. It export a function that return a preact component that render to an html5 tag with specified classes and styles applied.

Usage

This example create some components that wraps photonkit widgets.

It uses the html5 helpers function exported in html.

const {html, propsToClasses} = require('stiloso');
const {h} = require('preact');
const {render} = require('preact-render-to-string');

const ToolbarHeader = html.header('toolbar', 'toolbar-header');
const Window = html.main('window');
const Warning = html.span({color: 'red'});
const Title = html.h1('title', {fontSize: 40});
const Pane = html.section('pane', propsToClasses({small: 'pane-sm'}));

console.log(render(h(Window, {}, [
	h(ToolbarHeader, {}, [h(Title, {}, ['Example Window'])]),
	h(Pane, {active: true}, [h(Warning, {}, ['this is an example'])])
])));

This will output

<main class="window">
	<header class="toolbar toolbar-header">
		<h1 class="title" style="font-size: 40px;">
			Example Window
		</h1>
	</header>
	<section active class="pane">
		<span style="color: red;">
			this is an example
		</span>
	</section>
</main>

Travis Build Status NPM downloads

API

stiloso

Create a preact component that render to the specified HTML element, applying specified classes and styles. Component children will become children of the HTML element, and props will be forwarded to it as well. Class names and inline CSS styles will be coinstructed as specified below.

Parameters

  • tagName String Tagname of the html element to use for the component
  • definers (Object | Function | String) Arguments that defines classes and styles to apply to the html element. When elements are of String type, the value will be used as a class of the HTML element; When elements are simple object, they will be used as style property of the element, using normal react syntax for styles; When they are Functions, they will be called with component props as argument. The function should return a string or an array of string that will be used as classes of the HTML element.

Returns Component A stateless preact component.

partial

Partially apply a tagName and a set of definer arguments to stiloso function. Return a function that accept other definers, concatenate them to these and pass all them to stiloso function.

Parameters

  • tagName String Tagname of the html element to use for the component, required.
  • definers ...[type] Set of definers to partially apply to stiloso function.

Returns Function a stiloso function that will use given tagName and a concatenation of actual and future definers.

html

An object with methods to simplify creation of HTML5 stiloso Component. The object contain a method for each HTML5 element type.

propsToClasses

Given an object with prop names as keys and corresponding class names as values, return a definer that apply classes to the HTML element only when boolean props are present in the component.

Parameters

  • opts
  • options Object An object with prop names as keys and corresponding class names as values.

Returns Function a definer to use as stiloso argument.

Install

With npm installed, run

$ npm install stiloso

See Also

MIT License

Copyright (c) 2017 Andrea Parodi