@ultraviolet/ui

中文文档
3.29.3发布于 2026/11/03Apache-2.0TypeScriptESM + CJS构建来源已验证

Ultraviolet UI

原始使用文档
文档目录7 节
  1. Get Started
  2. Usage
  3. Migration from V2 to V3
  4. Theme provider
  5. Style
  6. Documentation
  7. Contributing

Ultraviolet UI

npm version

Ultraviolet UI is a set of React components and utilities to build fast application.

Get Started

$ pnpm add @ultraviolet/ui @ultraviolet/themes

You will also need to import fonts in your project by adding:

<link href="https://fonts.cdnfonts.com/css/inter?styles=29139,29137,29140" rel="stylesheet" />
<link href="https://fonts.cdnfonts.com/css/jetbrains-mono-2?styles=156604" rel="stylesheet" />
<link href="https://fonts.cdnfonts.com/css/space-grotesk?styles=24816,24815,24817" rel="stylesheet" />

Or if you prefer to install the package for it you can add:

$ pnpm add @ultraviolet/fonts

and import it in your project:

import '@ultraviolet/fonts'

Usage

For the library to work properly, you need to wrap your application with the ThemeProvider component from @ultraviolet/themes. To have access to the theme object, simply import the object directly from the @ultraviolet/themes library:

import { theme } from '@ultraviolet/themes'

You will also need to import styles of components for them to have the correct styles.

import { ThemeProvider, theme } from '@ultraviolet/themes'
import { Button } from '@ultraviolet/ui'
import '@ultraviolet/ui/styles' // <- components style

const App = () => (
  <ThemeProvider theme={theme}>
    <Button onClick={() => console.log('clicked')}>Click Me</Button>
  </ThemeProvider>
)

Note: To generate your own theme easily you can check the theme generator.

Migration from V2 to V3

With the migration from @ultraviolet/ui 2.0.0 to @ultraviolet/ui 3.0.0, several core changes have been introduced. These changes are due to the shift in styling from Emotion to vanilla-extract.

Theme provider

To ensure the library works correctly, you must wrap your application with the ThemeProvider component. Import it from @ultraviolet/themes or @ultraviolet/ui (replacing the previous Emotion-based provider).

If your app still uses Emotion, you can combine both theme providers:

import { ThemeProvider as EmotionThemeProvider } from '@emotion/react'
import { consoleLightTheme, ThemeProvider as UVThemeProvider } from '@ultraviolet/themes'

const App = () => (
  <UVThemeProvider theme={consoleLightTheme}>
    <EmotionThemeProvider theme={consoleLightTheme}>{children}</EmotionThemeProvider>
  </UVThemeProvider>
)

Style

To ensure styles are applied, import the component styles at the root of your application:

import '@ultraviolet/ui/styles'

To replace normalize() (which was used with Emotion), you can now import a global style with the same effect:

Before:

import { Global } from '@emotion/react'
import { normalize } from '@ultraviolet/ui'
import { ThemeProvider } from '@emotion/react'

const App = () => (
  <ThemeProvider theme={theme}>
      <Global styles={css`${normalize()}`}>
      <MyApp />
  </ThemeProvider>
)

After:

import { ThemeProvider } from '@ultraviolet/themes'
import '@ultraviolet/themes/global'

const App = () => (
  <ThemeProvider theme={theme}>
    <MyApp />
  </ThemeProvider>
)

Documentation

Checkout our documentation website.

Contributing

📝 You can participate in the development and start contributing to it.

版本与发布记录

@ultraviolet/ui 共发布 361 个版本,首次发布于 2023/06/20;过去 12 个月发布了 66 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.29.3latest2026/11/03今天
3.29.22026/10/304 天前
3.29.12026/10/295 天前
3.29.02026/10/286 天前
3.28.02026/10/2113 天前
3.27.02026/10/1617 天前

其他发布通道:beta → 3.0.0-beta.29。

关于 @ultraviolet/ui 的常见问题

@ultraviolet/ui 是什么?

紫外线UI

如何安装 @ultraviolet/ui?

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

@ultraviolet/ui 支持 TypeScript 吗?

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

@ultraviolet/ui 支持 ESM 还是 CommonJS?

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

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

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

@ultraviolet/ui 可以商用吗?

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

@ultraviolet/ui 还在维护吗?

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