Skip to main content

Next.js

Build static sites with Ravenbright CSS & Next.js 12. Check out the full demo on Ravenbright CSS Github repo.

View demo
tip

Make sure that you already have installed Node.js & npm CLI. read about this on npm official docs

Install Next.js

Step 1: create Next.js project

Create your project folder & run this command bellow to follow Next.js built-in installation process on your CLI

npx create-next-app@latest

Step 2: run the Next.js project

After it's finished, access the project folder & type npm run dev to start the server

cd project
npm run dev

Step 3: understand Next.js files & directory structure

├── components/
├── pages/
├── styles/
├── public/
├── next.config.js
└── package.json

Global CSS

Step 1: download or install Ravenbright

Quickly download Ravenbright source code & copy the CSS into your project folder.

Download source code

or run this command below:

npm install ravenbrightcss --save

Step 2: create the CSS folder

Put Ravenbright CSS file into styles directory

Import the Ravenbright CSS variables

Open _app.js file which located pages/. Then, import Ravenbright CSS:

pages/_app.js
---
import '../styles/ravenbright.min.css'
---
<html>
<!-- Your page here -->
</html>

Step 3: start using Ravenbright CSS utility classes, components or CSS variables

Open index.js located in pages/. Then write the following content:

pages/index.js
export default function Home() {
return (
<div>
<main>
<article class="radius-md bg-gray-100 shadow-xs">
<h1> Welcome to Ravenbright CSS </h1>
<a role="Button" class="bg-green-600 radius-md p-x-5 p-x-3">
{" "}
Get started{" "}
</a>
</article>
</main>
</div>
);
}

🎉 It's a wrap! You can check the new hero section built with Ravenbright CSS in http:localhost://3000 👈 to see the updates.

Component-based CSS

Step 1: create new Button.module.css

Put Ravenbright CSS variables and Utility classes inside Button.module.css in styles/ folder.

styles/Button.module.css
.btn {
--rbrh-green-700: #007c32;
--rbrh-spacing-4: 0.75rem;
--rbrh-spacing-5: 1rem;
--rbrh-radius-md: 0.75rem;
--rbrh-radius-sm: 0.5rem;
--rbrh-radius-xs: 0.25rem;
--rbrh-shadow-lg: 0rem 0.875rem 1.5rem -0.5rem rgba(0, 0, 0, 0.25);
cursor: pointer;
border: 0;
background: var(--rbrh-green-700);
color: white;
border-radius: var(--rbrh-radius-sm);
box-shadow: var(--rbrh-shadow-lg);
padding: var(--rbrh-spacing-4) var(--rbrh-spacing-5);
text-decoration: none;
margin: var(--rbrh-spacing-4) 0;
}
.w-fit {
width: fit-content;
}
.w-100 {
width: 100%;
}

Step 2: create a new Button.js component

Create a new Button.js component in components/.

components/Button.js
import styles from '../styles/Button.module.css'

const Button = () => {
return (
<Button
type="Button"
// Note how the "error" class is accessed as a property on the imported
// `styles` object.
className={styles.btn}
>
Get started with Ravenbright CSS
</Button>
)
}
export default Button;

Step 3: import Button on index.js

Open index.js which located in pages/ then import the Button components & it's done 🥳.

pages/index.js
import Button from "../components/Button.js";

export default function Home() {
return (
<div className="{styles.container}">
<h1> Big headline
</h1>
<p>
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<Button />
</div>
);
}

Check the new button built with Ravenbright CSS in http:localhost://3000 👈 to see the updates.