Getting Started
@kaiverse/k is a collection of powerful utilities, custom React hooks, and fully featured “uncommon” React components.
Installation
Section titled “Installation”pnpm add @kaiverse/knpm i @kaiverse/kyarn add @kaiverse/kPackages
Section titled “Packages”@kaiverse/k/ui: some rarely used React components.@kaiverse/k/hooks: Hooks.@kaiverse/k/utils: Utility functions.
If you are looking for a Design system or a component library with a wide range of components from basic (eg: <Button>, <Input>, <Layout>) to complex (such as <RichTextEditor>, <Chart>),
I highly recommend checking out shadcn UI, Mantine, and daisyui.
Usage with Server Components
Section titled “Usage with Server Components”All @kaiverse/k/ui components already have 'use client'; directive at the top of the file.
Usage with Next.js
Section titled “Usage with Next.js”To use @kaiverse/k with Next.js, adding the following to your next.config file:
const nextConfig = { ..., // other next config transpilePackages: ['@kaiverse/k'],}app router - tree shaking
Section titled “app router - tree shaking”To enable tree shaking with app router, enable experimental optimizePackageImports feature:
const nextConfig = { ..., // other next config transpilePackages: ['@kaiverse/k'], experimental: { ..., // other experimental flags optimizePackageImports: ['@kaiverse/k'], },}Usage with Astro
Section titled “Usage with Astro”Please make sure your Astro project supports React. If not, follow the official integration guide.
Remember to add client directive to make sure components are rendered on the client side.
Terminal in Astro island
Try type something and then command clear to clear the logs.
---import {Terminal} from '@kaiverse/k/ui'---
<div class="container mx-auto not-content"> <Terminal windowTitle="Terminal in Astro island" greeting="Try type something and then command clear to clear the logs." client:load /></div>Children passing
Section titled “Children passing”Children passed into a React component from an Astro component are parsed as plain strings, not React nodes.
Enable the experimental flag experimentalReactChildren to make it work via astro.config file.
Read more
Please note that there is some runtime cost to this.
import { defineConfig } from 'astro/config';import react from '@astrojs/react';
export default defineConfig({ ..., // other astro config integrations: [ react({ experimentalReactChildren: true, }), ],});Integration
Section titled “Integration”TailwindCSS
Section titled “TailwindCSS”Since @kaiverse/k/ui component CSS rules are applied within k-components layer. If you are facing issues with TailwindCSS styles overriding @kaiverse/k/ui styles or vice versa,
you might need to update the order of precedence in case of multiple cascade layers.
@layer base, k-components, theme, components, utilities;
@import 'tailwindcss';