Styling Guide

Styling Guide

For more information on how to style your markdown in Nextra, please refer to the official Nextra docs (opens in a new tab)

Blockquote

Blockquotes can be styled by adding a class to the blockquote element.

Blockquote example 1
> Your text here

>

Blockquote example 2
<blockquote className="info">Your text here</blockquote>
className=""
className="info"
className="example"
className="warning"
className="error"

Callout

Calloutes can be styled by adding a type to the Callout element. To use the Callout component you must first import it from nextra/components.

Callout example
import { Callout } from "nextra/components"
 
<Callout type="default">Your text here</Callout>
💡
type="default"
type="info"
⚠️
type="warning"
🚫
type="error"

Code

All code blocks should be wrapped in triple backticks, as well as contain the copy class, and optional filename.

Markdown
```mdx copy filename="<filename>"
This is a code block
```

Code blocks can also be syntax highlighted by specifying the language after the first set of backticks.

Markdown
```js
const foo = "bar"
```

Substring and line highlighting is possible by specifying them after the language.

Substring highlighting
```js /const/
const foo = "bar"
```
Line highlighting
```js {1,4-5}
import { useState } from "react"
 
function Counter() {
  const [count, setCount] = useState(0)
  return <button onClick={() => setCount(count + 1)}>{count}</button>
}
```

Images

Markdown
import Image from "next/image"
 
<Image src="/demo.png" alt="Hello" width={500} height={500} />

We recommend using static image imports using Markdown. Nextra will automatically optimize the images for you.

Markdown
![demo](/demo.png)
💡

The above code will load the image from the public directory. If you want to load an image from a different directory, you can use the reative path to the image.

Markdown
![demo](../somewhere/demo.png)

Result:

hhn docs

Custom CSS

We already support tailwind CSS out of the box. If you want to add your own custom CSS classes, you can do so by adding them to the globals.css file, inside the pages directory.

globals.css
.custom-class {
  color: red;
}

More coming soon...