Admonitions
Admonitions let you highlight important information in your docs using a simple Markdown syntax.
They render as colorful callout boxes like Tips, Notes, Warnings, etc.
Basic Syntaxβ
Wrap your text with 3 colons and specify a type:
:::note
This is a note block with **Markdown** support.
:::
This is a note block with Markdown support.
Supported types: note
, tip
, info
, warning
, danger
Examplesβ
:::tip
Great for best practices or quick advice.
:::
:::info
Use to provide additional context.
:::
:::warning
Warn users of potential issues.
:::
:::danger
Critical alerts or breaking changes.
:::
Great for best practices or quick advice.
Use to provide additional context.
Warn users of potential issues.
Critical alerts or breaking changes.
Adding a Custom Titleβ
You can provide a custom title (with Markdown too):
:::note[Your **Custom** _Title_]
This callout uses a custom title.
:::
This callout uses a custom title.
Nested Admonitionsβ
Admonitions can be nested for layered messages.
Use more colons :
for each parent level:
::::info[Outer]
Outer content
:::warning[Inner]
Inner content
:::
::::
Outer content
Inner content
Using MDX Insideβ
Admonitions fully support MDX components.
:::tip[Tabbed Example]
<Tabs>
<TabItem value="react" label="React">React example π</TabItem>
<TabItem value="vue" label="Vue">Vue example πΏ</TabItem>
</Tabs>
:::
- React
- Vue
Using in JSXβ
Outside Markdown, use the React component directly:
import Admonition from '@theme/Admonition';
export default function MyPage() {
return (
<Admonition type="tip" icon="π‘" title="Did you know?">
You can use Admonitions directly in JSX too!
</Admonition>
);
}
You can use Admonitions directly in JSX too!
Customizing Admonitionsβ
Custom Icons or Stylingβ
You can override default icons by swizzling the Admonition theme component:
import React from 'react';
import Admonition from '@theme-original/Admonition';
import MyIcon from '@site/static/img/custom-icon.svg';
export default function AdmonitionWrapper(props) {
if (props.type === 'info') {
return <Admonition icon={<MyIcon />} {...props} />;
}
return <Admonition {...props} />;
}
Add New Typesβ
Add a new keyword in docusaurus.config.js
:
export default {
presets: [
[
'classic',
{
docs: {
admonitions: {
keywords: ['my-callout'],
extendDefaults: true,
},
},
},
],
],
};
Then create a custom renderer:
import React from 'react';
import DefaultTypes from '@theme-original/Admonition/Types';
function MyCallout(props) {
return (
<div style={{border: '2px dashed #ff9800', padding: 12}}>
<h4>{props.title || 'β‘ My Callout'}</h4>
{props.children}
</div>
);
}
export default {
...DefaultTypes,
'my-callout': MyCallout,
};
Now you can use:
:::my-callout[Custom Callout]
This is a completely custom admonition.
:::
Best Practicesβ
- Always leave blank lines inside admonitions to avoid Prettier formatting issues.
- Use icons and concise titles to improve readability.
- Keep admonitions focusedβavoid stuffing too much content.