@economic/taco

中文文档
17.1.0发布于 2026/11/17MITTypeScriptESM + CJS近 30 天下载 6446

UI React component library

原始使用文档
文档目录13 节
  1. Usage
  2. Installation
  3. Peer Dependencies
  4. Styling
  5. PostCSS Configuration
  6. Development
  7. Prerequisites
  8. Getting Started
  9. Available Scripts
  10. Storybook
  11. Guidelines for New Components
  12. Linting
  13. Testing

@economic/taco

UI React component library

Usage

import { Button } from '@economic/taco';

const MyComponent = () => <Button>Guacamole</Button>;

Installation

npm install --save @economic/taco

Peer Dependencies

PackageVersion
react^18.3.1
react-dom^18.3.1
tailwindcss>=3.4.19

Styling

Taco ships a pre-compiled CSS file (dist/taco.css) that contains its component styles. However, consumers still need their own Tailwind setup to use the design system's theme tokens and utility classes in their application code.

Browser targeting, purging and minification should be performed by you, the consumer.

Your tailwind.config.js should use the taco config as a preset:

module.exports = {
    presets: [require('@economic/taco/tailwind.config.js')],
    content: {
        files: ['./src/**/*.{ts,tsx}', './node_modules/@economic/taco/dist/**/*.js'],
    },
};

Then import the Tailwind layers and the taco stylesheet in your application CSS:

@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import '@economic/taco/taco.css';
@import 'tailwindcss/utilities';

PostCSS Configuration

Important: This design system requires postcss-import to function properly.

The CSS imports above use @import statements instead of the @tailwind directive because of the postcss-import plugin. This is necessary to avoid issues when importing additional CSS files.

Your PostCSS config should look something like this:

module.exports = {
    plugins: ['postcss-import', 'tailwindcss', 'autoprefixer'],
};

Development

Prerequisites

  • Node >=24 (managed via Volta, see root package.json)
  • This package lives in a monorepo alongside @economic/taco-tokens. Always run npm install from the repository root.

Getting Started

# from the repository root
npm install
npm run dev        # starts Storybook on http://localhost:6006

Available Scripts

Run these from the package directory (packages/taco):

ScriptDescription
npm run buildType-check with tsc then build the library with Vite
npm testRun unit tests with Vitest
npm run lintRun stylelint on CSS files and oxlint on JS/TS files
npm run e2eRun Playwright end-to-end tests
npm run generate-iconsRegenerate icon components from SVG sources

Or from the repository root:

ScriptDescription
npm run devStart Storybook on port 6006
npm run buildBuild all packages
npm run lint:stylesRun stylelint for @economic/taco (src/**/*.css)
npm run lint:classesRun the class-linter on all TSX/TS source files

Storybook

Storybook is the primary development and documentation environment. Run npm run dev from the repository root to start it. Component stories and documentation live alongside their implementations in __stories__/ folders.

Guidelines for New Components

Create a folder under src/components/ with the name of the component, e.g. <NewComponent />:

src/components/
├── NewComponent/
│   ├── __stories__/
│   │   ├── NewComponent.dev.stories.tsx
│   │   ├── NewComponent.mdx
│   │   └── NewComponent.stories.tsx
│   ├── NewComponent.css
│   ├── NewComponent.spec.tsx
│   ├── NewComponent.e2e.ts
│   └── NewComponent.tsx

The component's style, implementation, tests, and documentation are co-located in its own folder.

FilePurpose
__stories__/NewComponent.mdxComponent documentation
__stories__/NewComponent.dev.stories.tsxDevelopment stories for Storybook
__stories__/NewComponent.stories.tsxStories used in documentation
NewComponent.cssComponent styles, directly imported in the implementation
NewComponent.spec.tsxUnit tests (Vitest)
NewComponent.e2e.tsEnd-to-end tests (Playwright), if applicable
NewComponent.tsxComponent implementation

Linting

Three linting layers run across the codebase:

ToolScopeDescription
oxlintJS/TS filesGeneral code quality linting
stylelintCSS files (src/**/*.css)Encourages approved design tokens
class-linterTSX/TS filesFlags disallowed class usage (local oxlint JS plugin)

Stylelint and the class-linter also run as pre-commit hooks via nano-staged.

The design-token rules for both stylelint and oxlint come from @economic/taco-rules, so CSS and TSX accept the same classes. taco's configs (stylelint.config.mjs, .oxlintrc.json, .oxlintrc.classes.json) extend its shipped configs and only override single rules. CSS and TS/TSX are switched separately: stylelint.config.mjs for CSS, both .oxlintrc.json and .oxlintrc.classes.json for TS/TSX.

Testing

  • Unit tests use Vitest with @testing-library/react. Test files follow the *.spec.tsx convention.
  • End-to-end tests use Playwright. Test files follow the *.e2e.ts convention.

版本与发布记录

@economic/taco 共发布 857 个版本,首次发布于 2022/01/14;过去 12 个月发布了 247 个版本。

版本发布日期距今
17.1.0latest2026/11/17今天
17.1.0-EC-91962-test-release.0canary2026/11/161 天前
17.1.0-EC-87491-formatting-config.02026/11/124 天前
17.0.1-EC-00234-table3-bundle.02026/11/115 天前
17.0.02026/11/106 天前
17.0.0-EC-90745-test-release.02026/11/107 天前

其他发布通道:next → 0.0.1-alpha.1543,canary → 17.1.0-EC-91962-test-release.0。

关于 @economic/taco 的常见问题

@economic/taco 是什么?

UI React component library

如何安装 @economic/taco?

在项目目录运行 npm install @economic/taco,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:clsx(^2.1.1)、react(^18.3.1 || ^19.0.0)、react-dom(^18.3.1 || ^19.0.0)、tailwindcss(^3.4.19)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@economic/taco 支持 TypeScript 吗?

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

@economic/taco 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@economic/taco 可以商用吗?

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

@economic/taco 的下载量有多少?

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

@economic/taco 还在维护吗?

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