ComponentSource() — ui Function Reference
Architecture documentation for the ComponentSource() function in component-source.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD f005bdf2_9c7c_3bb1_c106_f4f98cf8f3a8["ComponentSource()"] 6e002999_74c0_6885_6d92_dd3803998064["component-source.tsx"] f005bdf2_9c7c_3bb1_c106_f4f98cf8f3a8 -->|defined in| 6e002999_74c0_6885_6d92_dd3803998064 style f005bdf2_9c7c_3bb1_c106_f4f98cf8f3a8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/v4/components/component-source.tsx lines 13–87
export async function ComponentSource({
name,
src,
title,
language,
collapsible = true,
className,
styleName = "new-york-v4",
maxLines,
}: React.ComponentProps<"div"> & {
name?: string
src?: string
title?: string
language?: string
collapsible?: boolean
styleName?: string
maxLines?: number
}) {
if (!name && !src) {
return null
}
let code: string | undefined
if (name) {
const item =
(await getDemoItem(name, styleName)) ??
(await getRegistryItem(name, styleName))
code = item?.files?.[0]?.content
}
if (src) {
const file = await fs.readFile(path.join(process.cwd(), src), "utf-8")
code = file
}
if (!code) {
return null
}
code = await formatCode(code, styleName)
code = code.replaceAll("/* eslint-disable react/no-children-prop */\n", "")
// Truncate code if maxLines is set.
if (maxLines) {
code = code.split("\n").slice(0, maxLines).join("\n")
}
const lang = language ?? title?.split(".").pop() ?? "tsx"
const highlightedCode = await highlightCode(code, lang)
if (!collapsible) {
return (
<div className={cn("relative", className)}>
<ComponentCode
code={code}
highlightedCode={highlightedCode}
language={lang}
title={title}
/>
</div>
)
}
return (
<CodeCollapsibleWrapper className={className}>
<ComponentCode
code={code}
highlightedCode={highlightedCode}
language={lang}
title={title}
/>
</CodeCollapsibleWrapper>
)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does ComponentSource() do?
ComponentSource() is a function in the ui codebase, defined in apps/v4/components/component-source.tsx.
Where is ComponentSource() defined?
ComponentSource() is defined in apps/v4/components/component-source.tsx at line 13.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free