{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "attachment", "title": "Attachment", "description": "Displays a file or image attachment with media, metadata, upload state, and actions.", "dependencies": [ "class-variance-authority", "radix-ui" ], "registryDependencies": [ "button" ], "files": [ { "path": "registry/default/ui/attachment.tsx", "content": "import * as React from 'react';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport { Slot } from 'radix-ui';\n\nimport { cn } from '@/lib/utils';\nimport { Button } from '@/registry/default/ui/button';\n\nconst attachmentVariants = cva(\n 'group/attachment relative flex w-fit max-w-full min-w-0 shrink-0 flex-wrap rounded-xl border bg-card text-card-foreground transition-colors focus-within:ring-1 focus-within:ring-ring/50 has-[>a,>button]:hover:bg-muted/50 data-[state=error]:border-destructive-foreground/30 data-[state=idle]:border-dashed',\n {\n variants: {\n size: {\n default:\n 'gap-2 text-sm has-data-[slot=attachment-content]:px-2.5 has-data-[slot=attachment-content]:py-2 has-data-[slot=attachment-media]:p-2',\n sm: 'gap-2.5 text-xs has-data-[slot=attachment-content]:px-2 has-data-[slot=attachment-content]:py-1.5 has-data-[slot=attachment-media]:p-1.5',\n xs: 'gap-1.5 rounded-lg text-xs has-data-[slot=attachment-content]:px-1.5 has-data-[slot=attachment-content]:py-1 has-data-[slot=attachment-media]:p-1',\n },\n orientation: {\n horizontal: 'min-w-40 items-center',\n vertical: 'w-24 flex-col has-data-[slot=attachment-content]:w-30',\n },\n },\n }\n);\n\nfunction Attachment({\n className,\n state = 'done',\n size = 'default',\n orientation = 'horizontal',\n ...props\n}: React.ComponentProps<'div'> &\n VariantProps & {\n state?: 'idle' | 'uploading' | 'processing' | 'error' | 'done';\n }) {\n return (\n \n );\n}\n\nconst attachmentMediaVariants = cva(\n \"relative flex aspect-square w-10 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-muted text-foreground group-data-[orientation=vertical]/attachment:w-full group-data-[size=sm]/attachment:w-8 group-data-[size=xs]/attachment:w-7 group-data-[size=xs]/attachment:rounded-md group-data-[state=error]/attachment:bg-destructive group-data-[state=error]/attachment:text-destructive-foreground group-data-[orientation=vertical]/attachment:*:data-[slot=spinner]:size-6! [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 group-data-[orientation=vertical]/attachment:[&_svg:not([class*='size-'])]:size-6 group-data-[size=xs]/attachment:[&_svg:not([class*='size-'])]:size-3.5\",\n {\n variants: {\n variant: {\n icon: '',\n image:\n 'opacity-60 group-data-[state=done]/attachment:opacity-100 group-data-[state=idle]/attachment:opacity-100 *:[img]:aspect-square *:[img]:w-full *:[img]:object-cover',\n },\n },\n defaultVariants: {\n variant: 'icon',\n },\n }\n);\n\nfunction AttachmentMedia({\n className,\n variant = 'icon',\n ...props\n}: React.ComponentProps<'div'> & VariantProps) {\n return (\n \n );\n}\n\nfunction AttachmentContent({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n \n );\n}\n\nfunction AttachmentTitle({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n \n );\n}\n\nfunction AttachmentDescription({\n className,\n ...props\n}: React.ComponentProps<'span'>) {\n return (\n \n );\n}\n\nfunction AttachmentActions({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n \n );\n}\n\nfunction AttachmentAction({\n className,\n variant,\n size = 'icon-xs',\n ...props\n}: React.ComponentProps) {\n return (\n \n );\n}\n\nfunction AttachmentTrigger({\n className,\n asChild = false,\n type,\n ...props\n}: React.ComponentProps<'button'> & {\n asChild?: boolean;\n}) {\n const Comp = asChild ? Slot.Root : 'button';\n\n return (\n \n );\n}\n\nfunction AttachmentGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n \n );\n}\n\nexport {\n Attachment,\n AttachmentGroup,\n AttachmentMedia,\n AttachmentContent,\n AttachmentTitle,\n AttachmentDescription,\n AttachmentActions,\n AttachmentAction,\n AttachmentTrigger,\n};\n", "type": "registry:ui" } ], "type": "registry:ui" }