Next.js
Step-by-Step configuration for Next.js
Initialize a NextJS Project
If you donβt already have a Next.js project set up, you can follow the official Next.js setup guide to create a new project quickly.
Make sure you have Tailwind installed
Follow these instructions if you don't have Tailwind installed in your project. You just need to have a globals.css
and tailwind.config.{js,ts}
. They will be overwritten by our CLI.
Add AlignUI Styles
That's all! Now you have all AlignUI tokens.
Add the required utils
- Go to cn page and setup the utility in your project.
- Go to tv page and setup the utility in your project.
- Go to recursiveCloneChildren page and setup the utility in your project.
- Go to Polymorphic page and setup the utility in your project.
Add the icon library
AlignUI uses Remix Icon.
Setup Inter font
Include Inter font from 'next/font/google'
:
Then apply the --font-sans
variable as the default tailwind font.
Add Dark Mode (Optional)
All you need to do to enable dark mode in your app is add the dark
class to your root element.
We need to include the 'dark'
class in the safelist in Tailwind Config. Otherwise, dark colors will not be included if the 'dark'
class is absent in your JSX at build-time.
I recommend next-themes package for an easy dark mode toggle in your app. Simply follow the instructions on the page.
That's all!
Now you can start adding components to your app. You can begin by adding a button first.