Skip to Content

Install Switcher

Package manager install command with a gliding segmented switch inside the pill: pick pnpm, npm, yarn or bun and the command rewrites, and the copy button copies the one showing. Add the dark class over art.

View as Markdown
pnpm dlx shadcn add @01orbital/install-switcher

Usage

import { InstallSwitcher } from "@/components/code/install-switcher"

const COPY = {
  command: "shadcn add @01orbital/moon-sphere",
} as const

export default function InstallSwitcherDemo() {
  return (
    <div className="grid min-h-full w-full max-w-2xl flex-1 content-center">
      <InstallSwitcher command={COPY.command} />
    </div>
  )
}

API reference

An install command with a package manager switch in the same pill, for a hero or docs page. Picking pnpm, npm, yarn or bun rewrites the command's runner, and the copy button copies the command as it shows.

When the component is narrower than 32rem, the switch takes its own row above the command. After a copy, the button shows a check for two seconds; if copying fails, the command is selected and a message below asks the reader to press ⌘C or Ctrl+C. Over artwork, add className="dark". className lands on the outer div.

Prop

Type

It also accepts the HTML attributes of the element it renders.

Dependencies

npm: @phosphor-icons/react, cn. The CLI installs them for you. cn merges Tailwind class names, in place of clsx and tailwind-merge.

Registry pieces it installs with it: