Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chakra-ui/modal

Package Overview
Dependencies
Maintainers
2
Versions
511
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/modal

An accessible dialog (modal) component for React & Chakra UI

  • 0.0.0-dev-20230528200306
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
479K
decreased by-5.72%
Maintainers
2
Weekly downloads
 
Created

What is @chakra-ui/modal?

@chakra-ui/modal is a component library for creating accessible and customizable modal dialogs in React applications. It provides a set of components and hooks to easily manage modal states and styles.

What are @chakra-ui/modal's main functionalities?

Basic Modal

This code demonstrates how to create a basic modal using @chakra-ui/modal. It includes a button to open the modal, and the modal itself contains a header, body, footer, and a close button.

```jsx
import { Modal, ModalOverlay, ModalContent, ModalHeader, ModalFooter, ModalBody, ModalCloseButton, Button, useDisclosure } from '@chakra-ui/react';

function BasicModal() {
  const { isOpen, onOpen, onClose } = useDisclosure();

  return (
    <>
      <Button onClick={onOpen}>Open Modal</Button>
      <Modal isOpen={isOpen} onClose={onClose}>
        <ModalOverlay />
        <ModalContent>
          <ModalHeader>Modal Title</ModalHeader>
          <ModalCloseButton />
          <ModalBody>
            This is the modal body.
          </ModalBody>
          <ModalFooter>
            <Button colorScheme="blue" mr={3} onClick={onClose}>
              Close
            </Button>
          </ModalFooter>
        </ModalContent>
      </Modal>
    </>
  );
}
```

Centered Modal

This code demonstrates how to create a centered modal using @chakra-ui/modal. The `isCentered` prop ensures that the modal is vertically and horizontally centered on the screen.

```jsx
import { Modal, ModalOverlay, ModalContent, ModalHeader, ModalFooter, ModalBody, ModalCloseButton, Button, useDisclosure } from '@chakra-ui/react';

function CenteredModal() {
  const { isOpen, onOpen, onClose } = useDisclosure();

  return (
    <>
      <Button onClick={onOpen}>Open Centered Modal</Button>
      <Modal isOpen={isOpen} onClose={onClose} isCentered>
        <ModalOverlay />
        <ModalContent>
          <ModalHeader>Centered Modal</ModalHeader>
          <ModalCloseButton />
          <ModalBody>
            This modal is centered.
          </ModalBody>
          <ModalFooter>
            <Button colorScheme="blue" mr={3} onClick={onClose}>
              Close
            </Button>
          </ModalFooter>
        </ModalContent>
      </Modal>
    </>
  );
}
```

Scrollable Modal

This code demonstrates how to create a scrollable modal using @chakra-ui/modal. The `scrollBehavior` prop set to `inside` ensures that the modal content is scrollable if it exceeds the viewport height.

```jsx
import { Modal, ModalOverlay, ModalContent, ModalHeader, ModalFooter, ModalBody, ModalCloseButton, Button, useDisclosure } from '@chakra-ui/react';

function ScrollableModal() {
  const { isOpen, onOpen, onClose } = useDisclosure();

  return (
    <>
      <Button onClick={onOpen}>Open Scrollable Modal</Button>
      <Modal isOpen={isOpen} onClose={onClose} scrollBehavior="inside">
        <ModalOverlay />
        <ModalContent>
          <ModalHeader>Scrollable Modal</ModalHeader>
          <ModalCloseButton />
          <ModalBody>
            <p>Content that is long enough to require scrolling...</p>
            <p>More content...</p>
            <p>Even more content...</p>
          </ModalBody>
          <ModalFooter>
            <Button colorScheme="blue" mr={3} onClick={onClose}>
              Close
            </Button>
          </ModalFooter>
        </ModalContent>
      </Modal>
    </>
  );
}
```

Other packages similar to @chakra-ui/modal

Keywords

FAQs

Package last updated on 28 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc