MDX Notes
How to use Docusaurus callout boxes — note, tip, info, caution, danger — plus custom types, icons, and styling
Admonitions are those colored callout boxes you see in good docs — "hey, watch out for this" or "pro tip: do it this way." Docusaurus has them built in. No plugins needed. Just triple-colons and go.
Basic Admonition Syntax
The format is dead simple:
That's it. Three colons, the type, optional title in brackets, your content, three colons to close.
The Five Built-in Types
Note
For extra context that's good to know but not critical:
:::note
React 18+ is required for this feature. Check your `package.json`
to verify your React version.
:::Visual Result: A grey/blue box with an "ℹ️" icon and "NOTE" header. Subtle, doesn't scream for attention.
Tip
For helpful suggestions and best practices:
Visual Result: A green box with a "💡" lightbulb icon. Green = positive/helpful.
Info
For explanations and context:
Visual Result: A blue box with an "ℹ️" info icon. More vivid blue than Note — for when you're explaining something.
Caution
For "heads up, this might bite you":
// Before (v2) remarkPlugins: [require('plugin'), { option: true }]
// After (v3) remarkPlugins: [[require('plugin'), { option: true }]]
:::Visual Result: A yellow/amber box with a "⚠️" warning triangle. The warm color says "proceed carefully."
Danger
For serious stuff — data loss, security issues, things that can't be undone:
Visual Result: A red box with a "🔥" or "⛔" icon. Red = stop and pay attention.
Custom Admonition Titles
Override the default title with square brackets:
Nested Content in Admonitions
You can put anything inside — code blocks, tables, lists, even other components:
module.exports = { markdown: { format: 'mdx', }, };
You can also include images and links inside admonitions.
:::Nested Admonitions
You can nest them by using more colons on the outer one:
Visual Result: A note box containing a visually indented tip box inside it. The nesting shows through layered backgrounds.
Lists and Steps Inside Admonitions
Custom Admonition Types
You can invent your own types — exercise boxes, quizzes, whatever makes sense for your content.
Step 1: Define the Custom Admonition Component
Step 2: Use Custom Admonitions in MDX
Custom Admonition Icons
You can swap the default icons through CSS or by swizzling:
/* Override the note icon */
.alert--note .admonition-icon svg {
fill: #1a73e8;
}
/* Override the tip icon with a custom emoji-based approach */
.alert--tip::before {
content: '🚀';
font-size: 1.2em;
}
/* Change admonition heading styles */
.admonition-heading h5 {
font-size: 0.9rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}Using SVG Icons via Swizzling
npm run swizzle @docusaurus/theme-classic Admonition/Icon/Note -- --wrapimport React from 'react';
export default function AdmonitionIconNote(props) {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" {...props}>
<path d="M8 1a7 7 0 100 14A7 7 0 008 1zm0 3a1 1 0 110 2 1 1 0 010-2zm2 8H6v-1h1V7H6V6h3v5h1v1z"/>
</svg>
);
}Styling Admonitions
Global CSS Customization
Inline Styling with className
Docusaurus doesn't natively support className on admonitions directly, but you can wrap them:
<div className="compact-admonitions">
:::tip
Short and sweet tip.
:::
:::note
Brief note.
:::
</div>Best Practices for Admonitions
:::tip[Admonition Guidelines]
- Don't overuse — More than 2-3 per page dilutes their impact
- Choose the right type — Match severity to content importance
- Keep them concise — Long admonitions lose the "callout" benefit
- Use custom titles — Specific titles are more helpful than generic ones
- Reserve danger — Only for truly critical warnings about data loss or security
:::
Configuration in docusaurus.config.js
Admonitions work out of the box. But if you've added custom types, register their keywords:
Admonitions are one of those features that make docs actually scannable. They break up walls of text, draw eyes to what matters, and give readers clear signals about severity. Use them well and your docs feel polished. Overuse them and everything feels like a warning.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Admonitions in Docusaurus.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this MDX Tutorial topic.
Search Terms
mdx-tutorial, mdx tutorial, mdx, tutorial, docusaurus, admonitions, admonitions in docusaurus
Related MDX Tutorial Topics