Use Kivu UI with the App Router, Server Components and next/font.
On this page
Kivu UI works with the Next.js App Router out of the box. The bundle is marked "use client", so you can render components directly from Server Components.
npm install kivu-ui@import "tailwindcss";
@import "kivu-ui/styles.css";
@import "kivu-ui/tailwind.css";import { Martel_Sans } from "next/font/google";
import "./globals.css";
const martel = Martel_Sans({ subsets: ["latin"], weight: ["400", "600", "700"], variable: "--font-martel" });
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en" className={martel.variable}>
<body>{children}</body>
</html>
);
}Point the tokens at the font variables:
:root {
--kivu-font-display: var(--font-martel);
--kivu-font-body: var(--font-martel);
}Static components render fine in a Server Component:
import { Button, SectionHeader } from "kivu-ui";
export default function Page() {
return <SectionHeader title="Welcome" actions={<Button>Start</Button>} />;
}Anything with state or event handlers (opening a Modal, a controlled Tabs) belongs in a file marked "use client", like any other React code.
Use asChild to give Next.js Link button styles:
import Link from "next/link";
import { Button } from "kivu-ui";
<Button asChild>
<Link href="/projects/new">New project</Link>
</Button>