Mime Type Icon

Displays appropriate icons for different file types and MIME types using the Cubitt icon system.

Overview

The MimeTypeIcon component automatically displays appropriate icons for different file types and MIME types. It uses the comprehensive Cubitt icon system to provide consistent, recognisable visual representations for over 40 different file formats, including full coverage of browser MIME type aliases. Perfect for file managers, document lists, and attachment displays.

Usage

import { MimeTypeIcon } from "@tilt-legal/cubitt-components/primitives";
<MimeTypeIcon mimeType="application/pdf" />
<MimeTypeIcon fileName="document.pdf" />
<MimeTypeIcon mimeType="image/png" className="size-6" />

Examples

Using MIME Types

Using File Names

Different Sizes

File List Example

VirtualFileIcon

The VirtualFileIcon renders a blank document outline with a consumer-provided icon centered on top. Use it for virtual/derived files (transcripts, AI summaries, etc.) that don't map to a real MIME type.

import { VirtualFileIcon } from "@tilt-legal/cubitt-components/primitives";
import { Scroll, Sparkle } from "@tilt-legal/cubitt-icons/ui/outline";

<VirtualFileIcon className="size-[62px]">
  <Scroll />
</VirtualFileIcon>

<VirtualFileIcon className="size-5">
  <Sparkle />
</VirtualFileIcon>

Virtual files (asset_type: "virtual") automatically wrap consumer icons in the blank-file shell — just pass a plain icon node:

const file: FileAsset = {
  id: "t-1",
  name: "Deposition Transcript",
  asset_type: "virtual",
  virtual_type: "transcript",
  status: "active",
  created_at: "2025-01-10T09:00:00.000Z",
  updated_at: "2025-01-10T09:00:00.000Z",
  created_by: "System",
  icon: <Scroll />,
};

Props

PropTypeDefaultDescription
childrenReactNodeIcon to render centered on the blank document outline
classNamestringSize and style via Tailwind (e.g. size-[62px])

Supported File Types

The MimeTypeIcon component supports over 40 different file types across all major categories. It also handles MIME type aliases (e.g., audio/x-m4a, audio/mp4) automatically.

Documents

  • PDF - Portable Document Format
  • DOC/DOCX - Microsoft Word documents
  • XLS/XLSX - Microsoft Excel spreadsheets
  • PPT/PPTX - Microsoft PowerPoint presentations
  • TXT - Plain text files
  • CSV - Comma-separated values

Images

  • JPEG/JPG - JPEG images
  • PNG - Portable Network Graphics
  • GIF - Graphics Interchange Format
  • SVG - Scalable Vector Graphics
  • WEBP - WebP images
  • TIFF - Tagged Image File Format
  • ICO - Icon files

Video

  • MP4 - MPEG-4 video
  • AVI - Audio Video Interleave
  • MOV - QuickTime video
  • MPG - MPEG video

Audio

  • MP3 - MPEG audio
  • WAV - Wave audio
  • AAC - Advanced Audio Coding
  • FLAC - Free Lossless Audio Codec
  • M4A - MPEG-4 audio
  • WMA - Windows Media Audio

Email

  • EML - Email messages (RFC 822)
  • MSG - Outlook email messages

Development

  • HTML - HyperText Markup Language
  • CSS - Cascading Style Sheets
  • JS - JavaScript files
  • JSON - JavaScript Object Notation
  • JAVA - Java source code

Archives & Executables

  • ZIP - ZIP archives
  • RAR - RAR archives
  • DMG - macOS disk images
  • EXE - Windows executables

Props

MimeTypeIcon

PropTypeDefaultDescription
mimeTypestring-MIME type of the file (e.g., "application/pdf")
fileNamestring-File name with extension (e.g., "document.pdf")
classNamestring-Additional CSS classes to apply to the icon
sizenumber | string-Size of the icon (passed to the underlying icon component)

Note: You must provide either mimeType or fileName. If both are provided, the component tries mimeType first, then falls back to the fileName extension. This means a file with an unrecognised MIME type (e.g., application/octet-stream) but a known extension (e.g., report.pdf) will still display the correct icon. If neither matches a supported type, the component renders a generic blank file icon.


Design Guidelines

Usage Patterns

  • File Lists: Use consistent sizing (typically size-5 or size-6) for file listings
  • Attachments: Display alongside file names and sizes for clear identification
  • Upload Areas: Show appropriate icons during file selection or drag-and-drop
  • Document Cards: Use larger sizes (size-8 to size-12) for prominent file representations

Accessibility

  • Context: Always provide file names or descriptions alongside icons for screen readers
  • Fallback: The component includes appropriate fallback behavior for unknown file types
  • Semantic HTML: Icons are decorative and don't require alt text when used with descriptive text

Visual Consistency

  • Sizing: Use consistent icon sizes within the same interface section
  • Spacing: Maintain consistent spacing between icons and accompanying text
  • Color: Icons inherit text color by default and work well with muted foreground colors

On this page