# astro-file-icon

> Astro component that makes it easy to render themeable svg file icons.

Latest version **1.5.1** (published 2025-02-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install astro-file-icon
pnpm add astro-file-icon
yarn add astro-file-icon
bun add astro-file-icon
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2025-02-05 |
| First published | 2023-09-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 27.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Muhammad Hasan Firdaus |
| Maintainers | hsnfirdaus |
| Keywords | astro-component, withastro, svg, icons, file types, astro, component |

## Links

- npm: https://www.npmjs.com/package/astro-file-icon
- Repository: https://github.com/hsnfirdaus/astro-file-icon
- Homepage: https://github.com/hsnfirdaus/astro-file-icon#readme
- Issues: https://github.com/hsnfirdaus/astro-file-icon/issues
- npm.io page: https://npm.io/package/astro-file-icon

## Dependencies (1)

- [colord](https://npm.io/package/colord.md) ^2.9.3

## Alternatives

- [@fortawesome/react-fontawesome](https://npm.io/package/@fortawesome/react-fontawesome.md) — 2.2M weekly downloads
- [roboto-fontface](https://npm.io/package/roboto-fontface.md) — 196.0K weekly downloads
- [@react-native-vector-icons/common](https://npm.io/package/@react-native-vector-icons/common.md) — 150.4K weekly downloads
- [stockfish](https://npm.io/package/stockfish.md) — 27.0K weekly downloads
- [@procore/core-icons](https://npm.io/package/@procore/core-icons.md) — 4.6K weekly downloads

## Recent versions

- 1.5.1 (latest) — 2025-02-05
- 1.5.0 — 2024-06-30
- 0.3.1 — 2023-09-28
- 0.3.0 — 2023-09-28

## README

# Astro File Icon

[![astro file icon npm version](https://img.shields.io/npm/v/astro-file-icon.svg?style=flat-square&label=npm:astro-file-icon)](https://www.npmjs.com/package/astro-file-icon) [![react file icon npm version](https://img.shields.io/npm/v/react-file-icon.svg?style=flat-square&label=npm:react-file-icon)](https://www.npmjs.com/package/react-file-icon)

Astro component that display icon of file by it's extension. Based on [react-file-icon](https://github.com/corygibbons/react-file-icon).

Take a look at [astro-file-icon.pages.dev](https://astro-file-icon.pages.dev/) to view the default icon styles.

## Installation

```bash
pnpm install astro-file-icon
# Or
yarn add astro-file-icon
# Or
npm install astro-file-icon
```

```js
import { FileIcon } from "astro-file-icon";
```

## Props

| Property          | Type   | Default      | Description                                                                                                                        |
| :---------------- | :----- | :----------- | :--------------------------------------------------------------------------------------------------------------------------------- |
| `color`           | string | `whitesmoke` | Color of icon background                                                                                                           |
| `extension`       | string | `undefined`  | Text to display in label                                                                                                           |
| `fold`            | bool   | `true`       | Displays the corner fold                                                                                                           |
| `foldColor`       | string | `undefined`  | Color of the corner fold                                                                                                           |
| `glyphColor`      | string | `undefined`  | Color of file type icon                                                                                                            |
| `gradientColor`   | string | `white`      | Color of page gradient                                                                                                             |
| `gradientOpacity` | number | `0.25`       | Opacity of page gradient                                                                                                           |
| `labelColor`      | string | `undefined`  | Color of label                                                                                                                     |
| `labelTextColor`  | string | `white`      | Color of label text                                                                                                                |
| `labelUppercase`  | bool   | `false`      | Displays the label in all caps                                                                                                     |
| `radius`          | number | `4`          | Corner radius of the file icon                                                                                                     |
| `type`            | enum   | `undefined`  | Type of [glyph icon to display](https://github.com/hsnfirdaus/astro-file-icon/blob/main/packages/astro-file-icon/src/icon.type.ts) |

## Default Styles

We also export an object of [default styles](https://github.com/hsnfirdaus/astro-file-icon/blob/main/packages/astro-file-icon/src/defaultStyles.ts) that can be used as a starting point when rendering icons. Object keys map to file extensions.

```js
import { FileIcon, defaultStyles } from "astro-file-icon";

// Render a .docx icon with default styles
<FileIcon extension="docx" {...defaultStyles.docx} />;
```

---
_Source: https://npm.io/package/astro-file-icon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
