rn-bottomsheet-coder-piyush
v1.0.4
Published
Here's the updated README with your npm username and the correct package name:
Readme
Here's the updated README with your npm username and the correct package name:
# BottomSheet Component
A customizable, draggable bottom sheet component for React Native that
can be opened and closed dynamically. The component supports gesture
handling for drag-to-dismiss functionality, customizable drag indicators,
and flexible content insertion.
## Features
- **Draggable**: Users can drag the bottom sheet
to open and close it.
- **Gestures**: The sheet responds to swipe
gestures and can be closed or opened based
on the swipe position.
- **Customizable Drag Indicator**: You can customize the
appearance and position of the drag indicator.
- **Content Injection**: Insert dynamic content inside
the bottom sheet.
- **Configurable Open/Close**: Open and close the sheet
programmatically via the `open` prop.
## Installation
To install the `BottomSheet` component, run the following command:
```bash
npm install rn-bottomsheet-coder-piyushUsage
Import and use the BottomSheet component in your React Native project:
import React, { useState } from "react";
import { View, Button } from "react-native";
import BottomSheet from "rn-bottomsheet-coder-piyush";
export default function App() {
const [open, setOpen] = useState(false);
return (
<View style={{ flex: 1 }}>
<Button title="Open Bottom Sheet" onPress={() => setOpen(true)} />
<BottomSheet
open={open}
setOpen={setOpen}
content={() => <View><Text>Your content here</Text></View>}
/>
</View>
);
}Props
| Name | Type | Default | Description |
| ------------------------ | ------------------- | -------------- | ----------- |
| open | boolean | false | Controls whether the bottom sheet is open or closed. |
| setOpen | function | | A function to set the open state. |
| content | function | | A function that returns the content to be displayed inside the bottom sheet. |
| dragIndicatorColor | string | "#ccc" | Color of the drag indicator. |
| showDragIndicator | boolean | true | Whether to display the drag indicator. |
| draggable | boolean | true | Whether the bottom sheet is draggable. |
| dragwidth | number | 50 | Width of the drag indicator. |
| dragheight | number | 5 | Height of the drag indicator. |
| dragborderRadius | number | 2.5 | Border radius of the drag indicator. |
| dragalignSelf | string | "center" | Alignment of the drag indicator. |
| dragmarginVertical | number | 10 | Vertical margin of the drag indicator. |
| dragableindicatorstyle | object | {} | Custom styles for the drag indicator. |
| MainHeight | number | height | Height of the screen, typically the window height. |
Example
import React, { useState } from "react";
import { View, Button, Text } from "react-native";
import BottomSheet from "rn-bottomsheet-coder-piyush";
export default function App() {
const [open, setOpen] = useState(false);
return (
<View style={{ flex: 1 }}>
<Button title="Open Bottom Sheet" onPress={() => setOpen(true)} />
<BottomSheet
open={open}
setOpen={setOpen}
content={() => (
<View style={{ padding: 20 }}>
<Text>This is the content inside the bottom sheet!</Text>
<Button title="Close" onPress={() => setOpen(false)} />
</View>
)}
dragIndicatorColor="#333"
showDragIndicator={true}
draggable={true}
/>
</View>
);
}License
This project is licensed under the MIT License.
Acknowledgments
- This component uses
react-native-gesture-handlerandreact-native-reanimatedfor smooth and interactive gestures.
