Veil UI
Components

File Card

A file summary with type icon, size and optional actions.

Installation

$ npx veil-ui@latest add file-card

Usage

import { FileCard } from "@/components/ui/file-card";

<FileCard name="quarterly-report.pdf" size="2.4 MB" kind="pdf" />;

Examples

Basic

quarterly-report.pdf

2.4 MB · PDF

With actions

hero-banner.png

860 KB · IMAGE

notes.txt

4 KB · TEXT

Shared with the design team.

API reference

The package exports file-card along with its composable parts. It forwards standard attributes to its root element; see the examples above for the component-specific props.

Accessibility

  • Content uses semantic HTML — lists are lists, tables are tables and metadata uses a definition list.
  • Interactive elements are real buttons or links with visible focus states.
  • Images require meaningful alt text; icons used decoratively are aria-hidden.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add file-card --framework vue or switch the framework in components.json.

<script setup lang="ts">
import {
  File,
  FileArchive,
  FileImage,
  FileSpreadsheet,
  FileText,
} from "lucide-vue-next";
import type { Component } from "vue";

import { Card, CardContent } from "@/components/ui/card";
import { cn } from "@/lib/utils";

import type { FileKind } from "./types";

const props = withDefaults(
  defineProps<{
    name: string;
    size?: string;
    kind?: FileKind;
    description?: string;
    class?: string;
  }>(),
  { kind: "other" },
);

const kindIcon: Record<FileKind, Component> = {
  pdf: FileText,
  image: FileImage,
  sheet: FileSpreadsheet,
  archive: FileArchive,
  text: FileText,
  other: File,
};

const kindColor: Record<FileKind, string> = {
  pdf: "text-red-600 bg-red-500/10 dark:text-red-400",
  image: "text-violet-600 bg-violet-500/10 dark:text-violet-400",
  sheet: "text-emerald-600 bg-emerald-500/10 dark:text-emerald-400",
  archive: "text-amber-600 bg-amber-500/10 dark:text-amber-400",
  text: "text-sky-600 bg-sky-500/10 dark:text-sky-400",
  other: "text-muted-foreground bg-muted",
};
</script>

<template>
  <Card
    data-slot="file-card"
    :class="cn('max-w-sm gap-3', props.class)"
  >
    <CardContent class="flex items-start gap-3">
      <span
        :class="
          cn(
            'flex size-10 shrink-0 items-center justify-center rounded-lg',
            kindColor[kind],
          )
        "
      >
        <component :is="kindIcon[kind]" class="size-5" aria-hidden="true" />
      </span>
      <div class="min-w-0 flex-1">
        <p class="truncate text-sm font-medium">{{ name }}</p>
        <p class="text-xs text-muted-foreground">
          <span v-if="size">{{ size }} · </span>
          {{ kind.toUpperCase() }}
        </p>
        <p v-if="description" class="mt-1 text-sm text-muted-foreground">
          {{ description }}
        </p>
      </div>
      <div
        v-if="$slots.actions"
        class="flex shrink-0 items-center gap-1"
      >
        <slot name="actions" />
      </div>
    </CardContent>
  </Card>
</template>

On this page