# Bottom Sheet URL: /lynx/components/bottom-sheet Source: https://github.com/daangn/seed-design/blob/dev/docs/content/lynx/components/bottom-sheet.mdx A sheet component that slides up from the bottom of the screen, providing drag, snap, and dismiss interactions. Lynx Engine 최소 버전: 3.6 사용 XElement: 사용 가능 버전: @seed-design/lynx-react@0.1.0, @seed-design/lynx-css@0.1.0 ## Preview ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Open Content 확인 ); } ``` ## Installation - npm: npx @seed-design/cli add ui:bottom-sheet - pnpm: pnpm dlx @seed-design/cli add ui:bottom-sheet - yarn: yarn dlx @seed-design/cli add ui:bottom-sheet - bun: bun x @seed-design/cli add ui:bottom-sheet `@seed-design/lynx-react`'s `BottomSheet` wraps [`@lynx-js/lynx-ui-sheet`](https://github.com/lynx-family/lynx-ui/tree/main/packages/lynx-ui-sheet). Drag, spring, snap, and presence behaviors are handled by lynx-ui-sheet. Crispy provides public APIs and recipe slot styles. ## Usage ```tsx import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; export function App() { return ( Open sheet Body content Bottom action area ); } ``` The Registry `BottomSheetContent` internally assembles Positioner, Backdrop, and Header. `BottomSheetTrigger` must be placed outside Content to open the sheet by tapping. In the low-level package API, specifying `container` to `BottomSheet.Positioner` uses the `` XElement. The Registry default uses ``. If you need `container`, verify that your app's Lynx Engine supports ``. ### Imperative Control Pass `ref` to `BottomSheetRoot` to call the `open`, `close`, `snapTo`, `expand`, and `collapse` methods. ```tsx import { useRef } from "@lynx-js/react"; import { BottomSheetRoot, type BottomSheetRootRef } from "@/components/ui/bottom-sheet"; export function App() { const ref = useRef(null); return ( {/* ... */} ); } ``` ## Props ### `BottomSheetRoot` ### `BottomSheetTrigger` ### `BottomSheetContent` ### `BottomSheetBody` ### `BottomSheetFooter` ## Examples ### Trigger Tapping `` opens the Bottom Sheet. Lynx does not support `asChild`. Trigger renders a `` that wraps child elements. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Open Content 확인 ); } ``` ### Controlled To open and close the Bottom Sheet in ways other than using Trigger, control the state with `open` and `onOpenChange`. The example below opens the Bottom Sheet 1 second after tapping a button. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, } from "@/components/ui/bottom-sheet"; import { useState } from "@lynx-js/react"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [open, setOpen] = useState(false); function scheduleOpen() { "background only"; setTimeout(() => { setOpen(true); }, 1000); } return ( 1초 후 열기 Content 확인 ); } ``` ### `onOpenChange` Details Lynx's `onOpenChange` only passes the changed `open` value. The React version's `details.reason` is not supported. If you need the reason for opening or closing, record the reason in separate state from event handlers on buttons owned by your app and Trigger. Background tap and drag cannot be distinguished by callback value alone. ### Header Align Use `headerAlign` on `` to align the title and description to the left or center. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, HStack, useSeedClassName } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Left (기본값) Content 확인 Center Content 확인 ); } ``` ### Max Height `BottomSheetBody` renders a native ``. To create a scrollable area with a maximum of 300px, place `` inside Body and specify `height`, `maxHeight`, and `flex: "none"` together. If you only specify `maxHeight` on Lynx's `scroll-view`, the area may shrink to 0px because content size cannot be calculated as height. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Open 확인 ); } ``` ### Snap Points In `snapPoints`, you can use pixel numbers, percentages based on screen height, or `"fit"` to match content size. The array order becomes the snap index, and `initialSnap` specifies the height when first opened. In `onSnapChange`, you can receive the current index and pixel-calculated height. Use ref's `snapTo` method to move to your desired height. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, type BottomSheetRootRef, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { useRef, useState } from "@lynx-js/react"; import { ActionButton, HStack, useSeedClassName, VStack } from "@seed-design/lynx-react"; const snapPoints = ["45%", "80%"]; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const sheetRef = useRef(null); const [snapIndex, setSnapIndex] = useState(0); function handleSnapToFirst() { "background only"; sheetRef.current?.snapTo(0); } function handleSnapToSecond() { "background only"; sheetRef.current?.snapTo(1); } function handleClose() { "background only"; sheetRef.current?.close(); } return ( snap index: {JSON.stringify(snapIndex)} setSnapIndex(index)} > Snap Points 열기 현재 snap index: {JSON.stringify(snapIndex)} 45% 80% 닫기 ); } ``` Verify the final behavior of drag and snap animations in Lynx Explorer from the QR code tab. Device and gesture handling results may differ in the document preview. ### Fade From Index Lynx does not support `fadeFromIndex`. Use the default Backdrop provided by Registry. If dim changes per snap index are absolutely necessary, assemble Backdrop directly with the low-level package API and control opacity based on `onSnapChange` state. ### Show Handle Pass `showHandle` to `` to display the Handle. The default is `false`. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { useState } from "@lynx-js/react"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); const [open, setOpen] = useState(false); function handleClose() { "background only"; setOpen(false); } return ( Open Content 닫기 ); } ``` ### Show Close Button Lynx's `BottomSheetContent` does not support `showCloseButton` and CloseButton. If a close button is needed, use controlled state and change `open` to `false` from a button in `BottomSheetFooter`. ### Dismissible Lynx does not have a `dismissible` prop to control background tap, drag, and ESC close at once. Drag can be prevented with `enableDragToClose={false}` on `BottomSheetRoot`. If you also need to prevent background tap, assemble with the low-level package API and pass `clickToClose={false}` to `BottomSheet.Backdrop`. Lynx does not have ESC key close behavior like the web. If you've prevented close behavior, provide an explicit close button in Footer or elsewhere. ### With Scroll Fog `BottomSheetBody` is a native `` that does not determine scroll method. If scroll hints are needed, place `ScrollFog` directly inside Body. In this structure, you can control `size`, `placement`, `hideScrollBar`, and native scroll-view props directly where they're used. Native `fading-edge-length` displays fog only at edges where scrollable content remains. Initially at the bottom, it displays at the top when scrolled to the end. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, ScrollFog, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Open 확인 ); } ``` ### Handle Only Pass `handleOnly` to `` to restrict the vertical gesture area that moves the Bottom Sheet to the Handle. Use this option together with ``. For long body text, this combination is recommended to prevent overlap between scroll areas inside Body and sheet drag. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Open Content 확인 ); } ``` ### Skip Animation Pass `skipAnimation` to skip the enter, exit, and snap animations of the Bottom Sheet. ```tsx import "./styles"; import { BottomSheetBody, BottomSheetContent, BottomSheetFooter, BottomSheetRoot, BottomSheetTrigger, } from "@/components/ui/bottom-sheet"; import { ActionButton, useSeedClassName, VStack } from "@seed-design/lynx-react"; export default function Example() { const seedClassName = useSeedClassName({ colorMode: "system" }); return ( Open Content 확인 ); } ``` ## Web Version Differences | Item | Web | Lynx | | ------------------- | ------------------------------------- | -------------------------------------------------------------------------------------------- | | User Event | `onClick` | `bindtap` | | Rendering Elements | HTML elements | Native ``, ``, `` | | State Prop | `open`, `defaultOpen`, `onOpenChange` | Same. Internally connected via lynx-ui-sheet's state API | | Mount Control | `lazyMount`, `unmountOnExit` | Not supported in Registry. Controlled via `forceMount` in low-level `BottomSheet.Positioner` | | Trigger Composition | `asChild` supported | Not supported. Renders `` | | Imperative ref API | None | `open`, `close`, `snapTo`, `expand`, `collapse` |