--- title: Components description: Use React components in Markdown using MDX. --- The following components are available out of the box for use in Markdown. If you'd like to build and add your own custom components, see the [Custom Components](#custom-components) section below. ## Built-in Components ### 1. Callout ```mdx This is a default callout. You can embed **Markdown** inside a `callout`. ``` This is a default callout. You can embed **Markdown** inside a `callout`. This is a warning callout. It uses the props `type="warning"`. This is a danger callout. It uses the props `type="danger"`. ### 2. Card ```mdx #### Heading You can use **markdown** inside cards. ``` #### Heading You can use **markdown** inside cards. You can also use HTML to embed cards in a grid. ```mdx
#### Card One You can use **markdown** inside cards. #### Card Two You can also use `inline code` and code blocks.
```
#### Card One You can use **markdown** inside cards. #### Card Two You can also use `inline code` and code blocks.
--- ## Custom Components You can add your own custom components using the `components` props from `useMDXComponent`. ```ts title="components/mdx.tsx" {2,6} import { Callout } from "@/components/callout" import { CustomComponent } from "@/components/custom" const components = { Callout, CustomComponent, } export function Mdx({ code }) { const Component = useMDXComponent(code) return (
) } ``` Once you've added your custom component, you can use it in MDX as follows: ```js ``` --- ## HTML Elements You can overwrite HTML elements using the same technique above. ```ts {4} const components = { Callout, CustomComponent, hr: ({ ...props }) =>
, } ``` This will overwrite the `
` tag or `---` in Mardown with the HTML output above. --- ## Styling Tailwind CSS classes can be used inside MDX for styling. ```mdx

This text will be red.

``` Make sure you have configured the path to your content in your `tailwind.config.js` file: ```js title="tailwind.config.js" {6} /** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./app/**/*.{ts,tsx}", "./components/**/*.{ts,tsx}", "./content/**/*.{md,mdx}", ], } ```