Code groups
Group related code examples into tabs or a compact menu selector.
Usage
Wrap multiple fenced code blocks with CodeGroup. The fence language controls syntax highlighting, and the text after the language becomes the file label.
card.tsx
card.php
card.py
export function Card() {
return (
<section className="rounded-lg border p-4">
<h2 className="font-medium">Account overview</h2>
<p className="text-muted-fg">Review usage before upgrading.</p>
</section>
)
}As Menu
Use asMenu when you want the header to show the active file name while the selector uses the language labels. Selecting php, for example, switches the visible file to profile-form.php.
profile-form.tsx
profile-form.tsx
profile-form.php
profile_form.py
profile-form.tsx
export function ProfileForm() {
return (
<form className="grid gap-3">
<input name="name" placeholder="Name" />
<button type="submit">Save</button>
</form>
)
}Labels
The label is optional. If you omit it, the language name is used.