Use docspress/code-tabs for equivalent examples readers can switch between, such as package managers, programming languages, operating systems, or API clients.
When to use it
Choose Code Tabs only when every tab accomplishes the same task. Use Colorful Code when examples build on one another or need highlights, diffs, or annotations. Separate sequential examples with headings instead of hiding steps in tabs.
Edit the block
Add, remove, and reorder tabs in Gutenberg. Give each tab a short unique label, select its language, and optionally set a filename. Keep the same conceptual scope and expected result across tabs.
Attributes
Code Tabs attributes
docspress/code-tabs.-
tabsarray required -
Up to eight equivalent source examples.
-
showLineNumbersboolean -
Shows one-based line numbers in every panel.
-
captionstring -
Optional formatted caption for the complete tab set.
No fields match this filter.
Each tabs item accepts:
Tab object
-
labelstring required -
Short, unique tab label.
-
languageenum -
Syntax language. Invalid values normalize to plaintext.
-
filenamestring -
Optional display filename.
-
codestring required -
Plain source text.
No fields match this filter.
Invalid languages fall back to plaintext. Only the first eight valid tabs render. An empty tab array renders no block.
Creative examples
Package-manager alternatives
npm install docspress
pnpm add docspress
Fetch one documentation Page
curl https://example.test/wp-json/wp/v2/pages/42
const response = await fetch( 'https://example.test/wp-json/wp/v2/pages/42' );const page = await response.json();
import requestspage = requests.get( 'https://example.test/wp-json/wp/v2/pages/42', timeout=10,).json()
Express one configuration in three formats
{ "docsDir": "docs", "status": "draft"}
docsDir: docsstatus: draft
<?phpreturn [ 'docsDir' => 'docs', 'status' => 'draft',];
Published behavior and accessibility
The block uses a semantic tab list and tab panels. Readers can move between tabs with the keyboard, and only the active panel participates in the normal tab order. Copy operates on the active example and announces its result.
Put the most broadly useful choice first. Keep tab labels compact, avoid more than four choices when possible, and confirm that every example remains functionally equivalent after updates.