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.
Examples
Section titled “Examples”type keeps the Figma Type variant names in lowercase. FILE_TYPE_ICON_TYPES lists them in
Figma order.
import { FILE_TYPE_ICON_TYPES, FileTypeIcon } from "@nesra/ui/file-type-icon";
export function FileTypeIconTypesExample() { return ( <ul className="m-0 flex list-none flex-wrap gap-6 p-0"> {FILE_TYPE_ICON_TYPES.map((type) => ( <li className="grid justify-items-center gap-2 type-nesra-body-xsmall-medium text-nesra-text-support" key={type} > <FileTypeIcon type={type} /> <code>{type}</code> </li> ))} </ul> );}Beside a file name
Section titled “Beside a file name”Next to a file name the tile is decorative. A tile shown on its own needs an aria-label.
import { FileTypeIcon } from "@nesra/ui/file-type-icon";
export function FileTypeIconFileRowExample() { return ( <div className="grid gap-4"> <div className="flex items-center gap-3"> <FileTypeIcon type="xls" /> <div className="grid"> <span className="type-nesra-body-small-semibold text-nesra-text-headline"> Q3 budget.xlsx </span> <span className="type-nesra-body-xsmall-medium text-nesra-text-support">240 KB</span> </div> </div> <div className="flex items-center gap-3"> <FileTypeIcon aria-label="Image file" type="img" /> <span className="type-nesra-body-small-regular text-nesra-text-body"> Shown without a file name, so the tile has an accessible name. </span> </div> </div> );}Figma mapping
Section titled “Figma mapping”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.
Accessibility
Section titled “Accessibility”- Without
aria-labeloraria-labelledby, the tile hasaria-hidden="true". Put the file type in nearby text, such as the file name. - With
aria-labeloraria-labelledby, the tile rendersrole="img"with that name. - The tile has no built-in text, so it adds no translation keys.
API reference
Section titled “API reference”| 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.