- Code groups are for code. Use them when the explanation is the same for everyone and only the code changes, like the same API call in Python, JavaScript, and cURL.
- Tabs are for everything else. Use them when the instructions, explanation, or mix of content changes, like setup steps that differ on macOS and Windows.
Code groups: same explanation, different code
Wrap two or more code blocks in<CodeGroup>. Each block needs a title, which becomes its label in the group.
Example of a code group
dropdown prop to <CodeGroup> to show a menu instead of a crowded row of labels.
Tabs: when more than the code changes
Use tabs when a section of the page changes based on the reader’s context, and the change includes instructions or explanation, not just code.Example of tabs
- Authentication methods chosen earlier in a setup flow
- A short section that differs for administrators and members
- A procedure step that differs by platform
Keep choices in sync
Tabs and code groups on the same page sync by label. If a reader selectsPython in one, every other tab group or code group with a Python label switches too, so they only choose once.
Labels must match exactly. Python, python, and Python 3 are three different choices. For code groups, the label is the code block’s title, so a block titled create_user.py won’t sync with a tab titled Python. If you want syncing, title your code blocks by language.
Tab groups that sync
sync={false} on <Tabs>.