@divayth/brick-ui

中文文档
0.10.0发布于 2026/11/11TypeScriptES Module近 30 天下载 6119

React components for Brick UI

原始使用文档
文档目录6 节
  1. Development
  2. Usage
  3. Input and Textarea
  4. Select and Autocomplete
  5. Themes
  6. Structure

Brick UI

React components for React 19 and Next.js: Text, Flex, Button, Card, Chip, Skeleton, IconButton, CircularLoading and ProgressBar.

Development

npm install
npm run typecheck
npm run build
npm run storybook

Usage

import { Button, Flex, Text } from "@divayth/brick-ui";
import "@divayth/brick-ui/styles.css";

<Flex alignItems="center">
  <Text weight="medium">Brick UI</Text>
  <Button>Continue</Button>
</Flex>;

The package ships compiled CSS; consumers do not need Tailwind. No global CSS reset is included. Colors can be overridden via CSS variables. Interactive Button preserves its 'use client' directive; Text and Flex remain server-compatible.

Input and Textarea

Use Input for a single-line field and Textarea for multiline text. Replace <Input multiline rows={5} /> with <Textarea rows={5} />. Both components keep the same field styling, labels, errors, icons, and sizes. Their native props, events, and refs match their respective HTML elements. Textarea grows with its content: use minRows and maxRows to set the limits. Above maxRows, the content scrolls inside the field. rows is used as the minimum when minRows is not provided.

Select and Autocomplete

The value type is inferred from options; explicit JSX type arguments are not needed. SelectProps and AutocompleteProps describe single selection by default. Use SelectProps<number, true> or AutocompleteProps<number, true> for multiple-selection wrappers. multiple and clearable are off by default. Add clearable to allow clearing; clearing a single selection returns undefined. multiple returns an array.

<Autocomplete
  options={[{ value: 1, label: "Alice" }]}
  onChange={(id) => console.log(id)} // number
/>

SelectProps describes selection controls. AutocompleteProps additionally includes onSearchChange, searchPlaceholder, and filterOptions. SelectCommonProps contains the shared props, options, and loading state.

Options are not filtered by default. Pass filterOptions to enable local search, or use onSearchChange to fetch options from a server. Replace the old <Select searchable /> API with <Autocomplete />.

Themes

Provider includes light and dark palettes. It restores the theme from the theme cookie when no initial or controlled theme is supplied.

import { Provider, useProvider } from "@divayth/brick-ui";

function ToggleTheme() {
  const { theme, onChangeTheme } = useProvider();
  return (
    <button onClick={() => onChangeTheme(theme === "dark" ? "light" : "dark")}>
      Toggle theme
    </button>
  );
}

<Provider locale="en">
  <ToggleTheme />
</Provider>;

For SSR, read the cookie on the server and pass its validated value as defaultTheme. Apply getThemeStyle(theme) and data-theme={theme} to html to avoid a light flash before hydration. Next.js is not a dependency. For custom palettes, pass themes to both Provider and getThemeStyle. The optional defaultTheme prop sets the initial theme and takes precedence over the cookie. Mount one global Provider: theme styles and portals share the document root.

For Tailwind v4 applications, register the library tokens in your global CSS:

@import "tailwindcss";
@import "@divayth/brick-ui/theme.css";

Keep importing @divayth/brick-ui/styles.css for component styles.

Structure

  • src/ui — components, CSS Modules and Storybook stories.
  • src/lib — shared size scale, types and tokens.

Size: xs | sm | md | lg | xl. Button supports all five sizes (heights 24 / 32 / 40 / 48 / 56 px). Flex gap supports the same scale (4 / 8 / 16 / 24 / 32 px). Text uses the same names and defaults to md. Text also supports inherit, 2xl, 3xl and 4xl.

Control heights and horizontal padding can be overridden with --height-* and --padding-* CSS variables.

版本与发布记录

@divayth/brick-ui 共发布 40 个版本,首次发布于 2026/10/14;过去 12 个月发布了 40 个版本。

版本发布日期距今
0.10.0latest2026/11/111 天前
0.9.02026/11/102 天前
0.8.02026/11/084 天前
0.7.02026/11/084 天前
0.6.12026/11/075 天前
0.6.02026/11/075 天前

关于 @divayth/brick-ui 的常见问题

@divayth/brick-ui 是什么?

React components for Brick UI

如何安装 @divayth/brick-ui?

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

@divayth/brick-ui 支持 TypeScript 吗?

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

@divayth/brick-ui 支持 ESM 还是 CommonJS?

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

@divayth/brick-ui 可以商用吗?

@divayth/brick-ui 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@divayth/brick-ui 的下载量有多少?

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

@divayth/brick-ui 还在维护吗?

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