Body Scroll Lock
body-scroll-lock
Enables body scroll locking (for iOS Mobile and Tablet, Android, desktop Safari/Chrome/Firefox) without breaking scrolling of a target element (eg. modal/lightbox/flyouts/nav-menus)
Tables
body scroll
body scroll lock
react scroll lock
react scroll
scroll
lock
freeze
toggle
disable
overflow
Stars
1
Weekly
0
Open issues
0
Bundle
~60 kB
Installation
npm install body-scroll-lockCode example
import { useBodyScrollLock } from "body-scroll-lock";
const rows = [
{ id: 1, name: "Ada", role: "Engineer" },
{ id: 2, name: "Linus", role: "Maintainer" },
];
export function Example() {
const table = useBodyScrollLock({ data: rows, columns: [{ accessorKey: "name" }, { accessorKey: "role" }] });
return <pre>{JSON.stringify(table, null, 2)}</pre>;
}Pros & cons
Pros
- Actively maintained by Will Po
- 0 weekly downloads. Battle tested
- MIT licensed
Considerations
- Adds roughly ~60 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 0 open issues on GitHub