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 🙏

© 2025 – Pkg Stats / Ryan Hefner

html-styled

v1.17.2

Published

HTML for React with styled-system props

Readme

html-styled

HTML for React with styled-system props

npm GitHub Workflow Status

Documentation

You can find the full documentation at html-styled.now.sh, which is also built with html-styled! View the code in the docs folder in this repository.

Getting Started

This package is for projects using React that allows you to write HTML elements in which you can pass responsive style props easily. Normally when we write and style HTML elements in React we use the standard style props as follows:

<p style={{ color: "red", fontSize: "18px" }}>Hello world!</p>

The syntax is a little bit clunky, and gets a bit harder to read as we add more and more css rules. And if we wanted to make it responsive, e.g change the font size on smaller screens, we'd need to give it a class name and write some bulky CSS media queries. We also can't access selectors like :hover at all this way.

Using this package means that we get a nicer style props syntax, and can easily make this responsive using Styled System's responsive style syntax. With this in mind, the example above becomes:

<P color="red" fontSize={["16px", "18px"]}>
  Hello world!
</P>

Now instead of using the standard style prop we have a prop for every css property, e.g color and fontSize. If we want to make a property responsive we simply pass an array of strings instead of just one string, where each element in the array applies the rule to a certain screen size. In this example, the font size is 16px on small screens, and 18px on all larger screens. Notice that <p> becomes <P>.

Another benefit we get is access to direct CSS selector props. This means that we can add rules for selectors such as:hover directly through a prop in React. To change color, for example, on hover we do the following:

<P color="red" hover={{ color: "blue" }}>
  Hello world!
</P>

By adding a CSS selector name such as hover as a prop we get quick, direct access to selectors we want to use and don't have to write separate css or use bulky template literals. Taking this even further we can combine this with the responsive syntax:

<P color="red" hover={{ color: ["green", "blue"] }}>
  Hello world!
</P>

Now when we hover on small screens the color is green, and on larger screens it is blue - no bulky CSS with media queries required and not a template literal in sight!

Installation

Install html-styled and its peer dependencies.

yarn add html-styled styled-system @styled-system/css styled-components

or

npm install html-styled styled-system @styled-system/css styled-components

What are peer dependencies?

These are dependencies that we rely on, but instead of bundling them in our package we get you to install them separately. This keeps our package size down and allows you to install specific versions of each dependency if you need to.

FAQ

Why would I use this?

  • [x] You're hacking together a small app with React
  • [x] You're fine using HTML but also need a bit more to quickly prototype
  • [x] You like styled-system's features like style props and reponsive props but can't be bothered setting it up

Is it good for bigger projects?

Probably not, since it's essentially just inline css but easier and this isn't very scalable. However, you can make reusable components with them and make you're own mini design system if desired.

Why are the components in uppercase?

Believe it or not, HTML element names are case insensitive, so uppercase HTML elements are actually valid syntax. However, since conventionally developers use lowercase element names you can easily spot which elements you write are standard HTML and which ones are from html-styled. React component names are normally just capitalised as well, so you can also distunguish between normal components and html-styled components.