Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions apps/docs/content/1.component/package-command.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
title: Package Command
description: An install command for npm, pnpm, yarn and bun where only the letters that change flip like a split-flap board.
icon: package
---

An install command in a small **terminal card**, with a tab for each
package manager. The pill **follows your pointer** across the tabs and slides back to the
selected one when you leave. When the command changes, only the **characters that differ flip**,
like a split-flap board: `pnpm add` to `yarn add` turns over four letters and
leaves ` add` alone. Copy it and a check **draws itself in** while a
selection sweeps across the line. The choice is **remembered**, and every
Package Command on the page follows it. Driven by GSAP.

::component-preview{name="package-command"}
::

## Installation

::tabs
:::tabs-item{label="CLI" icon="i-lucide-terminal"}

::install-tabs{item="package-command"}
::

:::
:::tabs-item{label="Manual" icon="i-lucide-clipboard"}

::component-source{name="package-command"}
::

:::
::

## Usage

::tabs
:::tabs-item{label="React" icon="i-lucide-atom"}

```tsx [app/page.tsx]
import PackageCommand from '@/components/tweenui/package-command';

export default function Page() {
return (
<>
<PackageCommand packages={['gsap', '@gsap/react']} />
<PackageCommand packages="vitest" dev />
<PackageCommand kind="execute" packages="shadcn@latest add @tween-ui/package-command" />
</>
);
}
```

:::
::

## How it moves

- **Pill.** Slides under whichever tab you hover or focus and resizes to fit
it, 350ms on `power2.out`, and lights that label up. Leave the tabs and
it slides back to the selected one.
- **Command.** The text is laid out one monospace cell per character. Cells
that hold the same letter before and after stay still. The rest roll the
old letter up and out and the new one up from below, 30ms apart from left
to right. The line is laid out at its new length at once and the package
names slide in from where they were on `power3.inOut` over 550ms, using
only transforms, so nothing reflows mid-flip.
- **Copy.** The clipboard shrinks away, the check strokes itself in over
400ms, and an accent band sweeps under the command and fades. After 1.6s
the clipboard returns.

## Props

| Prop | Type | Default | Description |
| ----------- | ------------------------ | -------------------------------- | ------------------------------------------------------------------------------------------------ |
| `packages` | `string \| string[]` | — | What to install, or with `kind="execute"` the command to run. |
| `kind` | `'install' \| 'execute'` | `'install'` | `install` gives `npm install` / `add`. `execute` gives `npx`, `pnpm dlx`, `yarn dlx` and `bunx`. |
| `dev` | `boolean` | `false` | Adds `-D` to an install. |
| `managers` | `PackageManager[]` | `['npm', 'pnpm', 'yarn', 'bun']` | Which tabs to show, in order. |
| `onCopy` | `(command) => void` | — | Called with the copied command. |
| `className` | `string` | — | Extra classes for the root. |

The choice is saved to `localStorage` under `tweenui:package-manager` and
shared by every instance, including other open tabs. The server renders
`npm`, and the saved choice takes over after hydration without animating.
The accent comes from `--package-accent`. Override it with a class, e.g.
`[--package-accent:#e11d48]`. Everything else takes `currentColor`.

## Accessibility

::note
Under `prefers-reduced-motion: reduce` the pill jumps to the tab, the
command swaps without flipping and the check appears without drawing.
::

