Package Command

A command with a tab for each package manager, and a copy button.

Installation

  1. Add the registryOnce per project
  2. Add package-command

Usage

Write command without the package manager, and each tab fills it in for pnpm, npm, yarn, Bun or Vite+. Picking a tab switches every Package Command on the page, and the choice is saved in local storage. Clicking anywhere in the command copies it.

Examples

Installing packages

type="install" adds packages, as pnpm add or npm install. Flags such as -D work too.

Running scripts

type="run" runs a script, as pnpm dev or npm run dev.

Monochrome logos

iconVariant="mono" draws the logos in the text color.

Your own picker

usePackageManager returns the shared package manager and a setter. getPackageCommand writes a command for one package manager, and packageManagers lists them with their logos. PackageCommandText draws that command with its parts colored by the theme's syntax tokens, to pass as the children of a Copy Field.

Props

PackageCommand takes the props of Tabs, apart from defaultValue, orientation and children. Passing value overrides the shared choice.

PackageCommand

PackageCommandText