Usage
import { useState } from 'react';import { Sheet } from 'react-modal-sheet';
function Example() { const [isOpen, setOpen] = useState(false);
return ( <> <button onClick={() => setOpen(true)}>Open sheet</button>
<Sheet isOpen={isOpen} onClose={() => setOpen(false)}> <Sheet.Container> <Sheet.Header /> <Sheet.Content>{/* Your sheet content goes here */}</Sheet.Content> </Sheet.Container> <Sheet.Backdrop /> </Sheet> </> );}The Sheet component follows the Compound Component pattern in order to provide a flexible yet powerful API for creating highly customizable bottom sheet components.
Since the final bottom sheet is composed from smaller building blocks (Container, Content, Header, and Backdrop) you are in total control over the rendering output. So for example, if you donโt want to have any backdrop in your sheet then you can just skip rendering it instead of passing some prop like renderBackdrop={false} to the main sheet component. Cool huh? ๐
Also, by constructing the sheet from smaller pieces makes it easier to apply any necessary accessibility related properties to the right components without requiring the main sheet component to be aware of them. You can read more about accessibility in the accessibility guide.
