Installation
Get started with Grauity by installing the package and configuring your project.Prerequisites
Before installing Grauity, ensure your project meets these requirements:Grauity requires Node.js 18.0.0 or higher and npm 9 or higher.
Step 1: Install the package
Install Grauity and peer dependencies
Install
@newtonschool/grauity along with its required peer dependencies:Peer dependencies:
react>= 18.2.0react-dom>= 18.2.0styled-components>= 6.1.14
Step 2: Set up the theme provider
Wrap your app with GrauityThemeProvider
Grauity uses
GrauityThemeProvider to enable theming support. Wrap your root component with this provider:App.tsx
Understanding theming (optional)
Without the
GrauityThemeProvider, only foundational (theme-agnostic) CSS variables will be available. The provider adds:- Global theme context - Access to light/dark theme variables
- Theme scoping - Use
NSThemeScopeto apply different themes to sections - Dynamic theming - Switch themes at runtime
ThemeProvider and injects both light and dark theme configurations:Step 3: Import and use components
You’re ready to use Grauity components! Import them from the main package:Example.tsx
TypeScript configuration
Grauity is built with TypeScript and includes type definitions. No additional setup is required, but ensure yourtsconfig.json includes:
tsconfig.json
Build tool configuration
Webpack
If you’re using Webpack, ensure you have loaders for SCSS:webpack.config.js
Vite
For Vite, install sass:Next.js
For Next.js, install sass:_app.tsx:
pages/_app.tsx
Theme scoping (advanced)
UseNSThemeScope to apply different themes to specific sections of your app:
Legacy theme classes (optional)
If you’re not usingGrauityThemeProvider, you can control theming with CSS classes:
This approach is considered legacy. We recommend using
GrauityThemeProvider and NSThemeScope for better theme management.Verify installation
Create a simple test component to verify everything is working:Test.tsx
Next steps
Quickstart tutorial
Build your first component with Grauity
Component documentation
Explore all available components
Troubleshooting
Icons not showing
Icons not showing
Make sure you’ve imported the icon CSS:Also verify that your build tool (Webpack, Vite, etc.) is configured to handle SCSS imports.
Styled-components errors
Styled-components errors
Ensure you have the correct version of styled-components installed:For Next.js, make sure you’ve configured SSR support for styled-components.
TypeScript errors
TypeScript errors
If you’re getting TypeScript errors, ensure your
tsconfig.json has:"jsx": "react-jsx"or"jsx": "react""esModuleInterop": true"skipLibCheck": true
Theme not applying
Theme not applying
Make sure you’ve wrapped your app with
GrauityThemeProvider: