这是用户在 2024-7-10 17:27 为 https://www.radix-ui.com/themes/docs/overview/getting-started 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Overview

Getting started 入门

Install Radix Themes and start building in minutes.
安装 Radix 主题并在几分钟内开始构建。

Radix Themes is a pre-styled component library that is designed to work out of the box with minimal configuration. If you are looking for the unstyled components, go to Radix Primitives.
Radix 主题是一个预设样式的组件库,旨在通过最少的配置即可开箱即用。如果您正在寻找未设置样式的组件,请查看 Radix Primitives。

Installation 安装

Getting up and running is quick and easy.
快速上手简单易行。

1. Install Radix Themes 1. 安装 Radix 主题

Install the package from your command line.
从命令行安装软件包。

npm install @radix-ui/themes

2. Import the CSS file 2. 导入 CSS 文件

Import the global CSS file at the root of your application.
在应用程序的根目录导入全局 CSS 文件。

import '@radix-ui/themes/styles.css';

3. Add the Theme component 3. 添加主题组件

Add Theme to your application, wrapping the root component inside of body.
Theme 添加到您的应用程序中,将根组件包裹在 body 内。

import { Theme } from '@radix-ui/themes';
export default function () {
return (
<html>
<body>
<Theme>
<MyApp />
</Theme>
</body>
</html>
);
}

4. Start building 4. 开始构建

You are now ready to use Radix Themes components.
您现在可以使用 Radix Themes 组件了。

import { Flex, Text, Button } from '@radix-ui/themes';
export default function MyApp() {
return (
<Flex direction="column" gap="2">
<Text>Hello from Radix Themes :)</Text>
<Button>Let's go</Button>
</Flex>
);
}

Customizing your theme 自定义您的主题

Configuration is managed and applied via the Theme component.
配置通过主题组件进行管理和应用。

Basic configuration 基本配置

Pass configuration to the Theme to customize appearance.
将配置传递给 Theme 以自定义外观。

<Theme accentColor="crimson" grayColor="sand" radius="large" scaling="95%">
<MyApp />
</Theme>

Using the theme panel 使用主题面板

ThemePanel is a drop-in component that allows you to preview the theme in real time. Visit the component playground to see it in action.
ThemePanel 是一个即插即用的组件,允许您实时预览主题。访问组件游乐场以查看其运行情况。

To add ThemePanel to your app, import it from the package and drop it inside your root Theme.
要将 ThemePanel 添加到您的应用程序中,请从包中导入它,并将其放入您的根 Theme 中。

import { Theme, ThemePanel } from '@radix-ui/themes';
export default function () {
return (
<Theme>
<MyApp />
<ThemePanel />
</Theme>
);
}

Take it further 进一步深入

Get the most out of Radix Themes by exploring more concepts and features.
探索更多概念和功能,充分利用 Radix Themes。

NextStyling 下一代造型