@apify/ui-library

中文文档
1.176.1发布于 2026/11/09Apache-2.0TypeScriptES Module近 30 天下载 9004

React UI library used by apify.com

原始使用文档
文档目录6 节
  1. Install
  2. Quick start
  3. What's inside
  4. Using color tokens outside of styled-components
  5. Storybook
  6. Contributing

@apify/ui-library

Browse components at the hosted Storybook.

Apify's React design-system library — primitives, theme tokens, and styled components shared across Apify Console and the marketing web.

Install

pnpm add @apify/ui-library

Peer dependencies (install in your project if not already there):

  • react 17.x · 18.x · 19.x
  • react-dom 17.x · 18.x · 19.x
  • styled-components ^6.1.19

Quick start

import { Box, Button, Text } from '@apify/ui-library';

export const SaveBar = ({ onSave }: { onSave: () => void }) => (
    <Box pt="space8" pb="space8">
        <Text size="regular">You have unsaved changes.</Text>
        <Button variant="primary" color="default" mt="space4" onClick={onSave}>
            Save
        </Button>
    </Box>
);

<Box> exposes spacing tokens as utility props (pt, mb, mx, p, …); <Text> and <Heading> apply typography tokens via size. All values come from the shared theme — never hardcode colors, spacing, or radii.

What's inside

  • Layout — Box (utility-prop wrapper around any element)
  • Typography — Text, Heading, plus content / shared / marketing variants
  • Forms — Button, IconButton, Checkbox, RadioButton, Switch, Select
  • Data — Table + primitives (TableHead, TableRow, TableCell, …), Badge, Chip, Tag
  • Feedback — Banner, Message, Spinner
  • Navigation — Tabs, Breadcrumb, Pagination, Link
  • Overlay — Floating (menus, tooltips), CollapsibleCard
  • Theme tokens — theme.color.*, theme.space.*, theme.text.*, theme.radius.*, theme.shadow.*, theme.transition.*

Using color tokens outside of styled-components

For external projects that don't use styled-components — such as Tailwind-based apps or plain CSS — the package ships pre-built CSS files that register all color tokens as CSS custom properties on :root:

  • @apify/ui-library/style/colors/tokens.light.css
  • @apify/ui-library/style/colors/tokens.dark.css

Import the file that matches your theme in your global stylesheet:

@import '@apify/ui-library/style/colors/tokens.light.css';

You can then reference any token via CSS custom properties:

.my-element {
    color: var(--color-neutral-text);
    background: var(--color-neutral-background);
    border-color: var(--color-neutral-border);
}

For Tailwind, map the variables in tailwind.config.js:

/** @type {import('tailwindcss').Config} */
export default {
    theme: {
        extend: {
            colors: {
                'neutral-text': 'var(--color-neutral-text)',
                'neutral-bg': 'var(--color-neutral-background)',
                'neutral-border': 'var(--color-neutral-border)',
            },
        },
    },
};

Storybook

From the repository root:

pnpm run storybook

This starts both Storybooks in parallel — Console-specific stories on http://localhost:6006 and shared design-system stories (this library) on http://localhost:6007.

Contributing

See CONTRIBUTING.md for the component lifecycle, design-token sync (Figma colors and Supernova typography), Storybook conventions, publishing, and the review checklist. New components are easiest to scaffold with the /create-ui-component Claude Code skill.

版本与发布记录

@apify/ui-library 共发布 594 个版本,首次发布于 2025/02/12;过去 12 个月发布了 407 个版本。

版本发布日期距今
1.176.1latest2026/11/09今天
1.176.02026/11/072 天前
1.175.1-featvendordeveloperbadge-bc47f6.102026/11/063 天前
1.175.02026/11/063 天前
1.174.02026/11/054 天前
1.173.1-uilibraryversion2candida-85b55e.632026/11/054 天前

其他发布通道:featurepublishuilibrary-0a4729 → 0.56.3-featurepublishuilibrary-0a4729.38420,feataddaiagentcategories-114da5 → 0.61.1-feataddaiagentcategories-114da5.98,featcodeblockwithtabs-5a4360 → 0.64.1-featcodeblockwithtabs-5a4360.34,featunifyUserStats-5c4819 → 0.65.3-featunifyUserStats-5c4819.43,featuresyntaxhighlighter-48cb44 → 0.66.1-featuresyntaxhighlighter-48cb44.24,fixactorreadmeinlinecodeover-4ecb5d → 0.67.3-fixactorreadmeinlinecodeover-4ecb5d.23。

关于 @apify/ui-library 的常见问题

@apify/ui-library 是什么?

React UI library used by apify.com

如何安装 @apify/ui-library?

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

@apify/ui-library 支持 TypeScript 吗?

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

@apify/ui-library 支持 ESM 还是 CommonJS?

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

@apify/ui-library 可以商用吗?

@apify/ui-library 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@apify/ui-library 的下载量有多少?

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

@apify/ui-library 还在维护吗?

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