@corasan/modal-sheet
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

Installation

npm install @corasan/modal-sheet
yarn add @corasan/modal-sheet
bun add @corasan/modal-sheet

Usage

First, wrap your application with the ModalSheetProvider component.

import { ModalSheetProvider } from '@corasan/modal-sheet';

function App() {
  return (
    <ModalSheetProvider>
      <YourApp />
    </ModalSheetProvider>
  );
}

Use refs to expand and minimize the modal sheet.

import { ModalSheetStackRef, ModalSheetStack } from '@corasan/modal-sheet';

function YourComponent() {
  const modalRef = useRef<ModalSheetStackRef>()

  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Butto title="Open Modal" onClick={() => modalRef.current.open())} />

      <ModalSheetStack ref={modalRef} name="modal-drawer">
        <View style={{ flex: 1 }}>
          <View style={{ flexDirection: "row", justifyContent: "center" }}>
            <Text style={{ fontWeight: "500", fontSize: 18 }}>Title</Text>
          </View>

          <View
            style={{
              paddingVertical: 40,
              alignItems: "center",
              justifyContent: "center",
            }}
          >
            <Button
              title="Close Modal"
              onPress={() => {
                modalRef.current.dismiss();
              }}
            />
          </View>
        </View>
      </ModalSheetStack>
    </View>
  );
}

Components

ModalSheetStack

The ModalSheetStack component is a modal sheet that can be opened and dismissed. It creates a modal sheet effect similar to the iOS modal sheet.

Props

Name Type Default Description Required
ref React.RefObject<ModalSheetStackRef> - Ref for the modal sheet Yes
name string - The name of the modal sheet Yes
children ReactNode - The children components Kinda yeah
containerStyle string - Styles for the modal sheet container No
noHandle boolean false Hide the handle No
onDismiss () => void - Callback when the modal sheet is dismissed No
enableDragToDismiss boolean true Enable dragging to dismiss the modal sheet No

Methods

Name Type Description
open () => void Open the modal sheet
dismiss () => void Dismiss the modal sheet

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.0.471latest

Version History

VersionDownloads (Last 7 Days)Published
2.0.471
2.0.30
2.0.2113
2.0.10
2.0.00
2.0.0-rc.180
2.0.0-rc.170
2.0.0-rc.1653
2.0.0-rc.150
2.0.0-rc.140
2.0.0-rc.130
2.0.0-rc.120
2.0.0-rc.110
2.0.0-rc.100
2.0.0-rc.90
2.0.0-rc.80
2.0.0-rc.70
2.0.0-rc.60
2.0.0-rc.50
2.0.0-rc.40
2.0.0-rc.30
2.0.0-rc.20
2.0.0-rc.10
2.0.0-rc.00
1.4.20
1.4.10
1.4.00
1.3.00
1.2.00
1.1.00
1.0.11
1.0.00

Package Sidebar

Install

npm i @corasan/modal-sheet

Weekly Downloads

238

Version

2.0.4

License

MIT

Unpacked Size

152 kB

Total Files

71

Last publish

Collaborators

  • corasan