Installation
How to install dependencies and structure your app.
Frameworks
DGI-UI is currently built for Next.JS / React projects. We'll focus on setting up the necessary dependencies and files for your project.
Create your NEXT.JS project
Begin with creating a new Next.js project using create-next-app:
Typescript
DGI-UI components are built with TypeScript, a move that's not just technical but strategic. TypeScript isn't just a language; it's a safeguard that enhances your code’s durability, catching errors before they spiral into nightmares. It offers a smoother ride with your IDE, making autocompletion and type checking seamless. This is how our components reach their fullest potential. Still, we're looking to extend our components to JavaScript in the not-so-distant future.
Typescript DocumentationTailwind
DGI-UI leans on Tailwind CSS to handle its component styling. We’re toying with the idea of rolling out support for CSS and SASS down the line. Stay tuned, because we're always cooking up something new.
Tailwind DocumentationGlobal CSS
DGI-UI leverages CSS variables to maintain a unified design system, streamlining the process for any future tweaks or overhauls.
Copy and paste the following code into your global.css
file.
Tailwind Config
Now that we have added all our CSS variables to our global.css
file, we need to update our Tailwind configuration.
Copy and paste the following code into your tailwind.config.js
file.
Classname Helper Function Dependencies
The bulk of our components lean on a cn
helper function to mash classnames together. This lets us slap styles
straight onto the core component while layering on extra flair wherever we deploy that component.
Install the following dependencies:
Class Variance Authority
The Class Variance Authority, or cva
, is your tool for managing component style variants with the ease. With
the cva
function, you can tack on a variety of style variants to your base component. This method lets you
use different styles on your components wherever they're needed, streamlining your workflow and making your
design tight and consistent.
When diving into the world of cva
with Tailwind CSS, there are some extra steps you can take to get
the most from cva
: Enable autocompletion within cva
for a smoother ride.
Tailwind Merge
Tailwind Merge is a sleek utility that slices through the tangled web of Tailwind CSS classes in your JavaScript, ensuring you sidestep those pesky style conflicts. It's the sharp tool in the kit, making your styling operations easy peasy.
Tailwind Mergeclsx
A little (234B) dynamo for piecing together className
strings on a conditional basis.
Classname Helper Function
Now that we've got all the essential dependencies squared away, it's time to set
up the cn
helper function.
Head over to your lib
folder and drop this code into your utils.ts
file.
Lucid Icons
Certain components in this system lean on Lucid Icons. But remember, it's your code, your rules. You're free to swap in any icon library that suits your taste. If you fancy the seamless integration of Lucid's icons right from the get-go, just install this dependency:
Optional Installs
Automatic Class Sorting with Prettier
A plugin for Tailwind CSS that grabs your Tailwind classes, lines them up, and sorts them with precision, adhering strictly to the recommended class order. No more chaos, no more guesswork, ensuring every class is exactly where it should be. Clean and efficient.
Prettier Tailwind Plugin Documentation