@fohte/ui

中文文档
0.1.8发布于 2026/11/07MITES Module构建来源已验证近 30 天下载 2649

Shared design tokens and React components for fohte applications.

原始使用文档
文档目录4 节
  1. Installation
  2. Usage
  3. React components
  4. License

@fohte/ui

Shared design tokens and React components for fohte applications.

Installation

pnpm add @fohte/ui

Usage

@import 'tailwindcss';
@import '@fohte/ui/tokens.css';

The package provides light tokens at :root and dark tokens under .dark, plus font stacks, radius values, and a 2xs text size. Colors are available as Tailwind utilities such as bg-background and text-foreground.

The package does not follow prefers-color-scheme; the consuming application controls when .dark is applied. Tailwind CSS v4 is required to process the @theme directives. The font stacks reference JetBrains Mono Variable and IBM Plex Mono, which this package does not bundle; load the font files in your application if needed.

React components

Import components from their subpaths:

import { BottomNavigation } from '@fohte/ui/bottom-navigation'
import { Button } from '@fohte/ui/button'
import { ButtonGroup } from '@fohte/ui/button-group'
import { Checkbox } from '@fohte/ui/checkbox'
import { Chip } from '@fohte/ui/chip'
import { CommandPalette } from '@fohte/ui/command-palette'
import { Dialog, DialogContent, DialogTitle } from '@fohte/ui/dialog'
import { FieldTrigger } from '@fohte/ui/field-trigger'
import { Input } from '@fohte/ui/input'
import { Kbd } from '@fohte/ui/kbd'
import { List, ListItem } from '@fohte/ui/list'
import { Panel } from '@fohte/ui/panel'
import { Popover, PopoverContent, PopoverTrigger } from '@fohte/ui/popover'
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from '@fohte/ui/select'
import { SegmentedControl } from '@fohte/ui/segmented-control'
import { Tabs, TabsList, TabsPanel, TabsTab } from '@fohte/ui/tabs'
import { Textarea } from '@fohte/ui/textarea'
import { Tooltip, TooltipContent, TooltipTrigger } from '@fohte/ui/tooltip'

BottomNavigation accepts links and action buttons in one horizontal row. Each item has an id and visible label, and can also include an icon, selected state, and className. Link items use renderLink to wrap the content with the consuming application's router component. The render slot receives the link content, styling class, and current-page state. Replace openComposer in the example with the application's action handler.

import {
  BottomNavigation,
  type BottomNavigationItem,
} from '@fohte/ui/bottom-navigation'

const items = [
  {
    id: 'overview',
    type: 'link' as const,
    label: 'Overview',
    selected: true,
    renderLink: ({ children, ...props }) => (
      <a href="/overview" {...props}>
        {children}
      </a>
    ),
  },
  {
    id: 'compose',
    type: 'button' as const,
    label: 'Compose',
    onClick: openComposer,
  },
] satisfies ReadonlyArray<BottomNavigationItem>

<BottomNavigation aria-label="Primary navigation" items={items} />

The component provides semantic token colors, single-line labels, and horizontal scrolling when the items do not fit. Pass className to style or position the navigation for the application layout, and set an item's className to customize its appearance. fixed or sticky placement and space for the bar remain the consuming application's responsibility.

React, React DOM, @base-ui/react, and lucide-react are peer dependencies. Make sure they are available in the consuming application. Their supported version ranges are declared in package.json.

The component subpaths publish TSX source, so the consuming bundler must transform TSX from dependencies.

The components also require Tailwind CSS v4, tw-animate-css, and shadcn in the consuming application. Install them as development dependencies if they are not already present:

pnpm add -D tailwindcss@^4 tw-animate-css@^1 shadcn@^4

For example, a select can be composed from its trigger, value, content, and items:

<Select defaultValue="first">
  <SelectTrigger aria-label="Choose an option">
    <SelectValue placeholder="Choose an option" />
  </SelectTrigger>
  <SelectContent>
    <SelectItem value="first">First option</SelectItem>
    <SelectItem value="second">Second option</SelectItem>
  </SelectContent>
</Select>

The consuming application's CSS must load Tailwind CSS v4, tw-animate-css, shadcn/tailwind.css, and this package's tokens. Tailwind v4 ignores dependency files by default, so explicitly register the package source using @source. Adjust the path relative to the stylesheet:

@import 'tailwindcss';
@import 'tw-animate-css';
@import 'shadcn/tailwind.css';
@import '@fohte/ui/tokens.css';

@source '../node_modules/@fohte/ui/src';

License

MIT © Hayato Kawai

版本与发布记录

@fohte/ui 共发布 10 个版本,首次发布于 2026/09/24;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.8latest2026/11/078 天前
0.1.72026/10/2125 天前
0.1.62026/10/1927 天前
0.1.52026/10/1729 天前
0.1.42026/10/151 个月前
0.1.32026/10/041 个月前

关于 @fohte/ui 的常见问题

@fohte/ui 是什么?

Shared design tokens and React components for fohte applications.

如何安装 @fohte/ui?

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

@fohte/ui 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/fohte__ui 是否存在。

@fohte/ui 支持 ESM 还是 CommonJS?

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

@fohte/ui 可以商用吗?

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

@fohte/ui 的下载量有多少?

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

@fohte/ui 还在维护吗?

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