@serenis/ui

中文文档
6.94.0发布于 2026/11/02LicenseRef-PolyForm-Noncommercial-1.0.0TypeScriptESM + CJS

Main UI component library for the Serenis design system. Provides reusable React components with Storybook documentation, design-token integration, and accessibility support. Components are styled with colocated CSS Modules and @serenis/design-tokens.

原始使用文档
文档目录16 节
  1. Install
  2. Quick start
  3. Directory structure
  4. Component catalog
  5. General
  6. Data Display
  7. Feedback
  8. Form
  9. Navigation
  10. Layout
  11. Dependencies
  12. Styling conventions
  13. Documentation
  14. Consumers
  15. Build
  16. License

@serenis/ui

Main UI component library for the Serenis design system. Provides reusable React components with Storybook documentation, design-token integration, and accessibility support. Components are styled with colocated CSS Modules and @serenis/design-tokens.

Install

npm install @serenis/ui

Quick start

# Build
yarn workspace @serenis/ui build

# Dev (watch mode)
yarn workspace @serenis/ui dev

# Test
yarn workspace @serenis/ui test

# Typecheck
yarn workspace @serenis/ui typecheck

# Lint
yarn workspace @serenis/ui lint
yarn workspace @serenis/ui lint:css

When consuming the published package from npm, load component CSS modules once with import '@serenis/ui/css'. This ships a single dist/index.css for all CSS-module components. Monorepo apps that resolve @serenis/ui to source must not import it (the app bundler handles *.module.css). Per-component CSS loading may replace this later.

import '@serenis/ui/css'
import { cx } from '@serenis/design-tokens'
import { Button, Card } from '@serenis/ui'
;<Card>
  <div className={cx('flex', 'flex-col', 'gap-sm')}>
    <h2 className={cx('typography-h2')}>Session details</h2>
    <p className={cx('typography-paragraph', 'text-neutral-80')}>Your next session is scheduled for tomorrow.</p>
    <Button kind="primary">Confirm</Button>
  </div>
</Card>

Directory structure

libraries/ui/
├── src/
│   ├── {ComponentName}/
│   │   ├── index.tsx               # Main component (or {ComponentName}.tsx)
│   │   ├── index.test.tsx          # Tests
│   │   ├── Playground.stories.tsx  # Primary Storybook story
│   │   ├── Overview.mdx            # Component documentation
│   │   └── types.ts                # Type definitions (if complex)
│   ├── Form/                       # Composite form module
│   │   ├── TextField/
│   │   ├── TextAreaField/
│   │   ├── SelectField/
│   │   ├── PasswordField/
│   │   ├── PhoneNumberField/
│   │   ├── PinCodeField/
│   │   ├── Autocomplete/
│   │   ├── MultiSelect/
│   │   ├── Checkbox/
│   │   ├── CheckboxButton/
│   │   ├── Radio/
│   │   ├── RadioButton/
│   │   ├── SliderField/
│   │   ├── Switch/
│   │   ├── SwitchField/
│   │   ├── FileUploadField/
│   │   ├── internal/               # Shared internal chrome and styles
│   ├── utils/                      # Shared utilities (shouldForwardProp)
│   └── index.ts                    # Public API barrel
├── dist/                           # Built output (gitignored)
├── tsup.config.ts                  # Bundle config
└── package.json

Component catalog

Categories match Storybook (*.stories.tsx / Overview.mdx <Meta title>): General, Data Display, Feedback, Form, Navigation, Layout.

General

ComponentDescription
ButtonPrimary interactive element — actions, submits, navigation
TextDeprecated. Typographic primitive

Data Display

ComponentDescription
AccordionExpandable section with trigger and collapsible content
AccordionListConvenience wrapper that renders multiple Accordions
AvatarCircular image with name-based acronym fallback
BadgeCorner indicator for counts and presence (numeric or custom content)
CardFoundational surface with elevation, outline, and background variants
ChipCompact status label with icon and kind-based coloring
QuoteSemantic blockquote with left border accent
SuggestionContextual note with role="note" and kind-specific background
TabsTabbed interface with WAI-ARIA tabs pattern and overflow
SegmentedControlSegment-style tab switcher for 2–5 options
TileCard with icon, title, description, and action slot
ModalCentered dialog with drag-to-dismiss, focus trap, compound API
DrawerSlide-in panel (bottom on mobile, right on desktop), compound API
BottomSheetMobile bottom sheet with multi-step heights, drag-to-resize
PopoverClick-triggered floating content anchored to a reference element
TooltipHover/focus-triggered floating info anchored to a reference element

Feedback

ComponentDescription
AlertStatus banner with role="alert", icon, and action slot
LoaderSVG spinner with prefers-reduced-motion support
SkeletonLoading placeholder with shimmer animation and typography alignment

