Learn how to use rspress-language-tabs to create beautiful tabbed code examples.
The most basic usage involves importing the components and wrapping your code blocks.
First, import the components at the top of your MDX file:
Then use them to create tabs:
The language prop determines which icon to display. It's case-insensitive and supports common aliases.
For example, these are all equivalent:
language="javascript" or language="js"language="typescript" or language="ts"language="python" or language="py"See the full list of Supported Languages.
Use the label prop to display custom text while keeping the correct language icon:
In this example, both tabs show TypeScript code, but with different runtime labels.
Use the groupId prop to synchronize tab selections across multiple LanguageTabs components.
When you select a language in one group, all other groups with the same groupId will automatically switch to that language too!
Try clicking the tabs above - they stay in sync!
If a language isn't recognized, a generic code icon </> is displayed:
Include comments and meaningful variable names in your code examples to make them easier to understand.
Each tab should demonstrate the same concept in different languages for consistency.
Add explanatory text before code examples to help users understand what they're looking at.