Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add notes on Tailwind config to mdx-components.tsx documentation #74241

Open
wants to merge 1 commit into
base: canary
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions docs/01-app/03-building-your-application/07-configuring/05-mdx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,11 @@ export default function MDXPage({ children }) {

</PagesOnly>

### Using Tailwind typography plugin
### With Tailwind CSS

If you are using [Tailwind](https://tailwindcss.com) to style your application, using the [`@tailwindcss/typography` plugin](https://tailwindcss.com/docs/plugins#typography) will allow you to reuse your Tailwind configuration and styles in your markdown files.
#### Using the Tailwind typography plugin

If you are using [Tailwind CSS](https://tailwindcss.com) to style your application, using the [`@tailwindcss/typography` plugin](https://tailwindcss.com/docs/plugins#typography) will allow you to reuse your Tailwind configuration and styles in your markdown files.

The plugin adds a set of `prose` classes that can be used to add typographic styles to content blocks that come from sources, like markdown.

Expand Down Expand Up @@ -597,6 +599,51 @@ export default function MDXPage({ children }) {

</PagesOnly >

#### Using Tailwind classes in `mdx-components.tsx`

If you want to use custom Tailwind classes inside `mdx-components.tsx`, you need to add the path to `mdx-components.tsx` to your Tailwind configuration file for Tailwind to discover those classes.

```ts filename="tailwind.config.ts" highlight={8} switcher
import type { Config } from 'tailwindcss'

export default {
content: [
'./app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory.
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./mdx-components.{js,ts,jsx,tsx}',

// Or if using `src` directory:
// No changes are needed because mdx-components.tsx is already covered
'./src/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
} satisfies Config
```

```js filename="tailwind.config.js" highlight={7} switcher
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./app/**/*.{js,ts,jsx,tsx,mdx}', // Note the addition of the `app` directory.
'./pages/**/*.{js,ts,jsx,tsx,mdx}',
'./components/**/*.{js,ts,jsx,tsx,mdx}',
'./mdx-components.{js,ts,jsx,tsx}',

// Or if using `src` directory:
// No changes are needed because mdx-components.tsx is already covered
'./src/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {},
},
plugins: [],
}
```

## Frontmatter

Frontmatter is a YAML like key/value pairing that can be used to store data about a page. `@next/mdx` does **not** support frontmatter by default, though there are many solutions for adding frontmatter to your MDX content, such as:
Expand Down
Loading