# Bottom Sheet
URL: /react/components/bottom-sheet
Source: https://github.com/daangn/seed-design/blob/dev/docs/content/react/components/bottom-sheet.mdx
A modal component that slides up from the bottom of the screen. It is used when providing additional information or action lists while maintaining the current context.
사용 가능 버전: @seed-design/react@0.0.1, @seed-design/css@0.0.1
## Preview
```tsx
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetPreview = () => {
return (
Open
{/* If you need to omit padding, pass px={0}. */}
Content
OK
);
};
export default BottomSheetPreview;
```
Learn how to use Stackflow and Bottom Sheet together.
## Installation
- npm: npx @seed-design/cli@latest add ui:bottom-sheet
- pnpm: pnpm dlx @seed-design/cli@latest add ui:bottom-sheet
- yarn: yarn dlx @seed-design/cli@latest add ui:bottom-sheet
- bun: bun x @seed-design/cli@latest add ui:bottom-sheet
## Props
### `BottomSheetRoot`
### `BottomSheetTrigger`
### `BottomSheetContent`
### `BottomSheetBody`
### `BottomSheetFooter`
## Examples
### Trigger
`` uses the `asChild` pattern to allow child elements to open the BottomSheet.
`` sets the `aria-haspopup="dialog"` attribute and automatically sets the `aria-expanded` attribute based on the `open` state of the BottomSheet. This attribute is useful for assistive technologies like screen readers.
```tsx
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetTriggerExample = () => {
return (
Open
Content
확인
);
};
export default BottomSheetTriggerExample;
```
### Controlled
You can open and close the BottomSheet in ways other than using the trigger. In this case, use the `open` prop to control the state of the BottomSheet.
```tsx
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
} from "seed-design/ui/bottom-sheet";
const BottomSheetControlled = () => {
const [open, setOpen] = useState(false);
const scheduleOpen = () => {
setTimeout(() => {
setOpen(true);
}, 1000);
};
return (
<>
1초 후 열기
{/* If you need to omit padding, pass px={0}. */}
Content
확인
>
);
};
export default BottomSheetControlled;
```
### `onOpenChange` Details
The second argument of `onOpenChange` provides `details`.
#### `reason`
**When opening** (`open: true`)
- `"trigger"`: Opened with `BottomSheetTrigger` (`BottomSheet.Trigger`)
**When closing** (`open: false`)
- `"closeButton"`: Closed with `BottomSheet.CloseButton`
- `"escapeKeyDown"`: Using the ESC key
- `"interactOutside"`: Clicking outside the area
- `"drag"`: Closed by dragging
- `"handleClickOnLastSnapPoint"`: Closed by clicking the handle at the last snap point
```tsx
import { HStack, Text, VStack } from "@seed-design/react";
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const snapPoints = ["200px", "400px", 1];
export default function BottomSheetOnOpenChangeReason() {
const [open, setOpen] = useState(false);
const [snap, setSnap] = useState(snapPoints[0]);
const [openReason, setOpenReason] = useState(null);
const [closeReason, setCloseReason] = useState(null);
return (
{
setOpen(open);
(open ? setOpenReason : setCloseReason)(details?.reason ?? null);
}}
snapPoints={snapPoints}
activeSnapPoint={snap}
setActiveSnapPoint={setSnap}
>
열기
ESC 키를 누르거나, 외부 영역을 클릭하거나, 아래로 스와이프하거나, 핸들을 탭하여 snap
point를 순환해보세요.
마지막 열림 이유: {openReason ?? "-"}
마지막 닫힘 이유: {closeReason ?? "-"}
);
}
```
### Header Align
Set the `headerAlign` prop on `` to control the alignment of the title and description.
```tsx
import { HStack } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetHeaderAlign = () => {
return (
Left (기본값)
Content
확인
Center
Content
확인
);
};
export default BottomSheetHeaderAlign;
```
### Max Height
Pass the `maxHeight` prop to `` to set the maximum height of the BottomSheet.
```tsx
import { Box, VStack } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetMaxHeight = () => {
return (
Open
{/* If you need to omit padding, pass px={0}. */}
확인
);
};
export default BottomSheetMaxHeight;
```
### Snap Points
Use the `snapPoints` prop to set custom snap points for the BottomSheet.
```tsx
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const snapPoints = ["300px", "500px", 1];
const BottomSheetSnapPoints = () => {
const [snap, setSnap] = useState(snapPoints[0]);
return (
Open
Content
확인
);
};
export default BottomSheetSnapPoints;
```
### Fade From Index
Pass the `fadeFromIndex` prop to `` to set the starting index where the background darkens.
```tsx
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const snapPoints = ["300px", "500px", 1];
const BottomSheetFadeFromIndex = () => {
const [snap, setSnap] = useState(snapPoints[0]);
return (
Open
Content
확인
);
};
export default BottomSheetFadeFromIndex;
```
### Show Handle
Pass the `showHandle` prop to `` to display the handle.
The default value is `false`.
```tsx
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetShowHandle = () => {
const [isSheetOpen, setIsSheetOpen] = useState(false);
return (
Open
{/* If you need to omit padding, pass px={0}. */}
Content
setIsSheetOpen(false)}>
닫기
);
};
export default BottomSheetShowHandle;
```
### Show Close Button
Pass the `showCloseButton` prop to `` to display the close button.
The default value is `true`.
When `showCloseButton` is set to `false`, the close button is not displayed.
In this case, you must provide a way for users to close the BottomSheet.
```tsx
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetShowCloseButton = () => {
const [isSheetOpen, setIsSheetOpen] = useState(false);
return (
Open
{/* If you need to omit padding, pass px={0}. */}
Content
setIsSheetOpen(false)}>
닫기
);
};
export default BottomSheetShowCloseButton;
```
### Dismissible
When the `dismissible` prop is set to `false`, the closeOnEscape, closeOnInteractOutside, and draggable features are disabled.
Use this when you intentionally want to prevent the BottomSheet from being closed. Otherwise, you must provide a way for users to close the BottomSheet.
```tsx
import { useState } from "react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetDismissible = () => {
const [open, setOpen] = useState(false);
return (
Open
{/* If you need to omit padding, pass px={0}. */}
Content
setOpen(false)}>
닫기
);
};
export default BottomSheetDismissible;
```
### With Scroll Fog
You can apply a scroll hint effect using [Scroll Fog](/react/components/scroll-fog) in ``.
ScrollFog always displays the effect, so sufficient padding must be provided.
The recommended padding is `80px` at the bottom and `20px` at the top.
```tsx
import { Box, ScrollFog, VStack } from "@seed-design/react";
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetMaxHeight = () => {
return (
Open
{/* If you need to omit padding, pass px={0}. */}
확인
);
};
export default BottomSheetMaxHeight;
```
### Handle Only
When the `handleOnly` prop is provided to ``, the area where the Bottom Sheet can be moved by swiping is limited to the handle.
This option only works when used with ``.
```tsx
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetHandleOnly = () => {
return (
Open
Content
확인
);
};
export default BottomSheetHandleOnly;
```
### Skip Animation
Use the `skipAnimation` prop to skip the enter/exit animation of the BottomSheet.
```tsx
import { ActionButton } from "seed-design/ui/action-button";
import {
BottomSheetBody,
BottomSheetContent,
BottomSheetFooter,
BottomSheetRoot,
BottomSheetTrigger,
} from "seed-design/ui/bottom-sheet";
const BottomSheetSkipAnimation = () => {
return (
Open
Content
확인
);
};
export default BottomSheetSkipAnimation;
```