# Side Panel
URL: /react/components/side-panel
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/side-panel.mdx
A panel component that slides in from the left or right edge of the screen. Used to provide additional content or navigation in desktop environments.
사용 가능 버전: @seed-design/react@2.0.0, @seed-design/css@2.0.0
## Preview
```tsx
import { HStack } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelFooter,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelPreview = () => {
return (
Open Side Panel
The panel body can hold content for users to review or an extra input form.
OK
);
};
export default SidePanelPreview;
```
## Installation
### Default
Includes the basic Side Panel component that slides from the left/right edge.
- npm: npx @seed-design/cli@latest add ui:side-panel
- pnpm: pnpm dlx @seed-design/cli@latest add ui:side-panel
- yarn: yarn dlx @seed-design/cli@latest add ui:side-panel
- bun: bun x @seed-design/cli@latest add ui:side-panel
### Responsive
A responsive variant that automatically switches to Bottom Sheet based on viewport. Dependencies include both `ui:bottom-sheet` and `ui:side-panel`.
- npm: npx @seed-design/cli@latest add ui:responsive-side-panel
- pnpm: pnpm dlx @seed-design/cli@latest add ui:responsive-side-panel
- yarn: yarn dlx @seed-design/cli@latest add ui:responsive-side-panel
- bun: bun x @seed-design/cli@latest add ui:responsive-side-panel
## Props
### `SidePanelRoot`
### `SidePanelTrigger`
### `SidePanelContent`
### `SidePanelBody`
### `SidePanelFooter`
### `ResponsiveSidePanelRoot`
## Examples
### Trigger
`` uses the `asChild` pattern to allow child elements to open the Side Panel.
```tsx
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelTriggerExample = () => {
return (
Open
Trigger를 클릭하면 현재 화면 위에 Side Panel이 열립니다.
);
};
export default SidePanelTriggerExample;
```
### Controlled
You can open and close the Side Panel in ways other than the Trigger. In this case, use the `open` prop to control the Side Panel's state.
```tsx
import { HStack } from "@seed-design/react";
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelFooter,
SidePanelRoot,
} from "seed-design/ui/side-panel";
const SidePanelControlled = () => {
const [open, setOpen] = useState(false);
const scheduleOpen = () => {
setTimeout(() => {
setOpen(true);
}, 1000);
};
return (
<>
1초 후 열기
외부 상태로 패널을 열고 닫을 때도 본문과 푸터 구조는 동일하게 유지됩니다.
확인
>
);
};
export default SidePanelControlled;
```
### Direction
You can change the direction the Side Panel opens by setting the `direction` prop on ``.
Supports `"left"` or `"right"`, with the default being `"right"`.
```tsx
import { Flex } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelDirection = () => {
return (
Right
오른쪽 가장자리에서 슬라이드되어 보조 콘텐츠를 표시합니다.
Left
왼쪽 가장자리에서 슬라이드되어 탐색이나 설정 영역을 표시합니다.
);
};
export default SidePanelDirection;
```
### Size
You can change the Side Panel's width by setting the `size` prop on ``.
Supports `"small"` (480px), `"medium"` (720px, default), and `"large"` (960px).
```tsx
import { Flex } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelSize = () => {
return (
Small (480px)
좁은 패널에 적합한 간결한 콘텐츠를 배치합니다.
Medium (720px)
기본 너비로 상세 정보와 주요 액션을 함께 제공합니다.
Large (960px)
넓은 패널에서 더 많은 폼 필드나 상세 콘텐츠를 다룹니다.
);
};
export default SidePanelSize;
```
### Footer Layout
`SidePanelFooter` provides only flex layout, and button arrangement is directly composed with `VStack`, `HStack`, etc.
In narrow panels, you can stack vertically with `VStack`, and in wide panels, align horizontally with `HStack`.
```tsx
import { Box, Flex, HStack, VStack } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelFooter,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelFooterLayout = () => {
return (
Small
확인이 필요한 정보를 간결하게 보여줍니다.
버튼은 패널 너비를 채우며 위에서 아래로 쌓입니다.
확인
취소
Medium
상세 정보와 확인 액션을 함께 제공할 수 있습니다.
버튼은 우측 영역에 가로로 정렬됩니다.
취소
확인
);
};
export default SidePanelFooterLayout;
```
### Custom Size
You can directly control the width by passing `width` and `maxWidth` props to ``.
Use this when you need flexible viewport-based width instead of preset sizes.
```tsx
import { Flex } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelCustomSize = () => {
return (
width 80vw, max 640px
뷰포트 너비에 따라 커지되 최대 640px까지만 확장됩니다.
width 400px
고정 너비가 필요한 작업 패널에 사용할 수 있습니다.
);
};
export default SidePanelCustomSize;
```
### Show Close Button
You can show the close button by passing the `showCloseButton` prop to ``.
The default value is `true`.
```tsx
import { Flex } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelShowCloseButton = () => {
return (
닫기 버튼 있음
기본적으로 닫기 버튼이 표시되어 패널을 바로 닫을 수 있습니다.
닫기 버튼 없음
닫기 버튼을 숨길 때는 본문이나 푸터에 닫을 수 있는 액션을 제공하세요.
);
};
export default SidePanelShowCloseButton;
```
### Dismissible
Setting the `dismissible` prop to `false` prevents closing with the Escape key or outside clicks.
Use this when you intentionally want to prevent the Side Panel from being closed.
```tsx
import { HStack } from "@seed-design/react";
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelFooter,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelDismissible = () => {
const [open, setOpen] = useState(false);
return (
닫기 불가 Side Panel
Escape 키, 외부 클릭으로 닫을 수 없습니다. 프로그래밍 방식으로만 닫을 수 있습니다.
setOpen(false)}>
닫기
);
};
export default SidePanelDismissible;
```
### Non-modal
Setting the `modal` prop to `false` allows interaction with the background. The Backdrop is not displayed, and the focus trap is disabled.
If you need to close it by pressing the Trigger again, control the state directly with the `open` prop.
```tsx
import type { MouseEvent } from "react";
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
SidePanelBody,
SidePanelContent,
SidePanelRoot,
SidePanelTrigger,
} from "seed-design/ui/side-panel";
const SidePanelNonModal = () => {
const [open, setOpen] = useState(false);
return (
{
event.preventDefault();
setOpen((open) => !open);
}}
>
Non-modal Side Panel
배경과 상호작용이 가능합니다. Backdrop이 표시되지 않습니다.
);
};
export default SidePanelNonModal;
```
### Responsive
Using `ResponsiveSidePanel` automatically switches to Side Panel for `md` and above and to Bottom Sheet for `sm` and below. Try reducing the viewport to see the switch in action.
`onOpenChange` passes only the open state, and Root options that apply only to Side Panel or Bottom Sheet are passed via `sidePanelRootProps` and `bottomSheetRootProps`.
```tsx
import { Box, HStack, VStack } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
ResponsiveSidePanelBody,
ResponsiveSidePanelContent,
ResponsiveSidePanelFooter,
ResponsiveSidePanelRoot,
ResponsiveSidePanelTrigger,
} from "seed-design/ui/responsive-side-panel";
const SidePanelResponsive = () => {
return (
Open
본문 영역은 Header/Body/Footer 구조로 동일합니다.
md 이상에서는 화면 우측에서 슬라이드되는 Side Panel로,
sm 이하에서는 화면 하단에서 슬라이드되는 Bottom Sheet로 표시됩니다.
확인
);
};
export default SidePanelResponsive;
```
## Keyboard Interactions
| Key | Behavior |
| ------------- | ---------------------------------------------------------------------- |
| `Escape` | Closes the Side Panel when `dismissible=true`. |
| `Tab` | Cycles focus between elements inside the Side Panel when `modal=true`. |
| `Shift + Tab` | Cycles focus in reverse when `modal=true`. |