Home / Function/ Command() — supabase Function Reference

Command() — supabase Function Reference

Architecture documentation for the Command() function in command.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  6dab894a_a956_6f28_44d9_6d3388713095["Command()"]
  ea17971a_1c02_abd3_4eb0_642abdb391f3["useLocalStorage()"]
  6dab894a_a956_6f28_44d9_6d3388713095 -->|calls| ea17971a_1c02_abd3_4eb0_642abdb391f3
  b0b31295_09d6_092e_8a9b_370c46bdf15d["getBaseUrl()"]
  6dab894a_a956_6f28_44d9_6d3388713095 -->|calls| b0b31295_09d6_092e_8a9b_370c46bdf15d
  7a50c4e2_db65_859f_25f6_42e059e4aad1["getComponentPath()"]
  6dab894a_a956_6f28_44d9_6d3388713095 -->|calls| 7a50c4e2_db65_859f_25f6_42e059e4aad1
  style 6dab894a_a956_6f28_44d9_6d3388713095 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/learn/components/command.tsx lines 38–102

export function Command({ name, highlight, framework = 'react' }: CommandCopyProps) {
  const [value, setValue] = useLocalStorage(LOCAL_STORAGE_KEY, 'npm')

  const baseUrl = getBaseUrl()
  const componentPath = getComponentPath(name)

  const commands: Record<PackageManager, string> =
    framework === 'vue'
      ? {
          npm: `npx shadcn-vue@latest add ${baseUrl}${componentPath}`,
          pnpm: `pnpm dlx shadcn-vue@latest add ${baseUrl}${componentPath}`,
          yarn: `yarn dlx shadcn-vue@latest add ${baseUrl}${componentPath}`,
          bun: `bunx --bun shadcn-vue@latest add ${baseUrl}${componentPath}`,
        }
      : {
          npm: `npx shadcn@latest add ${baseUrl}${componentPath}`,
          pnpm: `pnpm dlx shadcn@latest add ${baseUrl}${componentPath}`,
          yarn: `yarn dlx shadcn@latest add ${baseUrl}${componentPath}`,
          bun: `bunx --bun shadcn@latest add ${baseUrl}${componentPath}`,
        }

  return (
    <Tabs_Shadcn_ value={value} onValueChange={setValue} className="w-full">
      <div className="w-full group relative rounded-lg bg-surface-200 dark:bg-surface-100 px-4 py-2 overflow-hidden">
        {highlight && (
          <motion.div
            className="absolute inset-0 bg-gradient-to-l from-transparent via-[#bbb] dark:via-white to-transparent opacity-10 z-0"
            initial={{ x: '100%' }}
            animate={{ x: '-100%' }}
            transition={{
              repeat: Infinity,
              duration: 2.5,
              ease: 'linear',
              repeatType: 'loop',
            }}
          />
        )}

        <div className="flex flex-col">
          <TabsList_Shadcn_ className="gap-2 relative mb-2 z-10">
            {(Object.keys(commands) as PackageManager[]).map((manager) => (
              <TabsTrigger_Shadcn_ key={manager} value={manager} className="text-xs">
                {manager}
              </TabsTrigger_Shadcn_>
            ))}
          </TabsList_Shadcn_>

          {(Object.keys(commands) as PackageManager[]).map((manager) => (
            <TabsContent_Shadcn_ key={manager} value={manager} className="m-0">
              <div className="flex items-center">
                <div className="flex-1 font-mono text-sm text-foreground relative z-10">
                  <span className="mr-2 text-[#888] select-none">$</span>
                  {commands[manager]}
                </div>
                <div className="relative z-10">
                  <CommandCopyButton command={commands[manager]} />
                </div>
              </div>
            </TabsContent_Shadcn_>
          ))}
        </div>
      </div>
    </Tabs_Shadcn_>
  )
}

Subdomains

Frequently Asked Questions

What does Command() do?
Command() is a function in the supabase codebase.
What does Command() call?
Command() calls 3 function(s): getBaseUrl, getComponentPath, useLocalStorage.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free