Playground

Next.js

Load the stylesheet in the App Router layout and use Monoline from Server and Client Components.

Installation

  1. Install the packages

    npm install @monoline/react @monoline/css
    
  2. Load the stylesheet in the layout

    App Router. Import it once, before your own CSS.

    app/layout.tsx
    import '@monoline/css';
    
    export default function RootLayout({children}: {children: React.ReactNode}) {
      return <html lang="en"><body>{children}</body></html>;
    }
    
  3. Use a component

    Components that use state or handlers carry 'use client' themselves, so a Server Component file can import and render them.

    app/page.tsx
    import {Button} from '@monoline/react';
    
    export default function Page() {
      return <Button>Save</Button>;
    }
    

Theme and accent

Set the attributes on <html> so the first paint already has the right look.

app/layout.tsx
<html lang="en" data-theme="warm" data-accent="blue">