1.0.13 • Published 7 months ago

react-stateful-bottom-sheet v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

React Stateful Bottom Sheet

https://github.com/helgastogova/react-stateful-bottom-sheet/assets/3423341/2c778317-4618-47c8-82ef-234741a7b86d

React Stateful Bottom Sheet is a versatile npm package that provides a stateful bottom sheet component for your React applications. It fits easily into your project, enhancing user interaction and responsiveness.

hackernoon arcticle about creation that component https://hackernoon.com/building-a-stateful-bottom-sheet-component-in-react

Features

  1. Flexible and customizable: Adapt the bottom sheet component to match your project's design and functionality requirements with ease.
  2. Draggable and resizable: Users can interactively drag the bottom sheet up and down, with the component automatically resizing its height in response.
  3. State management: Built-in state management allows for toggling the bottom sheet open or closed, offering a smooth user experience.
  4. Smooth animations: Leverages the framer-motion library for fluid animations and transitions.
  5. TypeScript support: TypeScript integration enhances type safety and the overall developer experience.

With these features, React Stateful Bottom Sheet serves as a comprehensive solution for implementing bottom sheets in your React applications, facilitating the creation of dynamic, engaging user interfaces.

Demo

Check out the live demo here.

Installation

npm install react-stateful-bottom-sheet

Usage

Here is an example of how you can use the React Stateful Bottom Sheet component::

import React from "react";
import { BottomSheet } from "react-stateful-bottom-sheet";

const MyComponent = () => {
  return (
    <BottomSheet>
      {({ isOpen, setOpen }) => {
          if (isOpen)
            return (
              <div>
                <div>Open state example</div>
                <button onClick={() => setOpen(false)}>
                  Test setOpen function
                </button>
              </div>
            );
          return (
            <div>Closed state example</div>
          );
        }}
    </BottomSheet>
  );
};

export default MyComponent;

Props

The StatefulBottomSheet component accepts the following props:

Prop NameTypeDescription
childrenReactNode or ((props: BottomSheetChildProps) => ReactNode)React node(s) to be rendered inside the bottom sheet. If this prop is a function, it will receive an object with isOpen and setOpen properties.
rootClassNamestring (optional)A CSS class name for the bottom sheet container.
wrapperClassNamestring (optional)A CSS class name for the wrapper element inside the bottom sheet container.
lineClassNamestring (optional)A CSS class name for the line element inside the bottom sheet.
contentClassNamestring (optional)A CSS class name for the content area inside the bottom sheet.
compactHeightstring (optional)The height of the bottom sheet when it is in its compact state. Default is "auto".
fullHeightstring (optional)The height of the bottom sheet when it is in its full state. Default is "90vh".
onClickOutside() => void (optional)A callback function that is invoked when a click is detected outside the bottom sheet.
closeOnClickOutsideboolean (optional)Indicates whether the bottom sheet should close when a click is detected outside of it. Default is true.

License

React Clickable Post Wrapper is released under the MIT License.

1.0.9

7 months ago

1.0.8

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.13

7 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.2-beta.3

10 months ago

1.0.2-beta.2

10 months ago

1.0.2-beta.1

10 months ago

1.0.1

10 months ago