Form

The barrel also exports lower-level primitives (TextInput, TextArea, Select, Checkbox, Radio, Switch, Hint, Label) for advanced use — prefer the field components below in product code.

ComponentDescription
TextFieldText input with floating label, hint/error, ARIA wiring
TextAreaFieldMulti-line variant of TextField
SelectFieldNative select with floating label and hint/error
PasswordFieldTextField with visibility toggle
PhoneNumberFieldTextField with phone-specific input defaults (type, inputMode, autoComplete)
PinCodeFieldSegmented OTP input
AutocompleteTextField with floating suggestions dropdown
MultiSelectMulti-select combobox with chips and checkbox listbox
CheckboxButtonCard-style checkbox with label and hint
RadioButtonCard-style radio with label and hint
SliderFieldSingle choice on an ordered scale, drawn as a track with a thumb
SwitchFieldInline switch with label, hint, and labelPosition
FileUploadFieldDrag-and-drop file upload with react-dropzone

Navigation

ComponentDescription
LinkStyled anchor for inline text links
NavigationButtonList-item button for menus and action lists
BottomBarFixed-position mobile bottom navigation bar
BreadcrumbsNavigation breadcrumb trail with chevron separators
NavBarMain navigation with a sliding active indicator
NavBarGroupCapsule of NavBarItems inside NavBar
NavBarItemIcon-and-label item for NavBarGroup, polymorphic via as
SideBarCollapsible sidebar navigation
SideBarItemNavigation item for SideBar (wraps NavigationButton)
SideBarUserUser avatar + name/email display for SideBar bottom slot
TopBarSticky header with logo and back navigation
TopBarBackBack link with chevron icon for TopBar's back slot

Layout

ComponentDescription
DividerHorizontal/vertical separator line

Dependencies

DependencyRole
@serenis/cdkInteractive primitives (Pressable, Expandable)
@serenis/design-tokensColors, spacing, typography, elevation, border radius
@serenis/iconsIcon components for Button, Alert, Accordion, etc.
@serenis/hooksShared React hooks
@serenis/numbers, @serenis/stringsFormatting utilities
styled-componentsCSS-in-JS (uses @sanity/styled-components fork)
@floating-ui/reactPositioning for Popover, Tooltip, Modal, Drawer, BottomSheet, Autocomplete
framer-motionAnimations for Modal, BottomSheet
react-dropzoneFile upload for FileUploadField

Styling conventions

  • CSS Modules: each component owns its styles in a colocated index.module.css; no utility classes in component source. See docs/agents/styling.md.
  • Design tokens for all visual values — never hardcode hex colors, pixel sizes, or font values.

Documentation

  • Storybook: Every component has a Playground.stories.tsx and an Overview.mdx next to its source in libraries/ui/src/{ComponentName}/
  • Overview.mdx: Comprehensive documentation with props, patterns, dos/don'ts, and known exceptions
  • AGENTS.md: Agent-oriented API reference — see AGENTS.md

Consumers

  • Apps: apps/web (primary), apps/blog, apps/nutrition-blog, apps/website, apps/design-system (Storybook host)
  • Libraries: libraries/shared-components (@serenis/shared-components), libraries/ui-deprecated (legacy — prefer @serenis/ui)

Build

Bundled with tsup into ESM + CJS + TypeScript declarations. Workspace dependencies are externalized.

License

PolyForm Noncommercial 1.0.0 — see LICENSE for the full text.

版本与发布记录

@serenis/ui 共发布 48 个版本,首次发布于 2026/07/03;过去 12 个月发布了 48 个版本。

版本发布日期距今
6.94.0latest2026/11/021 天前
6.93.02026/10/304 天前
6.92.02026/10/285 天前
6.91.02026/10/286 天前
6.90.02026/10/277 天前
6.89.02026/10/277 天前

关于 @serenis/ui 的常见问题

@serenis/ui 是什么?

Serenis设计系统的主UI组件库。提供可重用的React组件,包括故事书文档、设计令牌集成和可访问性支持。组件的样式与CSS模块和 @serenis/design-tokens.

如何安装 @serenis/ui?

在项目目录运行 npm install @serenis/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.0.0)、@serenis/cdk(*)、@serenis/hooks(*)、@serenis/icons(*)、@serenis/numbers(*)、@serenis/strings(*)、styled-components(>=6.0.0)、@serenis/design-tokens(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@serenis/ui 支持 TypeScript 吗?

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

@serenis/ui 支持 ESM 还是 CommonJS?

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

@serenis/ui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@serenis/ui 可以商用吗?

@serenis/ui 使用 LicenseRef-PolyForm-Noncommercial-1.0.0 许可。声明的许可为 LicenseRef-PolyForm-Noncommercial-1.0.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@serenis/ui 还在维护吗?

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