Kuma UI
zero-runtime CSS-in-JS with type-safe utility props
README
:construction: :rotating_light: BIG NEWS! :rotating_light: :construction:
We are taking Kuma UI to the next level. The ultimate CSS-in-JS solution is under development and we're aiming to drop the updates on July 16th, 2023. Until then, new releases will be paused. Stay tuned and get ready for the revolution 🐻❄️

Ultra Fast, Zero Runtime, Utility-First CSS-in-JS
🐻❄️ Kuma UI is a utility-first, zero-runtime CSS-in-JS library that offers an outstanding developer experience and optimized performance.
Features
🔥 Blazing-fast performance with zero-runtime CSS extraction
🦄 Build-time CSS generation
🌳 Responsive design with breakpoints and media queries
🎨 Utility-first approach for rapid UI development
👋 Support for pseudo-classes and pseudo-elements
🔬 Experimental support for Next.js 13.4 App router & React server components(RSC).
Installation
- ```sh
- npm install -D @kuma-ui/core
- ```
or
- ```sh
- yarn add @kuma-ui/core -D
- ```
Usage
styled API
The styled API works just like styled-components or Emotion, allowing you to create styled React components using tagged template literals. This makes it a familiar and comfortable choice for developers who have worked with these libraries.
- ```tsx
- import { styled } from "@kuma-ui/core";
- const Box = styled("div")`
- position: relative;
- &:hover {
- background-color: rgba(0, 0, 255, 0.5);
- }
- @media (max-width: 768px) {
- flex-direction: column;
- }
- `;
- // Then use it like so:
- <Box>Hello, world!</Box>;
- ```
k object
The k object is a key part of Kuma UI's API. It provides pre-styled HTML elements that you can use as components in your application. These elements can be styled using utility props for inline styling. The utility props are type-safe and make it easy to write responsive styles.
- ```tsx
- import { k } from "@kuma-ui/core";
- function App() {
- return (
- <k.div p={[4, 8]} m="2px" _hover={{ flexDir: "row" }}>
- hello world
- </k.div>
- );
- }
- ```
css function
The css function is another way to style your components. It takes an object of styles and returns a string of hashed classNames that you can apply to your component using the className prop.
- ```tsx
- import { css } from "@kuma-ui/core";
- const styles = css({ color: "red", fontSize: "24px" });
- function App() {
- return <div className={styles}>Hello, world!</div>;
- }
- ```
Setup
Next.js
- ```sh
- yarn add @kuma-ui/next-plugin -D
- ```
Pages Directory Version
next.config.js
- ```js
- const { withKumaUI } = require("@kuma-ui/next-plugin");
- /** @type {import('next').NextConfig} */
- const nextConfig = {
- reactStrictMode: true,
- };
- module.exports = withKumaUI(nextConfig);
- ```
App Router Version (Experimental)
next.config.js
- ```js
- const { withKumaUI } = require("@kuma-ui/next-plugin");
- /** @type {import('next').NextConfig} */
- const nextConfig = {
- reactStrictMode: true,
- experimental: {
- appDir: true
- }
- };
- module.exports = withKumaUI(nextConfig);
- ```
Vite
- ```sh
- yarn add @kuma-ui/vite -D
- ```
vite.config.ts
- ```js
- import { defineConfig } from "vite";
- import react from "@vitejs/plugin-react";
- import KumaUI from "@kuma-ui/vite";
- // https://vitejs.dev/config/
- export default defineConfig({
- plugins: [
- react(),
- KumaUI(),
- ],
- });
- ```
Responsive Design
Define the breakpoints in your config file:
- ```js
- import kumaUI from "@kuma-ui/vite";
- kumaUI({
- breakpoints: { sm: "400px", md: "700px" },
- });
- ```
Roadmap
Our ultimate goal is to develop a zero-runtime headless component library. We're currently focusing on enhancing the core and expanding our range of components. We aim to create a unique library that allows users to pass style props, operates with zero runtime, and remains accessible. In the future, we plan to introduce a kuma.config.js that allows users to define their own variants, making Kuma UI a go-to tool for creating design systems with high performance.
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests with any improvements or suggestions.
Adding a changeset
Don't forget to include a changeset as well, by running this command at the root of the project:
- ```sh
- pnpm changeset
- ```
License
MIT
探客时代
