Tabs
Use <Tabs> and <TabItem> to switch between options; they are globally registered in MDX site-wide, no import needed.
Basic Usage
- Source
- Result
<Tabs><TabItem value="bash" label="Bash" default>```bashecho "Hello from Bash"```</TabItem><TabItem value="python" label="Python">```pythonprint("Hello from Python")```</TabItem></Tabs>- Bash
- Python
echo "Hello from Bash"print("Hello from Python")Synced Groups
Give multiple <Tabs> the same groupId and they sync: switching one switches all blocks with the same groupId to the matching tab. Useful for splitting "install steps" and "path notes" while keeping a unified choice.
The two independent <Tabs> below both use groupId="os"; switching either one syncs the other:
- Source
- Result
<Tabs groupId="os"><TabItem value="mac" label="macOS" default>Install on macOS</TabItem><TabItem value="win" label="Windows">Install on Windows</TabItem></Tabs><Tabs groupId="os"><TabItem value="mac" label="macOS">macOS path: /Applications</TabItem><TabItem value="win" label="Windows" default>Windows path: C:\Program Files</TabItem></Tabs>- macOS
- Windows
Install on macOS
Install on Windows
- macOS
- Windows
macOS path: /Applications
Windows path: C:\Program Files
Two Options
There is no limit on the number of options; below is the common two-tab pattern:
- Source
- Result
<Tabs><TabItem value="npm" label="npm" default>```bashnpm install docusaurus```</TabItem><TabItem value="yarn" label="yarn">```bashyarn add docusaurus```</TabItem></Tabs>- npm
- yarn
npm install docusaurusyarn add docusaurusThree Options
Below is the three-tab pattern; extend horizontally for more:
- Source
- Result
<Tabs><TabItem value="js" label="JavaScript" default>```jsconsole.log("JS");```</TabItem><TabItem value="ts" label="TypeScript">```tsconsole.log("TS");```</TabItem><TabItem value="py" label="Python">```pythonprint("Python")```</TabItem></Tabs>- JavaScript
- TypeScript
- Python
console.log("JS");console.log("TS");print("Python")Parameters
<Tabs>: container; addgroupIdto sync multiple blocks<TabItem value="..." label="..." default>:valueuniquely identifies the tab within its block,labelis the displayed text,defaultmarks the initially selected tab- Sync rule: only
<Tabs>blocks with the samegroupIdsync (persisted vialocalStorage, kept after refresh);valueonly needs to be unique within its own block and may repeat across blocks. To keep blocks independent, use differentgroupIdvalues.