koss
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

KOSS - A performant and flexible CSS-in-JS library.

Quick Start

Install

npm i -S koss

Usage

import { CSSManager } from "koss";

// Create a custom theme.
const theme = {
    isDarkTheme: true,
    accent: "hsla(250, 50%, 50%)",
    foreground: "#fff",
    background: "#333",
};
// Create a cssManager instance.
const cssManager = new CSSManager(theme);

// feat: Object style.
const className = cssManager.addStyle({ color: "yellow", fontSize: 12 });

// feat: Multiple key styles.
const classNames = cssManager.addStyles({
    app: {
        // feat: Functional value support.
        color: theme => theme.isDarkTheme ? "#fff" : "#1a1a1a",
        // feat: Pseudo selector.
        "&:hover": {
            opacity: .75,
        },
        // feat: Calculation selector.
        "& > header": {
            opacity: .5,
        },
        // feat: Media Query.
        "@media (min-width: 420px)": {
            background: "transparent"
        } as KoCSSProperties,
    },
});

// feat: Template string.
const colorCls = cssManager.css
`font-size: ${14}px;
color: red;
`;

// feat: Selector style support.
cssManager.addSelectorStyle("html", {
    background: "#282c34"
});

// feat: Keyframes support.
cssManager.addKeyframes("App-logo-spin", {
    from: {
        transform: "rotate(0deg)",
    },
    to: {
        transform: "rotate(360deg)"
    }
});

Readme

Keywords

none

Package Sidebar

Install

npm i koss

Weekly Downloads

1

Version

1.0.8

License

none

Unpacked Size

63.2 kB

Total Files

35

Last publish

Collaborators

  • ~myxvisual
  • tiila.com