Skip to content

File Type Icon

⋯

FileTypeIcon renders the Figma File Type Icon set from the File upload page: a 44px gray tile with a 26px file glyph. File Upload Card renders the same tile for its fileType prop.

import { FileTypeIcon } from "@nesra/ui/file-type-icon";
export function Attachment() {
return (
<span className="flex items-center gap-3">
<FileTypeIcon type="pdf" />
Invoice.pdf
</span>
);
}

FileTypeIcon, FileTypeIconProps, FileTypeIconType, and FILE_TYPE_ICON_TYPES are also exported from @nesra/ui.

type keeps the Figma Type variant names in lowercase. FILE_TYPE_ICON_TYPES lists them in Figma order.

  • img
  • pdf
  • doc
  • xls

Next to a file name the tile is decorative. A tile shown on its own needs an aria-label.

Q3 budget.xlsx240 KB
Shown without a file name, so the tile has an accessible name.

Figma draws Font Awesome glyphs. Nesra UI uses the closest Lucide glyph.

type Figma variant Figma glyph Lucide glyph
img Type=IMG fa7-regular:file-image FileImage
pdf Type=PDF fa7-regular:file-pdf FileText
doc Type=DOC fa7-regular:file-word FileType
xls Type=XLS fa7-regular:file-excel FileSpreadsheet
Part Figma value CSS
Tile 44px, radius-xl, bg-gray size-nesra-unit-21 rounded-nesra-xl bg-nesra-foundation-bg-gray
Glyph 26px, Icon/icon-brand-primary text-nesra-icon-brand-primary

Both roles have Light and Dark values. The tile was checked in both modes.

  • Without aria-label or aria-labelledby, the tile has aria-hidden="true". Put the file type in nearby text, such as the file name.
  • With aria-label or aria-labelledby, the tile renders role="img" with that name.
  • The tile has no built-in text, so it adds no translation keys.
Prop Type Default Effect
type "img" | "pdf" | "doc" | "xls" "pdf" Chooses the file glyph.

Native span attributes, className, and refs are forwarded. The rendered span has data-slot="file-type-icon" and data-type. Inside File Upload Card it also has data-file-upload-card-icon. See also colors and shape tokens.