codehz / css-in-bun

CSS-in-Bun macro inspired by Meta's stylex (and johanholmerin/style9)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CSS-in-Bun macro inspired by Meta's stylex (and johanholmerin/style9)

Usage:

// build.ts
import { getGeneratedCss } from "css-in-bun/build";

const res = await Bun.build({
  entrypoints: ["./src/index.ts"],
  outdir: "dist",
});

const css = getGeneratedCss();

await Bun.write("./dist/style.css", css);

// component.tsx
import { create } from "css-in-bun" assert { type: "macro" };
const styles = create({
  test: {
    color: "red",
    backgroundColor: "green",
    "@media (min-width: 80em)": {
      color: "purple",
      ":hover": {
        color: "black",
      },
    },
    ":hover": {
      color: "yellow",
    },
  },
});

const Test = () => <div className={styles.test}></div>

Due to bun's bug(oven-sh/bun#6014), use keyframes may cause bun crash.

About

CSS-in-Bun macro inspired by Meta's stylex (and johanholmerin/style9)

License:MIT License


Languages

Language:TypeScript 93.8%Language:JavaScript 6.2%