A React Component to build friendly dialogs that slide from the bottom
npm install react-bottom-drawerThis package contains a single React component that allows you to build mobile-friendly dialogs that slide from the bottom.
While it works on desktop, it is designed as a mobile interaction.
It has 100% typescript support, as it's written in typescript.
Using it is pretty straight-forward, just import the component, and place the content as it's children.
``jsx
import React from "react";
import Drawer from "react-bottom-drawer";
function DemoDrawer() {
const [isVisible, setIsVisible] = React.useState(false);
const onClose = React.useCallback(() => {
setIsVisible(false);
}, []);
return (
onClose={onClose}
>
{ ... }
)
}
`
| Prop | Type | Required? | Default Value | Description |
| -------------- | ---------- | --------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| isVisible | boolean | Required | - | Shows or hides the modal |function
| onClose | | Required | - | Invoked when the drawer should be close. You shoud be setting isVisible to false in this callback |boolean
| mountOnEnter | | Optional | true | If true, the children won't be mounted until isVisible is true. If false, we will mount the children, and hide them via CSS. |boolean
| unmountOnExit | | Optional | true | If true, we will unmount the children once isVisible goes back to false. If false, we won't unmount the children after mounting them. |number
| duration | | Optional | 250 | Duration of the enter / exit animation in ms |boolean
| hideScrollbars | | Optional | false | If true, scrollbars won't appear even if content is scrollable |string
| className | | Optional | undefined | For theming. If provided, it will generate classNames for all divs based on the provided value |
Click here to see some examples on codesandbox.
You can provide custom styles by providing a custom className prop. You can use them to add styling to!important
the drawer. If you need to override some values, you probably need to use .
These are all the available classNames:`css
.drawer {
}
.drawer__backdrop {
}
.drawer__handle-wrapper {
}
.drawer__handle {
}
.drawer__content {
}
``