@sckyzo/cosmos-react

中文文档
0.6.0发布于 2026/11/02MITTypeScriptESM + CJS构建来源已验证

React 19 + Tailwind 4 UI component library — 135+ themeable, accessible components (forms, overlays, navigation, tables, data display) with built-in light/dark mode.

原始使用文档
文档目录5 节
  1. Install
  2. Set up the styles
  3. Use
  4. Documentation
  5. License

@sckyzo/cosmos-react

npm

React 19 component library for the Cosmos design system: themeable, accessible components, built with Tailwind 4 and shipped as ESM, CJS and types.

Browse the full catalog in the live Storybook.

Install

npm install @sckyzo/cosmos-react @sckyzo/cosmos-theme
npm install react react-dom   # peers, react 19+

@sckyzo/cosmos-theme carries the CSS (tokens, fonts, theme and accent vars). The components render unstyled without it. The three Cosmos packages share one version number: install the same version of each.

Set up the styles

Components are styled with Tailwind 4 utility classes, so your app's Tailwind build has to generate them. Tailwind does not scan node_modules, so you must point @source at the installed package: without it no Cosmos class is generated and every component renders unstyled.

In your main CSS file:

@import 'tailwindcss';

/* Required. The path is relative to this CSS file; adjust the depth to your layout. */
@source '../node_modules/@sckyzo/cosmos-react/dist/**/*.{js,cjs}';

@import '@sckyzo/cosmos-theme/tailwind';
@import '@sckyzo/cosmos-theme/vars';

/* Optional: the Outfit + JetBrains Mono webfonts. */
@import '@sckyzo/cosmos-theme/fonts';

/* Only if you use Calendar, DatePicker or a component built on them. */
@import '@sckyzo/cosmos-react/calendar.css';

Use

import { useState } from 'react';
import { Button, Modal } from '@sckyzo/cosmos-react';

function Example() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Open</Button>
      <Modal open={open} onClose={() => setOpen(false)}>
        <Modal.Header title="Hello from Cosmos" onClose={() => setOpen(false)} />
        <Modal.Body>A themed, focus-trapped dialog.</Modal.Body>
      </Modal>
    </>
  );
}

Documentation

License

MIT, see LICENSE.

版本与发布记录

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

版本发布日期距今
0.6.0latest2026/11/021 天前
0.5.02026/11/012 天前
0.4.12026/11/012 天前
0.4.02026/10/313 天前
0.3.02026/10/277 天前
0.2.02026/10/2212 天前

关于 @sckyzo/cosmos-react 的常见问题

@sckyzo/cosmos-react 是什么?

React 19 +顺风4 UI组件库- 135+主题,可访问的组件(表单,覆盖,导航,表格,数据显示)与内置的明暗模式。

如何安装 @sckyzo/cosmos-react?

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

@sckyzo/cosmos-react 支持 TypeScript 吗?

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

@sckyzo/cosmos-react 支持 ESM 还是 CommonJS?

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

@sckyzo/cosmos-react 可以商用吗?

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

@sckyzo/cosmos-react 还在维护吗?

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