BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/ncdai/code-block-command

Code Block Command

ncdai/code-block-command
UnverifiedComponent

Display install commands with package manager switcher and copy button.

Install it

npx shadcn@latest add https://raw.githubusercontent.com/Sumeet011/Portfolio/main/public/r/code-block-command.json

Source

src/registry/components/code-block-command/code-block-command.tsxraw.githubusercontent.com/Sumeet011/Portfolio/main/public/r/code-block-command.json · first 6 KB
1"use client"
2
3import { useMemo } from "react"
4import { ScrollArea } from "@base-ui/react/scroll-area"
5import { useAtom } from "jotai"
6import { atomWithStorage } from "jotai/utils"
7
8import { cn } from "@/lib/utils"
9import {
10 Tabs,
11 TabsContent,
12 TabsIndicator,
13 TabsList,
14 TabsTrigger,
15} from "@/components/base/ui/tabs"
16import { CopyButton } from "@/registry/components/copy-button"
17import { IconSwap, IconSwapItem } from "@/registry/components/icon-swap"
18import { IconPlaceholder } from "@/registry/icons/icon-placeholder"
19
20export type PackageManager = "prompt" | "pnpm" | "yarn" | "npm" | "bun"
21
22const packageManagerAtom = atomWithStorage<PackageManager>(
23 "packageManager",
24 "pnpm"
25)
26
27export function usePackageManager() {
28 return useAtom(packageManagerAtom)
29}
30
31/**
32 * Props for the CodeBlockCommand component.
33 */
34export type CodeBlockCommandProps = {
35 /**
36 * Natural language instruction for AI agents to install a package or component.
37 */
38 prompt?: string
39 /**
40 * Command to execute with pnpm package manager.
41 */
42 pnpm?: string
43
44 /**
45 * Command to execute with yarn package manager.
46 */
47 yarn?: string
48
49 /**
50 * Command to execute with npm package manager.
51 */
52 npm?: string
53
54 /**
55 * Command to execute with bun package manager.
56 */
57 bun?: string
58
59 /**
60 * Callback invoked when a command is successfully copied to clipboard.
61 *
62 * Receives an object containing the selected package manager and the copied command text.
63 * Useful for tracking user interactions or showing custom success notifications.
64 *
65 * @param data - Object containing copy operation details
66 * @param data.packageManager - The package manager that was selected when copying
67 * @param data.command - The actual command text that was copied
68 *
69 * @example
70 * ```tsx
71 * <CodeBlockCommand
72 * pnpm="pnpm add react"
73 * onCopySuccess={({ packageManager, command }) => {
74 * console.log(`Copied ${command} for ${packageManager}`)
75 * }}
76 * />
77 * ```
78 */
79 onCopySuccess?: (data: {
80 packageManager: PackageManager
81 command: string
82 }) => void
83
84 /**
85 * Callback invoked when copying to clipboard fails.
86 *
87 * Receives the error object for debugging or showing custom error messages.
88 *
89 * @param error - The error that occurred during the copy operation
90 *
91 * @example
92 * ```tsx
93 * <CodeBlockCommand
94 * pnpm="pnpm add react"
95 * onCopyError={(error) => {
96 * console.error('Copy failed:', error)
97 * }}
98// … truncated

What it pulls in

npm packages

  • @base-ui/react
  • lucide-react
  • motion
  • jotai

Other registry items

  • https://chanhdai.com/r/copy-button.json

Files it writes

  • src/registry/components/code-block-command/code-block-command.tsx
  • src/components/base/ui/tabs.tsx

Facts

Registry
ncdai
Type
registry:component
Access
Unverified
Files written
2
Theme wiring
ships cssVars
Licence
MIT
First indexed
2026-08-03
Last confirmed
today

Go to the source

chanhdai.com Sumeet011/Portfolio on GitHub Raw registry item This item as JSON

More from ncdai

All 48 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Apple Hello Effectapple-hello-effectncdaiComponentsUnverified1 dep
Apple Hello Effect - Hindiapple-hello-effect-hindincdaiComponentsUnverified1 dep
Apple Hello Effect - Spanishapple-hello-effect-spanishncdaiComponentsUnverified1 dep
Apple Hello Effect - Vietnameseapple-hello-effect-vietnamesencdaiComponentsUnverified1 dep
Brand Assets Menubrand-assets-menuncdaiComponentsUnverified1 dep
chevrons-up-down-iconchevrons-up-down-iconncdaiComponentsUnverified1 dep
Consent Managerconsent-managerncdaiComponentsUnverified1 dep
Contribution Graphcontribution-graphncdaiComponentsUnverified1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex