@dcs-tech/ui

中文文档
0.13.0发布于 2026/11/12UNLICENSEDTypeScriptES Module近 30 天下载 2021

React UI component library — fields, buttons, tooltips, tables and design tokens.

原始使用文档
文档目录13 节
  1. Install
  2. Use
  3. What's in it
  4. DataTable and Charts
  5. Files and the background worker
  6. Form validation
  7. Theming
  8. Sizes and variants
  9. Field width
  10. List width
  11. Icon size
  12. Dialog width
  13. Licence

@dcs-tech/ui

React UI components and design tokens — form fields, buttons, tooltips, popups and layout primitives, built on one shared control surface so every control agrees on size, spacing and state.

Install

npm i @dcs-tech/ui react react-dom

React >=18 is a peer dependency — your app brings its own copy.

Use

import { Button, Input, Select, Suggest, Tooltip, Typography } from '@dcs-tech/ui';
import '@dcs-tech/ui/style.css';   // tokens + component CSS, import once at the root

export const Example = () => (
  <>
    <Input label="Party name" tooltip="Legal name as printed on the invoice" />
    <Select label="Material" options={[{ name: 'Cotton', value: 'cotton' }]} search group />
    <Tooltip content="Deletes this row"><Button color="error">Delete</Button></Tooltip>
    <Typography variant="body1" truncate={{ lines: 2 }}>Long text…</Typography>
  </>
);

