🌐 Nodejs.cn

可调整大小

具有键盘支持的可访问可调整大小的面板组和布局。

One
Two
Three
import {
  ResizableHandle,
  ResizablePanel,

关于

🌐 About

Resizable 组件是由 bvaughn 基于 react-resizable-panels 构建的。

🌐 The Resizable component is built on top of react-resizable-panels by bvaughn.

安装

🌐 Installation

pnpm dlx shadcn@latest add resizable

用法

🌐 Usage

import {
  ResizableHandle,
  ResizablePanel,
  ResizablePanelGroup,
} from "@/components/ui/resizable"
<ResizablePanelGroup orientation="horizontal">
  <ResizablePanel>One</ResizablePanel>
  <ResizableHandle />
  <ResizablePanel>Two</ResizablePanel>
</ResizablePanelGroup>

示例

🌐 Examples

垂直

🌐 Vertical

使用 orientation="vertical" 进行垂直调整大小。

🌐 Use orientation="vertical" for vertical resizing.

Header
Content
import {
  ResizableHandle,
  ResizablePanel,

处理

🌐 Handle

ResizableHandle 上使用 withHandle 属性以显示可见的句柄。

🌐 Use the withHandle prop on ResizableHandle to show a visible handle.

Sidebar
Content
import {
  ResizableHandle,
  ResizablePanel,

从右到左

🌐 RTL

要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南

🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.

واحد
اثنان
ثلاثة
"use client"

import * as React from "react"

API参考

🌐 API Reference

请参阅 react-resizable-panels 文档。

🌐 See the react-resizable-panels documentation.

更新日志

🌐 Changelog

2025-02-02 react-resizable-panels v4

已更新至 react-resizable-panels v4。详细信息请参见 v4.0.0 发行说明

🌐 Updated to react-resizable-panels v4. See the v4.0.0 release notes for full details.

如果你直接使用 react-resizable-panels 原语,请注意以下变化:

🌐 If you're using react-resizable-panels primitives directly, note the following changes:

v3v4
PanelGroupGroup
PanelResizeHandleSeparator
direction 属性orientation 属性
defaultSize={50}defaultSize="50%"
onLayoutonLayoutChange
ImperativePanelHandlePanelImperativeHandle
面板上的 ref 属性panelRef 属性
data-panel-group-directionaria-orientation