Getting Started
Installation
Get started with Sunsato UI in your Next.js project. Follow these steps to set up the foundation.
Prerequisites
Before you begin, make sure you have the following installed:
- Node.js 18.17 or later
- A Next.js 13+ project with App Router
- Tailwind CSS configured
1. Install Dependencies
Install the required dependencies for Sunsato UI:
Terminalbash
npm install clsx tailwind-merge class-variance-authority lucide-reactFor dark mode support and toast notifications:
Terminalbash
npm install next-themes sonner2. Create Utility Functions
Create a lib/utils.ts file with the cn helper function:
lib/utils.tstypescript
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}3. Configure CSS Variables
Add the theme CSS variables to your globals.css:
app/globals.csscss
@import "tailwindcss";
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 240 5.9% 10%;
--radius: 0.625rem;
}
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--card-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 240 3.7% 15.9%;
--muted-foreground: 240 5% 64.9%;
--accent: 240 3.7% 15.9%;
--accent-foreground: 0 0% 98%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 240 4.9% 83.9%;
}4. Set up Theme Provider
Create a providers component for theme support:
components/providers.tsxtypescript
"use client";
import { ThemeProvider } from "next-themes";
import { Toaster } from "sonner";
export function Providers({ children }: { children: React.ReactNode }) {
return (
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
<Toaster position="bottom-right" />
</ThemeProvider>
);
}5. Update Root Layout
Wrap your app with the Providers component:
app/layout.tsxtypescript
import { Providers } from "@/components/providers";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<Providers>{children}</Providers>
</body>
</html>
);
}You're all set! 🎉
Now you can start copying components from the documentation and using them in your project. Check out the Theming guide to customize the look and feel of your components.