The tabs are a real `tablist` with one focusable tab. Arrow keys move and
wrap, and Home and End jump to the ends. The panel holds the full command as
text for screen readers, so they never hear it letter by letter. The copy
button is labelled "Copy command" and a status region announces "Copied to
clipboard".
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
17 changes: 17 additions & 0 deletions apps/docs/public/r/package-command-demo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
"name": "package-command-demo",
"type": "registry:example",
"title": "Package Command Demo",
"description": "Usage examples for Package Command.",
"registryDependencies": [
"https://tween-ui.vercel.app/r/package-command.json"
],
"files": [
{
"path": "examples/package-command-demo.tsx",
"type": "registry:example",
"content": "import PackageCommand from '@/components/tweenui/package-command';\n\nexport default function Page() {\n return (\n <>\n <PackageCommand packages={['gsap', '@gsap/react']} />\n <PackageCommand packages=\"vitest\" dev />\n <PackageCommand kind=\"execute\" packages=\"shadcn@latest add @tween-ui/package-command\" />\n </>\n );\n}"
}
]
}
24 changes: 24 additions & 0 deletions apps/docs/public/r/package-command.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions apps/docs/public/r/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,30 @@
}
]
},
{
"name": "package-command",
"type": "registry:ui",
"title": "Package Command",
"description": "An install command in npm, pnpm, yarn and bun inside a small terminal card. A pill slides between the tabs, and only the characters that differ between managers flip like a split-flap board. Copying draws a check and sweeps a selection across the line. The choice is remembered and every block on the page follows it.",
"files": [
{
"path": "components/tweenui/package-command.tsx",
"type": "registry:component"
}
]
},
{
"name": "package-command-demo",
"type": "registry:example",
"title": "Package Command Demo",
"description": "Usage examples for Package Command.",
"files": [
{
"path": "examples/package-command-demo.tsx",
"type": "registry:example"
}
]
},
{
"name": "pricing-plan-switch",
"type": "registry:block",
Expand Down
1 change: 1 addition & 0 deletions apps/docs/registry/__index__.generated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const demos: Record<string, ComponentType> = {
'theme-toggle-reveal:sonar': dynamic(() => import('./demos/theme-toggle-reveal-sonar')),
'theme-toggle-reveal:spiral': dynamic(() => import('./demos/theme-toggle-reveal-spiral')),
'elastic-slider:default': dynamic(() => import('./demos/elastic-slider')),
'package-command:default': dynamic(() => import('./demos/package-command')),
'pricing-plan-switch:default': dynamic(() => import('./demos/pricing-plan-switch')),
'process-card-reveal:default': dynamic(() => import('./demos/process-card-reveal')),
'process-sticky-steps:default': dynamic(() => import('./demos/process-sticky-steps')),
Expand Down
1 change: 1 addition & 0 deletions apps/docs/registry/__media__.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const discoveredMedia: Record<string, RegistryMedia> = {
'morphing-search': {"image":"/media/components/morphing-search-poster.webp","video":"/media/components/morphing-search-preview.mp4"},
'theme-toggle-reveal': {"image":"/media/components/theme-toggle-reveal-poster.webp","video":"/media/components/theme-toggle-reveal-preview.mp4"},
'elastic-slider': {"image":"/media/components/elastic-slider-poster.webp","video":"/media/components/elastic-slider-preview.mp4"},
'package-command': {"image":"/media/components/package-command-poster.webp","video":"/media/components/package-command-preview.mp4"},
'pricing-plan-switch': {"image":"/media/blocks/pricing-plan-switch-poster.webp","video":"/media/blocks/pricing-plan-switch-preview.mp4"},
'process-card-reveal': {"image":"/media/blocks/process-card-reveal-poster.webp","video":"/media/blocks/process-card-reveal-preview.mp4"},
'process-sticky-steps': {"image":"/media/blocks/process-sticky-steps-poster.webp","video":"/media/blocks/process-sticky-steps-preview.mp4"},
Expand Down
12 changes: 12 additions & 0 deletions apps/docs/registry/__sources__.generated.ts

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions apps/docs/registry/demos/package-command.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use client';

import PackageCommand from '@/registry/tweenui/package-command';

const PackageCommandDemo = () => {
return (
<div className="flex w-full justify-center px-6 text-[#12161F] dark:text-white">
<PackageCommand kind="execute" packages="shadcn@latest add @tween-ui/package-command" />
</div>
);
};

export default PackageCommandDemo;
33 changes: 33 additions & 0 deletions apps/docs/registry/registry-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,39 @@ export default function Example() {
prefix="$"
/>
);
}`,
},
},
{
name: 'package-command',
type: 'component',
addedAt: '2026-11-08',
title: 'Package Command',
description:
'An install command in npm, pnpm, yarn and bun inside a small terminal card. A pill slides between the tabs, and only the characters that differ between managers flip like a split-flap board. Copying draws a check and sweeps a selection across the line. The choice is remembered and every block on the page follows it.',
media: {},
dependencies: ['gsap', '@gsap/react'],
registryDependencies: [],
cssVars: {},
files: [
{
path: 'registry/tweenui/package-command.tsx',
target: 'components/tweenui/package-command.tsx',
kind: 'react',
},
],
variants: [
{
id: 'default',
label: 'Default',
reactSource: 'registry/tweenui/package-command.tsx',
},
],
usage: {
react: `import PackageCommand from '@/components/tweenui/package-command';

export default function Example() {
return <PackageCommand packages={['gsap', '@gsap/react']} />;
}`,
},
},
Expand Down
Loading
Loading