Menu

File icon

Added in 1.8.0

A sheet of paper with the file format on a colored label, for uploads, attachments and file lists.

Basic example

Add .file-icon to an empty element and put the file format in data-type. The component draws the sheet and shows the format on the label in upper case.

<span class="file-icon" data-type="pdf" role="img" aria-label="PDF file"></span>

Formats

Common formats get a color on their own, so no extra class is needed. Any other format gets a gray label.

Color Formats
Red pdf
Blue doc, docx, txt, rtf
Green xls, xlsx, csv
Orange ppt, pptx
Yellow zip, rar, 7z
Purple jpg, jpeg, png, gif, svg, webp
Pink mp3, wav, mp4, mov
<div class="d-flex flex-wrap gap-3">
  <span class="file-icon" data-type="pdf" role="img" aria-label="PDF file"></span>
  <span class="file-icon" data-type="doc" role="img" aria-label="DOC file"></span>
  <span class="file-icon" data-type="xls" role="img" aria-label="XLS file"></span>
  <span class="file-icon" data-type="ppt" role="img" aria-label="PPT file"></span>
  <span class="file-icon" data-type="zip" role="img" aria-label="ZIP file"></span>
  <span class="file-icon" data-type="png" role="img" aria-label="PNG file"></span>
  <span class="file-icon" data-type="mp4" role="img" aria-label="MP4 file"></span>
  <span class="file-icon" data-type="json" role="img" aria-label="JSON file"></span>
</div>

The label fits up to four characters. Use the short form of a longer format.

Colors

Add a .file-icon-{color} class to choose the color yourself. It also overrides the color of a known format.

<div class="d-flex flex-wrap gap-3">
  <span class="file-icon file-icon-azure" data-type="md" role="img" aria-label="MD file"></span>
  <span class="file-icon file-icon-teal" data-type="json" role="img" aria-label="JSON file"></span>
  <span class="file-icon file-icon-indigo" data-type="fig" role="img" aria-label="FIG file"></span>
  <span class="file-icon file-icon-primary" data-type="pdf" role="img" aria-label="PDF file"></span>
</div>

Sizes

Use .file-icon-sm or .file-icon-lg to change the size. For any other size set --tblr-file-icon-size on the icon; the sheet and the label scale with it.

<div class="d-flex align-items-end gap-3">
  <span class="file-icon file-icon-sm" data-type="pdf" role="img" aria-label="PDF file"></span>
  <span class="file-icon" data-type="pdf" role="img" aria-label="PDF file"></span>
  <span class="file-icon file-icon-lg" data-type="pdf" role="img" aria-label="PDF file"></span>
  <span class="file-icon" data-type="pdf" style="--tblr-file-icon-size: 4rem" role="img" aria-label="PDF file"></span>
</div>

Without a label

Leave out data-type to show a blank sheet.

<span class="file-icon" role="img" aria-label="File"></span>

With a file name

Put the icon next to the file name in an upload list or a table of files. The name already says the format, so hide the icon with aria-hidden="true".

Invoice 2026-11.pdf
320 KB
<div class="d-flex align-items-center gap-3">
  <span class="file-icon" data-type="pdf" aria-hidden="true"></span>
  <div>
    <div class="fw-medium">Invoice 2026-11.pdf</div>
    <div class="text-secondary">320 KB</div>
  </div>
</div>

Accessibility

  • An icon without a file name next to it needs role="img" and an aria-label that names the format, for example "PDF file".
  • An icon next to a file name is decoration. Hide it with aria-hidden="true".
  • Do not rely on the color alone. The label text carries the format, the color only supports it.

Class reference

Every class this component ships, grouped by what it changes. A name in braces stands for a family — {color} is any base color, {breakpoint} any responsive step.

file-icon componentThe icon; the label text comes from the data-type attribute
file-icon-{color} colorColors the label with a theme color
file-icon-sm sizeSmall icon
file-icon-lg sizeLarge icon

CSS

Variables

The component uses local CSS variables for real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.

On .file-icon. Source: core/scss/ui/_file-icon.scss.

--file-icon-size: #{$file-icon-size};
--file-icon-color: #{$file-icon-color};
--file-icon-fg: #{$white};
--file-icon-bg: var(--bg-surface);
--file-icon-outline: #{escape-svg($file-icon-outline)};
--file-icon-border-color: light-dark(var(--gray-300), var(--gray-600));

Sass variables

Override these variables before importing Tabler to change the defaults.

Source: core/scss/_variables.scss.

$file-icon-size: map.get(map.get($avatar-sizes, 'md'), size);
$file-icon-size-sm: map.get(map.get($avatar-sizes, 'sm'), size);
$file-icon-size-lg: map.get(map.get($avatar-sizes, 'lg'), size);
$file-icon-color: $text-secondary;
$file-icon-outline: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 40' preserveAspectRatio='none' fill='none' stroke='#000' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><path d='M19.5.75H5A4.25 4.25 0 0 0 .75 5v30A4.25 4.25 0 0 0 5 39.25h20A4.25 4.25 0 0 0 29.25 35V10.5zv6.75a3 3 0 0 0 3 3h6.75'/></svg>");
$file-icon-label-font-weight: $font-weight-bold;
$file-icon-types: (
  'red': ('pdf'),
  'blue': (
    'doc',
    'docx',
    'txt',
    'rtf',
  ),
  'green': (
    'xls',
    'xlsx',
    'csv',
  ),
  'orange': (
    'ppt',
    'pptx',
  ),
  'yellow': (
    'zip',
    'rar',
    '7z',
  ),
  'purple': (
    'jpg',
    'jpeg',
    'png',
    'gif',
    'svg',
    'webp',
  ),
  'pink': (
    'mp3',
    'wav',
    'mp4',
    'mov',
  ),
);