1.4.0 β€’ Published 3 years ago

@ijsto/react-slideout v1.4.0

Weekly downloads
21
License
ISC
Repository
github
Last release
3 years ago

react-slideout

Accessible SlideOut component for React.JS

πŸ“– Table of Contents

πŸ“¦ Installation

To install, you can use npm:

$ npm install @ijsto/react-slideout

or yarn:

$ yarn add @ijsto/react-slideout

πŸ”¨ How to Use

Here is a simple example of react-modal being used in an app with some custom styles and focusable input elements within the modal content:

import React, { useState } from "react";
import SlideOut from "@ijsto/react-slideout";

const MySlideOut = () => {
  const [slideOutIsOpen, setSlideOutIsOpen] = useState(false);

  const openSlideOut = () => {
    setSlideOutIsOpen(true);
  };

  const closeSlideOut = () => {
    setSlideOutIsOpen(false);
  };

  return (
    <div>
      <button onClick={openSlideOut}>Open Modal</button>
      <SlideOut isOpen={slideOutIsOpen} onClose={closeSlideOut}>
        <h2>My Slide Out</h2>

        <div>This is the content inside React Slide Out component.</div>
        <button onClick={closeSlideOut}>Close slide-out</button>
      </SlideOut>
    </div>
  );
};

More examples are coming soon.

πŸ“œ API documentation

Props

The following propertiess are available:

Property nameTypeDefaultDescription
bgCSS Color"white"Any legal CSS color value component
childrenA React component-Any React component - this will appear in the slideout
classNamePrefixstring-Namespace - will be applied to all SlideOut components
closeComponentReact Component or html element-Custom close button component
hideClosebooleanfalseUse this to hide close button. You can use parent component to handle state and toggle
isOpenboolean-Controls whether the slideout is visible
max-widthCSS unit100%Custom max-width of the the Slideout container.
offsetTopCSS Unit0Offset slideout from top. Useful to account for the header height.
onClosefunctioninternal state toggleA function that will close the Slideout
onCloseComponentKeyDownfunction-Accessibility handler
onCloseComponentKeyPressfunction-Accessibility handler
onCloseComponentKeyUpfunction-Accessibility handler
onOverlayKeyPressfunction-Accessibility handler
overflowShouldLockBooleantrueLocks the document body overflow-y
overlayColorHEX Color code"#000000" (black)Changes overlay color must be in HEX format (example: "#ffffff")
overlayOpacityinteger from 0 to 10.5Changes default opacity of the overlay
paddingCSS unit-Applied to the inner SlideOut container
shouldCloseOnOverlayClickbooleantrueTo disable closing, when user clicks on overlay set shouldCloseOnOverlayClick={false}
slideFromstring"left"Determines the location from where slideout will appear
speedinteger0.3sControls the speed of the slideout animation
widthCSS unit350pxCustom width of the the Slideout
zIndexIncrementinteger0Increments all zIndexes by the provided value. See default zIndexes below.

Stacking (zIndexes)

By default Slideout components have the following zIndexes:

Here are the available classNames:

  • wrapper // 7
  • close-overlay // 8
  • body // 9

Styling

We provide more fine-grained control over all React-Slideout components via CSS class names.

Here are the available classNames:

  • wrapper // the top-level Slideout component
  • body // the Slideout component content
  • close-button //
  • close-component // wrapper that wrapper your custom close component
  • close-overlay // style overlay background, opacity, z-index etc.

🎬 Demos

Coming soon.

πŸ—ΊοΈ Roadmap

  • Add entry from other sides
  • Add focus management system
  • Improve accessibility

πŸ™†β€β™‚οΈ Contributions

Please feel free to submit PRs for the above (Roadmap) goals or otherwise

iJS.to

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.0.2

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.1.0

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.3

4 years ago

0.0.1

4 years ago