Skip to content
synccn

Command Snippet

New

Install command with npm, pnpm, yarn and bun tabs. Write it once for npm; the choice is remembered and shared across snippets.

pnpm dlx shadcn@latest add @synccn/command-snippet
pnpm add -D tailwindcss @tailwindcss/vite

Both snippets switch together, and the choice is remembered.

Installation

$ pnpm dlx shadcn@latest add @synccn/command-snippet

First time in this project? Connect synccn with one command.

Usage

import { CommandSnippet, convertCommand } from "@/components/ui/command-snippet";<CommandSnippet command="npm install motion" />

API reference

Generated from the component's TypeScript types, so it always matches the code.

CommandSnippet

An install command with npm, pnpm, yarn and bun tabs and a copy button. Write the command once for npm; the others are worked out, and the choice is remembered.

  • commandrequired
    string

    The command written for npm, e.g. `npm install motion` or `npx shadcn@latest add button`. Converted for each manager.

  • managers
    "npm" | "pnpm" | "yarn" | "bun"[]

    Default ALL

    Managers offered, in order.

  • value
    "npm" | "pnpm" | "yarn" | "bun"

    Controlled manager.

  • defaultValue
    "npm" | "pnpm" | "yarn" | "bun"

    Manager at first, when uncontrolled and nothing is saved. Defaults to the first of `managers`.

  • onValueChange
    (manager: "npm" | "pnpm" | "yarn" | "bun") => void

    Called when the person picks a manager.

  • storageKey
    string | false

    Default "package-manager"

    Saves the choice in localStorage under this key and keeps every snippet with the same key in step. Pass false to turn off.

  • className
    string

    Extra classes for the root element.

convertCommand

Rewrites an npm command for another package manager.

Takes no props.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Keyboard

  • ←or→Switch package manager

Accessibility

  • Managers are tabs with one tab stop; the copy button changes its label to Copied.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: tab, tablist, tabpanel
  • ARIA attributes: aria-label, aria-selected
  • Keys handled: ArrowLeft, ArrowRight, Space
  • Shows a visible focus ring for keyboard users