react-spring-bottom-sheet is a React component library designed for creating accessible, animated bottom sheets (also known as bottom drawers or modals) for web applications. It is built upon the `react-spring` library for physics-based animations and `react-use-gesture` for robust gesture control, delivering a smooth and interactive user experience. The current stable version is 3.4.1, which includes support for React 18. Key features include content drag expansion, customizable snap points, and an opt-out focus trap for accessibility. The library differentiates itself by its focus on combining delightful animations with strong accessibility standards through its underlying animation libraries and CSS custom properties for styling. While not adhering to a strict time-based release schedule, the project is actively maintained with updates addressing bug fixes, dependency compatibility, and new features as needed.
npm install react-spring-bottom-sheetVerified import paths — ran on the pinned version, not inferred.
Demonstrates a controlled bottom sheet with open/close functionality, programmatic snap-to, multiple snap points, and custom header/footer. It includes the necessary CSS import.
Always pass an `onDismiss` prop that sets the `open` state to `false`, e.g., `<BottomSheet open={open} onDismiss={() => setOpen(false)} />`.Add `import 'react-spring-bottom-sheet/dist/style.css';` to your entry file or a relevant component file.
Design child components to be resilient to unmounting/remounting, or manage their state externally if persistence across sheet closures is required. Avoid complex local state that needs to be preserved when the sheet is closed.
Refer to the documentation for available CSS custom properties (e.g., `--rsbs-bg`, `--rsbs-handle-bg`) and use them to customize the sheet's appearance. Copying `style.css` into your project allows full control.
Only use `blocking={false}` when the sheet's behavior genuinely doesn't require a modal-like interaction that traps focus. For most dialog-like bottom sheets, keep `blocking={true}` (default) or ensure alternative accessibility considerations are made.Ensure `react-spring` and its dependencies are correctly configured for your bundler. Check GitHub issues for workarounds related to `StrictMode` or specific framework versions. Consider alternative packages or forks if the issue persists and is framework-specific.
Verify that `open` is a boolean state variable and `onDismiss` correctly sets this state variable to `false`. E.g., `const [open, setOpen] = useState(false); <BottomSheet open={open} onDismiss={() => setOpen(false)} />`.Add `import 'react-spring-bottom-sheet/dist/style.css';` to your main application file (e.g., `App.tsx` or `index.tsx`). Ensure your bundler is configured to handle CSS imports.
Update your project's `react` and `react-dom` packages to a compatible version (e.g., `^18.0.0`) or install the package with `--force` or `--legacy-peer-deps` (use with caution as it might lead to unexpected behavior).