JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q38300F
  • License MIT

A tiny React styling library inspired by styled-components

Package Exports

  • @aurhight/jsx-css

Readme

jsx-css

A tiny zero-runtime CSS-in-JS styling library for React โ€” inspired by styled-components, but minimal and fast. Built as a practice project to learn about CSS-in-JS libraries.


๐Ÿš€ Features

  • ๐ŸŽฏ Use plain object styles โ€” no tagged templates
  • โšก Runtime CSS generation using hashed classNames
  • ๐Ÿง  Supports :hover, ::after, @media, and more
  • ๐Ÿ’… Designed to be familiar for styled-components users

๐Ÿ“ฆ Installation

npm install jsx-css

โœจ Usage

import JsxCss from "jsx-css";

<JsxCss.div
  styles={{
    color: "red",
    ":hover": {
      color: "blue",
    },
    "::after": {
      content: '"๐Ÿ”ฅ"',
      display: "inline-block",
    },
    "@max-width: 600px": {
      color: "green",
    },
  }}
>
  Hello world
</JsxCss.div>

๐Ÿงช Usage with Third Party Components

  • You can use JsxCssWrapper to wrap third-party components and apply styles to them.
  • This is useful for libraries that don't support CSS-in-JS natively.
  • It works by applying the generated class name to the wrapped component.
  • Requires the className prop to be defined in the component.
import { JsxCssWrapper } from "jsx-css";
import { Button } from "some-ui-library";

<JsxCssWrapper
  styles={{
    backgroundColor: "red",
    ":hover": {
        backgroundColor: "blue",
    },
  }}
>
    <Button
      className="some-ui-library-button"
    >
      Hello world
    </Button>
</JsxCssWrapper>