This guide shows how to use the unified @j-cam/bttn package in a Next.js project (App Router).
npm install @j-cam/bttnImport the CSS in your root layout.tsx:
// app/layout.tsx
import "@j-cam/bttn/styles.css";
export default function RootLayout({ children }) {
return (
<html>
<body>{children}</body>
</html>
);
}The Button component is marked with "use client", so you can use it in both Client and Server components (it will hydrate correctly).
// app/page.tsx
import { Button } from "@j-cam/bttn/react";
export default function Page() {
return (
<main>
<h1>Welcome to bttn</h1>
{/* Standard usage */}
<Button variant="pill" color="primary">
Get Started
</Button>
{/* Polymorphic: Renders as a Next.js Link */}
<Button as="a" href="/docs" variant="ghost">
Read Docs
</Button>
{/* Custom Theme */}
<Button
variant="stroke"
customTheme={{
bg: '#7c3aed',
color: '#fff'
}}
>
Custom Purple
</Button>
</main>
);
}Since the library uses CSS variables, you can override them in your global CSS:
/* app/globals.css */
:root {
--bttn-primary-bg: #ff00ff;
--bttn-radius-pill: 4px; /* Make pills less round */
}