百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

enum-plus

> 前端框架
开源

替换原生枚举的插入式替代方案。与原生枚举类似,但性能更好!

200 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

替换原生枚举的插入式替代方案。与原生枚举类似,但性能更好!

English | 中文 | CHANGELOG

A solution for business dictionary management

Like native enum, but much better!

Supported Platforms         Introduction • Get Started • API Reference • Global Configuration • User Stories • Plugin System • Localization • Extensibility • Best Practices • Compatibility • FAQ • Full API Reference

Why enum-plus

Native enums are great for constants, but product code usually needs more at runtime:

  • human-readable label,
  • metadata such as color, icon, or permission
  • dropdowns, checkboxes, and menus,
  • table filters,
  • render a label in a table,
  • render a badge color,
  • localization,
  • metadata lookups,
  • validation and lookup helpers.

enum-plus keeps the direct enum-style experience, then adds those runtime capabilities in one place.

It's a front-end business dictionary solution, that provides a lightweight data source. It's part of the front-end infrastructure.

Want to see what enum-plus can do and how it improves productivity? See Full Demo

Features

  • Compatible with the usage of native enums
  • Supports multiple data types such as number and string
  • Enhanced enum items with display names
  • Internationalization support for display names, can be integrated with any i18n library
  • Converts values directly into display names, simplifying data display in the UI
  • Extensible design, allowing custom metadata fields for enum items
  • Plugin system design, extending enum functionality through plugin installations
  • Supports type narrowing to enhance type safety_  TypeScript_
  • Generates dropdowns from enums, compatible with UI libraries like Ant Design, Element Plus, Material-UI
  • Compatible with various environments including Browsers, Node.js, React Native, Taro, and mini-programs
  • Supports server-side rendering (SSR)
  • Compatible with any front-end development framework, including vanilla projects
  • TypeScript‑oriented, providing excellent type inference and code completion capabilities
  • Zero dependencies
  • Lightweight (min+gzip 2KB+ only)

Installation

bash
npm install enum-plus

Quick example

…

i18n

typescript
import i18nPlugin from '@enum-plus/plugin-i18next';
import { Enum } from 'enum-plus';

Enum.install(i18nPlugin);

const StatusEnum = Enum({
  Draft: { value: 1, label: 'locales.enums.statusEnum.draft' },
  Review: { value: 2, label: 'locales.enums.statusEnum.review' },
  Published: { value: 3, label: 'locales.enums.statusEnum.published' },
});

StatusEnum.labels; // ['Draft', 'In Review', 'Published'] or ['草稿', '审核中', '已发布']
StatusEnum.label(2); // 'In Review' or '审核中'
StatusEnum.named.Review.label; // 'In Review' or '审核中'

Ecosystem

  • @enum-plus/plugin-react
  • @enum-plus/plugin-react-i18next
  • @enum-plus/plugin-i18next
  • @enum-plus/plugin-i18next-vue
  • @enum-plus/plugin-vue-i18n
  • @enum-plus/plugin-next-international
  • @enum-plus/plugin-antd

Support

If this project helps you, please consider giving it a Star ⭐️ on GitHub. This will encourage us to continue developing and maintaining this project.

Issues· 1 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptback-endenumenumerationfront-end

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架