ComponentExample() — ui Function Reference
Architecture documentation for the ComponentExample() function in component-example.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD ba251659_19a1_4f5e_9484_40a3a2216e54["ComponentExample()"] dd51cd43_f956_27de_b8dd_239661015176["component-example.tsx"] ba251659_19a1_4f5e_9484_40a3a2216e54 -->|defined in| dd51cd43_f956_27de_b8dd_239661015176 style ba251659_19a1_4f5e_9484_40a3a2216e54 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
deprecated/www/components/component-example.tsx lines 21–107
export function ComponentExample({
children,
className,
extractClassname,
extractedClassNames,
align = "center",
src: _,
...props
}: ComponentExampleProps) {
const [Example, Code, ...Children] = React.Children.toArray(
children
) as React.ReactElement[]
const codeString = React.useMemo(() => {
if (
typeof Code?.props["data-rehype-pretty-code-fragment"] !== "undefined"
) {
const [, Button] = React.Children.toArray(
Code.props.children
) as React.ReactElement[]
return Button?.props?.value || Button?.props?.__rawString__ || null
}
}, [Code])
return (
<div
className={cn("group relative my-4 flex flex-col space-y-2", className)}
{...props}
>
<Tabs defaultValue="preview" className="relative mr-auto w-full">
<div className="flex items-center justify-between pb-3">
<TabsList className="w-full justify-start rounded-none border-b bg-transparent p-0">
<TabsTrigger
value="preview"
className="relative rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
>
Preview
</TabsTrigger>
<TabsTrigger
value="code"
className="relative rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
>
Code
</TabsTrigger>
</TabsList>
{extractedClassNames ? (
<CopyWithClassNames
value={codeString}
classNames={extractedClassNames}
className="absolute right-4 top-20"
/>
) : (
codeString && (
<CopyButton
value={codeString}
className="absolute right-4 top-20"
/>
)
)}
</div>
<TabsContent value="preview" className="rounded-md border">
<div
className={cn("flex min-h-[350px] justify-center p-10", {
"items-center": align === "center",
"items-start": align === "start",
"items-end": align === "end",
})}
>
{Example}
</div>
</TabsContent>
<TabsContent value="code">
<div className="flex flex-col space-y-4">
<div className="w-full rounded-md [&_button]:hidden [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto">
{Code}
</div>
{Children?.length ? (
<div className="rounded-md [&_button]:hidden [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto">
{Children}
</div>
) : null}
Domain
Subdomains
Source
Frequently Asked Questions
What does ComponentExample() do?
ComponentExample() is a function in the ui codebase, defined in deprecated/www/components/component-example.tsx.
Where is ComponentExample() defined?
ComponentExample() is defined in deprecated/www/components/component-example.tsx at line 21.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free