mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-26 06:05:56 +00:00
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
|
|
export function ComponentPreviewTabs({
|
|
className,
|
|
align = "center",
|
|
hideCode = false,
|
|
chromeLessOnMobile = false,
|
|
component,
|
|
source,
|
|
...props
|
|
}: React.ComponentProps<"div"> & {
|
|
align?: "center" | "start" | "end"
|
|
hideCode?: boolean
|
|
chromeLessOnMobile?: boolean
|
|
component: React.ReactNode
|
|
source: React.ReactNode
|
|
}) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"group relative mt-4 mb-12 flex flex-col gap-2 rounded-lg border",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<div data-slot="preview">
|
|
<div
|
|
data-align={align}
|
|
className={cn(
|
|
"preview flex w-full justify-center data-[align=center]:items-center data-[align=end]:items-end data-[align=start]:items-start",
|
|
chromeLessOnMobile ? "sm:p-10" : "h-[450px] p-10"
|
|
)}
|
|
>
|
|
{component}
|
|
</div>
|
|
{!hideCode && (
|
|
<div
|
|
data-slot="code"
|
|
className="overflow-hidden [&_[data-rehype-pretty-code-figure]]:!m-0 [&_[data-rehype-pretty-code-figure]]:rounded-t-none [&_[data-rehype-pretty-code-figure]]:border-t [&_pre]:max-h-[400px]"
|
|
>
|
|
{source}
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|