What's in it

  • Fields — Input, Select, Suggest, DatePicker (a day, a range, or picker="month" / "year"), Checkbox, Radio, Switch, ChipInput (including free-text tags), all sharing one control surface, a 6-step size scale and one state model
  • Images — ImagePicker, ImageStrip, ImageViewer, and ImageEditor (crop, zoom, rotate, straighten, flip; each tool can be allowed or restricted). prepareImage applies the same transform with no UI
  • Overlays — Dialog (useDialog() for confirms; DialogHost if you do not use UIProvider), Popover, DropdownMenu, Toast
  • Primitives — Button, Typography, Tooltip, Alert (with a page-wide banner form)
  • Navigation — Link (as takes a router's link), Pagination, CommandPaletteTrigger, PageProgress (a route-change bar, driven by active), NavList (a vertical link list for inside a page)
  • Layout — Collapsible, FieldWrapper
  • Lists — ReorderList (drag to reorder: rows slide live, with mouse, touch or keyboard)
  • Composites — Form, Fields, EditableTable
  • Data — DataTable (client data or a server dataSource: views, search, filters, sort, grouping, column chooser, table / card / split layouts, toolbarActions, selection + bulk actions (the table reports what onRun returns, and nothing if it returns nothing), header / footer summaries with charts, export to xlsx / pdf / csv / html / json / xml) and Charts (Chart, ColumnChart, BarList, Donut, Progress, Legend, ChartTable, LineChart, Funnel, Gauge, Treemap, … with a picture menu)
  • Scroll — one scrollbar rule (thin, hidden until needed) in style.css, edge fades (.scroll-fade-x / .scroll-fade-y) and ScrollStrip for tab / chip rows. UIProvider starts its listener; without it, mount <ScrollRule /> once
  • Tokens — a hue-variable theme: --primary-hue: 211 retints the whole palette from one number, with light and dark themes keyed off data-theme

DataTable and Charts

import { DataTable, Donut, type DataTableView } from '@dcs-tech/ui';

const view: DataTableView<Order> = {
  id: 'all', rowKey: 'id',
  columns: [
    { key: 'customer', header: 'Customer' },
    { key: 'amount', header: 'Amount', type: 'number', align: 'right', summable: true },
  ],
  export: { quick: { filename: 'Orders' } },
};

<DataTable data={orders} views={[view]} tableId="orders" />;          // client mode
<DataTable dataSource={source} views={[view]} tableId="orders" />;    // server mode
<Donut ariaLabel="By status" slices={[{ key: 'a', label: 'Open', value: 12, slot: 1 }]} />;

The table's runtime dependencies (@tanstack/react-table, @tanstack/react-virtual, @tanstack/match-sorter-utils, exceljs and pdfmake — loaded on the first PDF export) install with the package. The icons are the library's own (IconFilter, filterIcon, …): it has no icon dependency.

Files and the background worker

Exports (DataTable, chart images, your own reports) run through one file engine that UIProvider sets up. Excel and PDF files build in a background worker, so a large export does not freeze the page.

The worker ships as its own file and imports exceljs and pdfmake by package name, so your bundler must treat it as a worker entry:

  • Vite and webpack 5: nothing to do. They follow the package's new Worker(new URL(…, import.meta.url)) and bundle the worker themselves.

  • Anything else: build a worker from @dcs-tech/ui/file-worker with your bundler and hand it to the engine:

    // file.worker.ts — bundled by your setup as a module worker
    import '@dcs-tech/ui/file-worker';
    
    <UIProvider fileEngine={{ createWorker: () => new Worker('/assets/file.worker.js', { type: 'module' }) }}>
    

If a worker cannot start, the engine builds the same file on the main thread instead. fileEngine={{ workers: 'off' }} always uses the main thread. Large PDF fonts (a script font) belong on the engine, so they reach each worker once: fileEngine={{ pdfFonts: { fonts, vfs } }}.

Form validation

Form validates with any Standard Schema library — Zod 3.24+, Valibot 1+, ArkType 2+, Yup 1.7+ — with no adapter:

import { z } from 'zod'

<Form fields={fields} defaultData={data} validation={{ schema: z.object({ name: z.string().min(1, 'Required') }), validateOnBlur: true }} />

Errors are keyed by each issue's path (address.city). Leaving a field checks only that field; a failed submit shows every error and focuses the first. For other schemas (e.g. Yup before 1.7), pass validate: (schema, data) => ({ valid, errors }) as before. The form's words (Submit, Reset, its error toasts) come from UIProvider labels.form.

Theming

Every colour, size and spacing value is a CSS custom property. Override them on :root after importing the stylesheet:

:root { --primary-hue: 264; }          /* retints the entire theme */
:root { --border-radius-sm: 4px; }

Sizes and variants

size is uniform across every control: xxs | xs | small | medium | large | xl.

variant is per family — outlined | filled | standard | underlined for text fields, outlined | filled | standard for Checkbox and Radio, none for Switch.

Field width

A text field fills the space its parent gives it, up to 320px. width changes that:

widthThe field is
not giventhe available space, up to 320px
"full"the whole row, with no limit
"auto"as wide as its content
240, "15rem"exactly that, never wider than its parent

In a table cell (layout="cell") the column decides and width is ignored. With layout="horizontal" it sizes the control; the label keeps its column.

List width

A Select or Suggest list fits its content: never narrower than its field, up to 320px (Select) or 480px (Suggest), and always on screen. listWidth="field" makes it exactly the field's width.

Icon size

An icon-only button or a Sidebar row sizes its icon with the --icon-size-xxs … --icon-size-xl tokens, which follow --ui-scale. Override them on :root to change icon sizes across the app. An icon given its own size keeps it.

Dialog width

Dialog takes size="sm | md | lg | xl | full" (420 / 560 / 720 / 960 px / the whole window). For any other width, set --dialog-width. It is the supported way, and it wins over size:

<Dialog open title="Wide" style={{ '--dialog-width': '840px' } as React.CSSProperties} />
.invoice-dialog { --dialog-width: min(1100px, 95vw); }  /* <Dialog className="invoice-dialog"> */

For a side or top/bottom sheet (placement), it sets the panel's width or its max width.

Licence

UNLICENSED — © 2026 Noyyal Tech. All rights reserved.

版本与发布记录

@dcs-tech/ui 共发布 12 个版本,首次发布于 2026/07/31;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.13.0latest2026/11/122 天前
0.12.02026/11/104 天前
0.11.02026/11/095 天前
0.10.02026/11/077 天前
0.9.02026/11/068 天前
0.8.02026/11/059 天前

关于 @dcs-tech/ui 的常见问题

@dcs-tech/ui 是什么?

React UI component library — fields, buttons, tooltips, tables and design tokens.

如何安装 @dcs-tech/ui?

在项目目录运行 npm install @dcs-tech/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18)、react-dom(>=18)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dcs-tech/ui 支持 TypeScript 吗?

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

@dcs-tech/ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dcs-tech/ui 可以商用吗?

@dcs-tech/ui 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@dcs-tech/ui 的下载量有多少?

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

@dcs-tech/ui 还在维护吗?

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