CodeTabs
Package manager code switcher with automatic command conversion
CodeTabs
A specialized component that automatically converts package manager commands between npm, yarn, pnpm, and bun. Users can switch between their preferred package manager.
Usage
Simply write npm commands in a code block, and they will automatically be converted to a tabbed interface with all package managers:
The above code block is automatically rendered with tabs for npm, yarn, pnpm, and bun.
Automatic Conversion
The component automatically converts the following command patterns:
Install Commands
Create Commands
Npx Commands
Run Commands
Examples
Installation
Create Project
Run Scripts
User Preference
The selected package manager is persisted in the user's browser, so their preference is remembered across page visits.
How It Works
The CodeTabs component is automatically applied to code blocks that contain npm, yarn, pnpm, or bun commands. It:
- Detects the package manager command pattern
- Generates equivalent commands for all supported package managers
- Renders a tabbed interface with syntax highlighting
- Includes a copy button for each command
Styling
The component displays a terminal icon header with the package manager tabs below. Each tab shows the correctly formatted command with syntax highlighting.