Home / Function/ addComponents() — ui Function Reference

addComponents() — ui Function Reference

Architecture documentation for the addComponents() function in add-components.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  078f2672_34c7_86ae_f39e_4a5df4f1125b["addComponents()"]
  05e0e857_0905_dce0_82c9_cfde160573bd["add-components.ts"]
  078f2672_34c7_86ae_f39e_4a5df4f1125b -->|defined in| 05e0e857_0905_dce0_82c9_cfde160573bd
  c7860b80_e410_7cb2_d73d_5220d24c63d9["addWorkspaceComponents()"]
  078f2672_34c7_86ae_f39e_4a5df4f1125b -->|calls| c7860b80_e410_7cb2_d73d_5220d24c63d9
  fdd9197d_b14e_a97e_a1a7_e1ef82de0896["addProjectComponents()"]
  078f2672_34c7_86ae_f39e_4a5df4f1125b -->|calls| fdd9197d_b14e_a97e_a1a7_e1ef82de0896
  style 078f2672_34c7_86ae_f39e_4a5df4f1125b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/add-components.ts lines 34–68

export async function addComponents(
  components: string[],
  config: Config,
  options: {
    overwrite?: boolean
    silent?: boolean
    isNewProject?: boolean
    baseStyle?: boolean
    registryHeaders?: Record<string, Record<string, string>>
    path?: string
  }
) {
  options = {
    overwrite: false,
    silent: false,
    isNewProject: false,
    baseStyle: true,
    ...options,
  }

  const workspaceConfig = await getWorkspaceConfig(config)
  if (
    workspaceConfig &&
    workspaceConfig.ui &&
    workspaceConfig.ui.resolvedPaths.cwd !== config.resolvedPaths.cwd
  ) {
    return await addWorkspaceComponents(components, config, workspaceConfig, {
      ...options,
      isRemote:
        components?.length === 1 && !!components[0].match(/\/chat\/b\//),
    })
  }

  return await addProjectComponents(components, config, options)
}

Subdomains

Frequently Asked Questions

What does addComponents() do?
addComponents() is a function in the ui codebase, defined in packages/shadcn/src/utils/add-components.ts.
Where is addComponents() defined?
addComponents() is defined in packages/shadcn/src/utils/add-components.ts at line 34.
What does addComponents() call?
addComponents() calls 2 function(s): addProjectComponents, addWorkspaceComponents.

Analyze Your Own Codebase

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

Try Supermodel Free