Attachment
Anexos de arquivo/imagem em composers e threads (upload, preview, ações).
Conteúdo e mídia
Carregando demonstração…
Código da demo
"use client";
import * as React from "react";
import { FileTextIcon, XIcon } from "lucide-react";
import {
Attachment,
AttachmentAction,
AttachmentActions,
AttachmentContent,
AttachmentDescription,
AttachmentGroup,
AttachmentMedia,
AttachmentTitle,
} from "@/components/ui/attachment";
export function Demo() {
const [removed, setRemoved] = React.useState(false);
return (
<div className="flex w-full max-w-lg flex-col gap-fe-3">
<AttachmentGroup
role="group"
aria-label="Anexos de exemplo"
tabIndex={0}
>
<Attachment state="done">
<AttachmentMedia>
<FileTextIcon />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>briefing-notes.pdf</AttachmentTitle>
<AttachmentDescription>PDF · 1.4 MB</AttachmentDescription>
</AttachmentContent>
</Attachment>
<Attachment state="uploading">
<AttachmentMedia>
<FileTextIcon />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>sales-dashboard.pdf</AttachmentTitle>
<AttachmentDescription>Uploading · 64%</AttachmentDescription>
</AttachmentContent>
</Attachment>
{!removed ? (
<Attachment state="done">
<AttachmentMedia>
<FileTextIcon />
</AttachmentMedia>
<AttachmentContent>
<AttachmentTitle>message-renderer.tsx</AttachmentTitle>
<AttachmentDescription>TypeScript · 12 KB</AttachmentDescription>
</AttachmentContent>
<AttachmentActions>
<AttachmentAction
aria-label="Remover message-renderer.tsx"
onClick={() => setRemoved(true)}
>
<XIcon />
</AttachmentAction>
</AttachmentActions>
</Attachment>
) : null}
</AttachmentGroup>
{removed ? (
<p className="fe-caption text-muted-foreground">Anexo removido.</p>
) : null}
</div>
);
}- Acessibilidade
- AttachmentAction e AttachmentTrigger precisam de aria-label; estado error também no texto da descrição.
- Importar
import { Attachment, AttachmentMedia, AttachmentContent, AttachmentTitle, AttachmentDescription, AttachmentActions, AttachmentAction } from "@financeequity/ui/attachment"Neste repositório:
import { Attachment, AttachmentMedia, AttachmentContent, AttachmentTitle, AttachmentDescription, AttachmentActions, AttachmentAction } from "@/components/ui/attachment"- Dependências
- lucide-react