@expo/material-symbols

中文文档
0.1.1发布于 2026/04/29MITTypeScriptCommonJS零依赖构建来源已验证近 30 天下载 46.5万

Material Symbols icons for Expo, rendered via @expo/ui.

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. How it works
  4. CLI: adding individual icons
  5. Using custom XML icons
  6. Credits
  7. Development

@expo/material-symbols

Material Symbols icon library for Expo/React Native Android. Icons are Android XML vector drawables, imported as Metro assets and rendered via @expo/ui. Only the icons you import are bundled — each icon lives at its own subpath (@expo/material-symbols/star.xml), so unused icons are never resolved by Metro.

Only the outlined style is shipped at the moment. For rounded or sharp styles, see Using custom XML icons.

Installation

bun add @expo/material-symbols

Usage

Each icon is imported from its own subpath:

import { Host, Icon } from "@expo/ui/jetpack-compose";
import Star from "@expo/material-symbols/star.xml";
import Home from "@expo/material-symbols/home.xml";

<Host matchContents>
  <Icon source={Star} size={32} tint="#007AFF" />
</Host>;
  • size — icon size in dp
  • tint — any React Native ColorValue (hex, named color, etc.). Overrides the XML's fill color at runtime.
  • <Host matchContents> is required — without it the Compose host has 0×0 size.

How it works

  • update-icons.ts downloads the latest Material Symbols metadata from Google Fonts.
  • generate.ts uses that metadata to fetch the official outlined Android XML vector drawables from Google's asset host (icons/*.xml) and writes a per-icon .xml.d.ts next to each one so TypeScript can verify the subpath.
  • The package's exports map points ./*.xml at ./icons/*.xml, so import Star from "@expo/material-symbols/star.xml" resolves to the asset and Metro returns a numeric asset ID.
  • The @expo/ui <Icon> component resolves the asset and renders it natively via Jetpack Compose.
  • Icons and their .d.ts files are generated at publish time via prepublishOnly and shipped in the npm tarball. They're gitignored in the repo, so run bun run generate after cloning to populate icons/ for local development.

CLI: adding individual icons

The add-material-symbols CLI downloads Material Symbols icons as Android XML vector drawables. This is useful when you want specific styles or axis values (fill, weight, grade, optical size) beyond the default outlined set.

# By name (defaults: outlined, weight 400, no fill, grade 0, 24px)
npx add-material-symbols search

# Multiple icons at once
npx add-material-symbols search star home

# Rounded style
npx add-material-symbols --style rounded search star

# Sharp + filled
npx add-material-symbols --style sharp --fill favorite

# Custom weight
npx add-material-symbols --weight 300 star

# From a Google Fonts URL (preserves the axes you picked in the UI)
npx add-material-symbols "https://fonts.google.com/icons?selected=Material+Symbols+Outlined:check_box:FILL@1;wght@300;GRAD@0;opsz@24"

# Custom output directory
npx add-material-symbols -o ./my-icons search
OptionDescriptionDefault
-o, --output <dir>Output directory./assets
-s, --style <style>Icon style: outlined, rounded, sharpoutlined
-f, --fillUse filled variant
-w, --weight <wght>Weight: 100–700400
-g, --grade <grad>Grade: -25, 0, 2000
--opsz <size>Optical size: 20, 24, 40, 4824
-h, --helpShow help

The output is a ready-to-use XML vector drawable that you can import directly (see Using custom XML icons).

Using custom XML icons

You can use your own Android XML vector drawables. Place them anywhere in your project and import them:

import { Host, Icon } from "@expo/ui/jetpack-compose";

const MyIcon = require("./assets/my-icon.xml");

<Host matchContents>
  <Icon source={MyIcon} size={32} />
</Host>;

This works for rounded, sharp, or any custom Material Symbols style — you can download the Android drawable XML directly from Google Fonts via add-material-symbols, or provide your own XML asset.

Credits

The icons are from Google's Material Symbols, licensed under Apache 2.0. Package generation uses Google Fonts metadata and Google-hosted Android XML assets.

Development

This package lives in the expo/material-symbols monorepo. From the repo root:

bun install
cd packages/expo-material-symbols && bun run generate  # regenerate icons
cd example && bun run android                          # run the example app

版本与发布记录

@expo/material-symbols 共发布 3 个版本,首次发布于 2026/04/28;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.1latest2026/04/296 个月前
0.1.02026/04/286 个月前
0.0.12026/04/286 个月前

关于 @expo/material-symbols 的常见问题

@expo/material-symbols 是什么?

Material Symbols icons for Expo, rendered via @expo/ui.

如何安装 @expo/material-symbols?

在项目目录运行 npm install @expo/material-symbols,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 add-material-symbols,可以用 npx add-material-symbols 直接运行。

@expo/material-symbols 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@expo/material-symbols 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@expo/material-symbols 可以商用吗?

@expo/material-symbols 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@expo/material-symbols 的下载量有多少?

根据 npm 官方下载统计,@expo/material-symbols 在 2026/10/14 – 2026/11/12 这 30 天内被下载 465,080 次,日均约 15,503 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@expo/material-symbols 还在维护吗?

最新版本 0.1.1 发布于 2026/04/29(6 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/04/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。