Utilities

方向提供程序

¥Direction Provider

封装你的应用以提供全局阅读指导。

Features

    Enables all primitives to inherit global reading direction.

安装

¥Installation

从命令行安装组件。

¥Install the component from your command line.

npm install @radix-ui/react-direction

结构

¥Anatomy

导入组件。

¥Import the component.

import { Direction } from "radix-ui";
export default () => <Direction.Provider />;

API 参考

¥API Reference

提供者

¥Provider

在创建需要从右到左 (RTL) 阅读方向的本地化应用时,你需要使用 Direction.Provider 组件封装你的应用,以确保所有基元都根据 dir 属性调整其行为。

¥When creating localized apps that require right-to-left (RTL) reading direction, you need to wrap your application with the Direction.Provider component to ensure all of the primitives adjust their behavior based on the dir prop.

PropTypeDefault
dir
enum
No default value

示例

¥Example

使用方向提供程序。

¥Use the direction provider.

import { Direction } from "radix-ui";
export default () => (
<Direction.Provider dir="rtl">{/* your app */}</Direction.Provider>
);