Drawer
Drawer (서랍 패널)
화면 가장자리에서 슬라이드되어 들어오는 패널 컴포넌트예요. 주로 네비게이션이나 폼을 표시하는 데 사용해요.
출처: 문서
본문
구조 (Anatomy)
<Drawer.Root>
<Drawer.Trigger />
<Drawer.Backdrop />
<Drawer.Positioner>
<Drawer.Content>
<Drawer.Grabber>
<Drawer.GrabberIndicator />
</Drawer.Grabber>
<Drawer.Title />
<Drawer.Description />
<Drawer.CloseTrigger />
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
예제 (Examples)
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const Basic = () => (
<Drawer.Root>
<Drawer.Trigger className={styles.Trigger}>Open</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Drawer Title</Drawer.Title>
<p>This is the content of the drawer.</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
스와이프 방향 (Swipe Direction)
swipeDirection prop을 사용해 서랍이 어느 가장자리에서 슬라이드되어 들어올지 제어할 수 있어요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const SwipeDirection = () => (
<Drawer.Root swipeDirection="end">
<Drawer.Trigger className={styles.Trigger}>Open Right</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Title className={styles.Title}>Right Drawer</Drawer.Title>
<p>This drawer slides in from the right side.</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
스냅 포인트 (Snap Points)
snapPoints prop을 사용해 서랍이 스냅할 수 있는 중간 위치를 정의할 수 있어요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const SnapPoints = () => (
<Drawer.Root snapPoints={[0.25, 0.5, 1]} defaultSnapPoint={0.5}>
<Drawer.Trigger className={styles.Trigger}>Open</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Drawer with Snap Points</Drawer.Title>
<p>This drawer has multiple snap points at 25%, 50%, and 100% of the viewport height.</p>
<p>Drag the grabber to snap between different heights, or swipe to dismiss.</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
모달 (Modal)
modal을 false로 설정하면 서랍이 열려 있는 동안에도 페이지의 나머지 부분과 상호작용할 수 있게 해줘요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const Modal = () => (
<Drawer.Root modal>
<Drawer.Trigger className={styles.Trigger}>Open</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Modal Drawer</Drawer.Title>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
제어 (Controlled)
open과 onOpenChange prop을 사용해 서랍 상태를 제어할 수 있어요.
import { Drawer, type DrawerOpenChangeDetails } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import { useState } from 'react'
import button from 'styles/button.module.css'
import styles from 'styles/drawer.module.css'
export const Controlled = () => {
const [open, setOpen] = useState(false)
return (
<>
<button className={button.Root} onClick={() => setOpen(!open)}>
{open ? 'Close' : 'Open'} Drawer
</button>
<Drawer.Root open={open} onOpenChange={(details: DrawerOpenChangeDetails) => setOpen(details.open)}>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Controlled Drawer</Drawer.Title>
<p>This drawer is controlled via state.</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
</>
)
}
스크롤 가능 (Scrollable)
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const Scrollable = () => (
<Drawer.Root>
<Drawer.Trigger className={styles.Trigger}>Open</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Scrollable Drawer</Drawer.Title>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
<div className={styles.Scrollable}>
{Array.from({ length: 50 }).map((_, index) => (
<div key={index} className={styles.ScrollableItem}>
Item {index + 1}
</div>
))}
</div>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
드래그 금지 영역 (No Drag Area)
서랍 안의 아무 요소에나 data-no-drag 속성을 적용해 그 요소에서 드래그가 시작되는 것을 방지할 수 있어요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const NoDragArea = () => (
<Drawer.Root>
<Drawer.Trigger className={styles.Trigger}>Open</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Drawer Title</Drawer.Title>
<p data-no-drag>This is the no drag area of the drawer.</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
드래그 불가 (Non Draggable)
draggable을 false로 설정하면 드래그-투-닫기(drag-to-dismiss)를 완전히 비활성화할 수 있어요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer.module.css'
export const NonDraggable = () => (
<Drawer.Root>
<Drawer.Trigger className={styles.Trigger}>Open</Drawer.Trigger>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content} draggable={false}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Drawer Title</Drawer.Title>
<p>This is the content of the drawer.</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
배경 들여쓰기 (Indent Background)
Drawer.IndentBackground를 사용해 서랍 뒤의 페이지에 시각적 들여쓰기 효과를 만들 수 있어요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import styles from 'styles/drawer-indent.module.css'
export const IndentBackground = () => (
<Drawer.Stack>
<div className={styles.Sandbox}>
<Drawer.IndentBackground className={styles.IndentBackground} />
<Drawer.Root modal={false}>
<Drawer.Indent className={styles.Indent}>
<div className={styles.IndentCenter}>
<Drawer.Trigger className={styles.Trigger}>Open Drawer</Drawer.Trigger>
</div>
</Drawer.Indent>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Notifications</Drawer.Title>
<Drawer.Description className={styles.Description}>You are all caught up. Good job!</Drawer.Description>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
</div>
</Drawer.Stack>
)
여러 트리거 (Multiple Triggers)
Drawer.Trigger의 value prop을 사용해 하나의 서랍을 여러 트리거 요소와 공유할 수 있어요. 다른 트리거가 활성화되면 onTriggerValueChange 콜백이 호출돼요.
import { Drawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import { useState } from 'react'
import button from 'styles/button.module.css'
import styles from 'styles/drawer.module.css'
import field from 'styles/field.module.css'
interface User {
id: string
name: string
email: string
}
const users: User[] = [
{ id: '1', name: 'Alice Johnson', email: 'alice@example.com' },
{ id: '2', name: 'Bob Smith', email: 'bob@example.com' },
{ id: '3', name: 'Carol Davis', email: 'carol@example.com' },
]
export const MultipleTriggers = () => {
const [activeUser, setActiveUser] = useState<User | null>(null)
return (
<Drawer.Root
swipeDirection="end"
onTriggerValueChange={(e) => {
setActiveUser(users.find((u) => u.id === e.value) ?? null)
}}
>
<div className={button.Group}>
{users.map((user) => (
<Drawer.Trigger key={user.id} value={user.id} className={button.Root}>
Edit {user.name}
</Drawer.Trigger>
))}
</div>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Edit User</Drawer.Title>
{activeUser && (
<div className="stack">
<div className={field.Root}>
<label className={field.Label}>Name</label>
<input className={field.Input} value={activeUser.name} />
</div>
<div className={field.Root}>
<label className={field.Label}>Email</label>
<input className={field.Input} value={activeUser.email} />
</div>
<div className={button.Group}>
<Drawer.CloseTrigger className={button.Root}>Cancel</Drawer.CloseTrigger>
<Drawer.CloseTrigger className={button.Root} data-variant="solid">
Save Changes
</Drawer.CloseTrigger>
</div>
</div>
)}
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.Root>
)
}
RootProvider 사용 (Using the Root Provider)
useDrawer 훅과 Drawer.RootProvider를 사용해 컴포넌트 트리 외부에서 서랍을 제어할 수 있어요.
import { Drawer, useDrawer } from '@ark-ui/react/drawer'
import { XIcon } from 'lucide-react'
import button from 'styles/button.module.css'
import styles from 'styles/drawer.module.css'
export const RootProvider = () => {
const drawer = useDrawer({
defaultSnapPoint: 0.5,
snapPoints: [0.25, 0.5, 1],
})
return (
<div className="stack">
<div className="hstack">
<button className={button.Root} onClick={() => drawer.setOpen(true)}>
Open via API
</button>
<button className={button.Root} onClick={() => drawer.setSnapPoint(0.25)}>
Set to 25%
</button>
<button className={button.Root} onClick={() => drawer.setSnapPoint(1)}>
Set to 100%
</button>
</div>
<Drawer.RootProvider value={drawer}>
<Drawer.Backdrop className={styles.Backdrop} />
<Drawer.Positioner className={styles.Positioner}>
<Drawer.Content className={styles.Content}>
<Drawer.Grabber className={styles.Grabber}>
<Drawer.GrabberIndicator className={styles.GrabberIndicator} />
</Drawer.Grabber>
<Drawer.Title className={styles.Title}>Drawer with RootProvider</Drawer.Title>
<p>This drawer is controlled via the useDrawer hook and RootProvider.</p>
<p>Active snap point: {drawer.snapPoint}</p>
<Drawer.CloseTrigger className={styles.CloseTrigger}>
<XIcon />
</Drawer.CloseTrigger>
</Drawer.Content>
</Drawer.Positioner>
</Drawer.RootProvider>
</div>
)
}
가이드 (Guides)
스와이프 방향별 스타일링 (Styling by Swipe Direction)
Drawer.Content 요소는 서랍이 슬라이드되어 들어오는 실제 물리적 방향을 반영하는 data-swipe-direction 속성(up | down | left | right)을 노출해요.
이 속성을 대상으로 방향 인식 스타일을 적용할 수 있어요 — 예를 들어, 뷰포트를 바라보는 쪽에만 둥근 모서리를 적용할 수 있어요:
[data-scope='drawer'][data-part='content'] {
/* Top drawer */
&[data-swipe-direction='up'] {
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-left-radius: 16px;
border-bottom-right-radius: 16px;
}
/* Bottom drawer */
&[data-swipe-direction='down'] {
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-top-left-radius: 16px;
border-top-right-radius: 16px;
}
/* Left drawer */
&[data-swipe-direction='left'] {
border-top-left-radius: 0;
border-bottom-right-radius: 16px;
border-top-left-radius: 16px;
border-top-right-radius: 0;
}
/* Right drawer */
&[data-swipe-direction='right'] {
border-top-right-radius: 0;
border-bottom-left-radius: 16px;
border-top-left-radius: 0;
border-top-right-radius: 16px;
}
}
오버드래그 간격 방지 (Preventing Overdrag Gaps)
사용자가 서랍을 열린 위치를 지나서 드래그하면, 서랍 콘텐츠와 뷰포트 가장자리 사이에 작은 간격이 생길 수 있어요. 이를 방지하려면 CSS ::after 의사 요소를 사용해 서랍의 배경을 보이는 경계 밖으로 확장하세요:
[data-scope='drawer'][data-part='content'] {
--bleed: 3rem;
position: relative;
/* Bleed effect */
&::after {
content: '';
position: absolute;
inset-inline: 0;
top: 100%;
height: var(--bleed);
background-color: inherit;
pointer-events: none;
}
}
측면 서랍의 경우 의사 요소를 조정해 가로로 확장하세요:
[data-scope='drawer'][data-part='content'] {
/* Right drawer */
&[data-swipe-direction='right']::after {
inset-inline: auto;
inset-block: 0;
top: 0;
left: 100%;
width: var(--bleed);
height: auto;
}
/* Left drawer */
&[data-swipe-direction='left']::after {
inset-inline: auto;
inset-block: 0;
top: 0;
right: 100%;
width: var(--bleed);
height: auto;
}
}
::after 요소는 서랍의 배경색을 상속받아 콘텐츠 경계 바로 바깥에 위치해요. 오버드래그 중에는 감쇠된 이동이 빈 간격 대신 이 확장 영역을 드러내요.
API 참조 (API Reference)
Props
Root
Props
closeOnEscape
Type: boolean
Required: false
Default Value: true
Description: Escape 키를 눌렀을 때 서랍을 닫을지 여부예요.
closeOnInteractOutside
Type: boolean
Required: false
Default Value: true
Description: 외부가 클릭됐을 때 서랍을 닫을지 여부예요.
closeThreshold
Type: number
Required: false
Default Value: 0.25
Description: 서랍을 닫기 위한 임계 거리예요.
defaultOpen
Type: boolean
Required: false
Default Value: undefined
Description: 서랍의 초기 열림 상태예요.
defaultSnapPoint
Type: SnapPoint
Required: false
Default Value: undefined
Description: undefined
defaultTriggerValue
Type: string
Required: false
Default Value: undefined
Description: 기본 트리거 값이에요(비제어).
finalFocusEl
Type: () => MaybeElement
Required: false
Default Value: undefined
Description: 시트가 닫힐 때 포커스를 받을 요소예요.
hideMode
Type: HideMode
Required: false
Default Value: 'display-none'
Description: 마운트되었지만 표시되지 않을 때 콘텐츠를 숨기는 방법이에요.
'display-none': HTMLhidden속성을 사용해요. 이펙트는 계속 동작해요.'activity': React 19<Activity mode="hidden">을 사용해요. 이펙트가 일시 중지돼요. React 19+가 필요해요.
id
Type: string
Required: false
Default Value: undefined
Description: 머신의 고유 식별자예요.
ids
Type: Partial<{ backdrop: string positioner: string content: string title: string description: string header: string trigger: string | ((value?: string | undefined) => string) grabber: string grabberIndicator: string closeTrigger: string swipeArea: string }>
Required: false
Default Value: undefined
Description: 서랍 안 요소들의 id예요. 컴포지션에 유용해요.
immediate
Type: boolean
Required: false
Default Value: undefined
Description: 현재 변경을 즉시 동기화할지, 아니면 다음 프레임으로 지연할지 여부예요.
initialFocusEl
Type: () => MaybeElement
Required: false
Default Value: undefined
Description: 시트가 열릴 때 포커스를 받을 요소예요.
lazyMount
Type: boolean
Required: false
Default Value: false
Description: 지연 마운트를 활성화할지 여부예요.
modal
Type: boolean
Required: false
Default Value: true
Description: 요소 외부에서의 포인터 상호작용을 방지하고 그 아래의 모든 콘텐츠를 숨길지 여부예요.
onEscapeKeyDown
Type: (event: KeyboardEvent) => void
Required: false
Default Value: undefined
Description: Escape 키를 눌렀을 때 호출되는 함수예요.
onExitComplete
Type: VoidFunction
Required: false
Default Value: undefined
Description: 닫힌 상태에서 애니메이션이 끝날 때 호출되는 함수예요.
onFocusOutside
Type: (event: FocusOutsideEvent) => void
Required: false
Default Value: undefined
Description: 포커스가 컴포넌트 외부로 이동됐을 때 호출되는 함수예요.
onInteractOutside
Type: (event: InteractOutsideEvent) => void
Required: false
Default Value: undefined
Description: 컴포넌트 외부에서 상호작용이 발생했을 때 호출되는 함수예요.
onOpenChange
Type: (details: OpenChangeDetails) => void
Required: false
Default Value: undefined
Description: 열림 상태가 변경될 때 호출되는 함수예요.
onPointerDownOutside
Type: (event: PointerDownOutsideEvent) => void
Required: false
Default Value: undefined
Description: 컴포넌트 외부에서 포인터가 눌렸을 때 호출되는 함수예요.
onRequestDismiss
Type: (event: LayerDismissEvent) => void
Required: false
Default Value: undefined
Description: 부모 레이어가 닫혀서 이 레이어가 닫힐 때 호출되는 함수예요.
onSnapPointChange
Type: (details: SnapPointChangeDetails) => void
Required: false
Default Value: undefined
Description: 스냅 포인트가 변경될 때 호출되는 콜백이에요.
onTriggerValueChange
Type: (details: TriggerValueChangeDetails) => void
Required: false
Default Value: undefined
Description: 활성 트리거 값이 변경될 때 호출되는 콜백이에요.
open
Type: boolean
Required: false
Default Value: undefined
Description: 서랍이 열려 있는지 여부예요.
present
Type: boolean
Required: false
Default Value: undefined
Description: 노드가 존재하는지(사용자가 제어) 여부예요.
preventDragOnScroll
Type: boolean
Required: false
Default Value: true
Description: 스크롤 가능한 요소에서 드래그를 방지할지 여부예요.
활성화하면 사용자가 스크롤 가능한 요소와 상호작용 중일 때 시트가 드래그를 시작하지 않아요.
preventScroll
Type: boolean
Required: false
Default Value: true
Description: 시트가 열렸을 때 그 뒤의 스크롤을 방지할지 여부예요.
restoreFocus
Type: boolean
Required: false
Default Value: true
Description: 시트가 열리기 전에 포커스가 있던 요소로 포커스를 복원할지 여부예요.
role
Type: 'dialog' | 'alertdialog'
Required: false
Default Value: "dialog"
Description: 시트의 역할이에요.
skipAnimationOnMount
Type: boolean
Required: false
Default Value: false
Description: 초기 등장 애니메이션을 허용할지 여부예요.
snapPoint
Type: SnapPoint
Required: false
Default Value: undefined
Description: 현재 활성 스냅 포인트예요.
snapPoints
Type: SnapPoint[]
Required: false
Default Value: [1]
Description: 서랍의 스냅 포인트들이에요.
스냅 포인트를 나타내는 숫자 또는 문자열의 배열이에요.
snapToSequentialPoints
Type: boolean
Required: false
Default Value: false
Description: 스와이프할 때 서랍이 순차 포인트에 스냅해야 하는지 여부예요.
stack
Type: DrawerStack
Required: false
Default Value: undefined
Description: 앱 수준의 서랍 스택 시각 요소(예: 들여쓰기·배경 레이어)를 조정하기 위한 선택적 외부 저장소예요.
swipeDirection
Type: SwipeDirection
Required: false
Default Value: "down"
Description: 서랍을 스와이프할 수 있는 방향이에요.
swipeVelocityThreshold
Type: number
Required: false
Default Value: 700
Description: 서랍을 닫기 위한 임계 속도(픽셀/초)예요.
trapFocus
Type: boolean
Required: false
Default Value: true
Description: 시트가 열렸을 때 내부에 포커스를 가둘지 여부예요.
triggerValue
Type: string
Required: false
Default Value: undefined
Description: 현재 서랍을 제어하는 트리거의 값이에요.
unmountOnExit
Type: boolean
Required: false
Default Value: false
Description: 종료 시 마운트를 해제할지 여부예요.
Backdrop
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
데이터 속성 (Data Attributes)
data-scope: drawer
data-part: backdrop
data-state: "open" | "closed"
data-swiping:
CloseTrigger
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
Content
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
draggable
Type: boolean
Required: false
Default Value: true
Description: 서랍 콘텐츠를 드래그할 수 있는지 여부예요.
false면 그랩바(grabber)로만 서랍을 드래그할 수 있어요.
데이터 속성 (Data Attributes)
data-scope: drawer
data-part: content
data-state: "open" | "closed"
data-expanded: 펼쳐졌을 때 표시돼요.
data-swipe-direction:
data-swiping:
data-dragging: 드래그 상태일 때 표시돼요.
data-nested-drawer-open:
data-nested-drawer-swiping:
Description
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
GrabberIndicator
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
Grabber
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
IndentBackground
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
Indent
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
Positioner
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
데이터 속성 (Data Attributes)
data-scope: drawer
data-part: positioner
data-state: "open" | "closed"
data-swipe-direction:
RootProvider
Props
value
Type: UseDrawerReturn
Required: true
Default Value: undefined
Description: undefined
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
hideMode
Type: HideMode
Required: false
Default Value: 'display-none'
Description: 마운트되었지만 표시되지 않을 때 콘텐츠를 숨기는 방법이에요.
'display-none': HTMLhidden속성을 사용해요. 이펙트는 계속 동작해요.'activity': React 19<Activity mode="hidden">을 사용해요. 이펙트가 일시 중지돼요. React 19+가 필요해요.
immediate
Type: boolean
Required: false
Default Value: undefined
Description: 현재 변경을 즉시 동기화할지, 아니면 다음 프레임으로 지연할지 여부예요.
lazyMount
Type: boolean
Required: false
Default Value: false
Description: 지연 마운트를 활성화할지 여부예요.
onExitComplete
Type: VoidFunction
Required: false
Default Value: undefined
Description: 닫힌 상태에서 애니메이션이 끝날 때 호출되는 함수예요.
present
Type: boolean
Required: false
Default Value: undefined
Description: 노드가 존재하는지(사용자가 제어) 여부예요.
skipAnimationOnMount
Type: boolean
Required: false
Default Value: false
Description: 초기 등장 애니메이션을 허용할지 여부예요.
unmountOnExit
Type: boolean
Required: false
Default Value: false
Description: 종료 시 마운트를 해제할지 여부예요.
SwipeArea
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
데이터 속성 (Data Attributes)
data-scope: drawer
data-part: swipe-area
data-state: "open" | "closed"
data-swiping:
data-swipe-direction:
data-disabled: 비활성화됐을 때 표시돼요.
Title
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
Trigger
Props
asChild
Type: boolean
Required: false
Default Value: undefined
Description: 제공된 자식 요소를 기본 렌더링 요소로 사용하고, 그 props와 동작을 결합해요.
value
Type: string
Required: false
Default Value: undefined
Description: 이 특정 트리거를 식별하는 값이에요.
데이터 속성 (Data Attributes)
data-scope: drawer
data-part: trigger
data-value: 항목의 값이에요.
data-state: "open" | "closed"
data-current: 현재 항목일 때 표시돼요.
Context
API:
| Property | Type | Description |
|---|---|---|
open |
boolean |
서랍이 열려 있는지 여부예요. |
dragging |
boolean |
서랍이 현재 드래그되고 있는지 여부예요. |
triggerValue |
string | null |
활성 트리거의 값이에요. |
setTriggerValue |
(value: string | null) => void |
활성 트리거 값을 설정해요. |
setOpen |
(open: boolean) => void |
메뉴를 열거나 닫는 함수예요. |
snapPoints |
SnapPoint[] |
서랍의 스냅 포인트들이에요. |
swipeDirection |
SwipeDirection |
서랍의 스와이프 방향이에요. |
snapPoint |
SnapPoint | null |
현재 활성 스냅 포인트예요. |
setSnapPoint |
(snapPoint: SnapPoint | null) => void |
활성 스냅 포인트를 설정하는 함수예요. |
getOpenPercentage |
() => number |
서랍의 현재 열림 비율을 가져와요. |
getSnapPointIndex |
() => number |
현재 활성 스냅 포인트의 인덱스를 가져와요. |
getContentSize |
() => number | null |
서랍 콘텐츠의 현재 주축 크기를 가져와요. |
접근성 (Accessibility)
Dialog WAI-ARIA 디자인 패턴을 준수해요.
Enter
Description: 포커스가 트리거에 있을 때 대화상자를 열어요.
Tab
Description: 콘텐츠 안의 다음 포커스 가능 요소로 포커스를 이동해요. 포커스는 대화상자 안에 갇혀 있어요.
Shift + Tab
Description: 이전 포커스 가능 요소로 포커스를 이동해요. 포커스는 대화상자 안에 갇혀 있어요.
Esc
Description: 대화상자를 닫고 포커스를 트리거나 정의된 최종 포커스 요소로 이동해요.