PM Command

A package-manager-aware command block with npm, pnpm, yarn, and bun tabs and copy-to-clipboard.

npx lily-svelte@latest add button
npm i bits-ui

Installation

npx lily-svelte@latest add pm-command

Usage

<script lang="ts">
	import { PMCommand } from '$lib/components/ui/pm-command';
</script>
 
<PMCommand command="execute" args={['lily-svelte@latest', 'add', 'button']} />

The command and args are passed to package-manager-detector, so the right runner is shown for each tab — pnpm dlx, npm install, yarn add, and so on.

Install command

Use command="install" to render a dependency-install command.

<PMCommand command="install" args={['bits-ui']} />

Variants

<PMCommand variant="secondary" command="install" args={['bits-ui']} />

Bound agent

The selected package manager is bindable, so you can keep several blocks in sync.

<script lang="ts">
	import { PMCommand } from '$lib/components/ui/pm-command';
	import type { Agent } from 'package-manager-detector';
 
	let agent = $state<Agent>('pnpm');
</script>
 
<PMCommand bind:agent command="execute" args={['lily-svelte@latest', 'init']} />
<PMCommand bind:agent command="install" args={['bits-ui']} />

Props

  • command — the package-manager-detector command kind, e.g. execute or install.
  • args — everything after the runner, e.g. ['lily-svelte@latest', 'add', 'button'].
  • agent — the selected package manager (bindable, defaults to npm).
  • agents — the package managers shown as tabs (defaults to ['npm', 'pnpm', 'yarn', 'bun']).
  • variantdefault or secondary.
  • class — extra classes for the outer container.

Built by levish. The source code is available on GitHub.

Quiet by design.