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:

bun add docs-please

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

npmyarnpnpmbun
npm install pkgyarn add pkgpnpm add pkgbun add pkg
npm installyarn installpnpm installbun install

Create Commands

npmyarnpnpmbun
npm create appyarn create apppnpm create appbun create app

Npx Commands

npmyarnpnpmbun
npx commandyarn dlx commandpnpm dlx commandbunx --bun command

Run Commands

npmyarnpnpmbun
npm run devyarn devpnpm devbun dev

Examples

Installation

bun add vue

Create Project

bunx --bun create-nuxt-app my-app

Run Scripts

bun build

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:

  1. Detects the package manager command pattern
  2. Generates equivalent commands for all supported package managers
  3. Renders a tabbed interface with syntax highlighting
  4. 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.