Use the Tabs component to create multi-language code blocks
mainThe Tabs component allows you to group multiple code blocks under a single tabbed interface. This is useful for showing the same logic implemented in different languages or different file versions.
To use it, wrap your code blocks within the <Tabs> component. Each code block inside the component will be treated as a separate tab. You can specify the tab title (e.g., the filename) using a comment at the top of the code block, such as // title filename.ext for JavaScript or # title filename.ext for Python.
import { Tabs } from "./tabs"
<Tabs>
```js
// title foo.js
function lorem(ipsum, dolor = 1) {
const sit = ipsum == null ? 0 : ipsum.sit
dolor = sit - amet(dolor)
return dolor
}# title bar.py
def dolor_sit_amet(consectetur, adipiscing):
if consectetur == "Lorem"
print("Pellentesque habitant.")
else:
print("Suspendisse potenti.")</Tabs>