RC Drawer Component for React

7.3.0 · renamed · verified Sun Apr 19

rc-drawer is a foundational, highly customizable drawer component for React applications, providing animated side panels typically used for navigation menus or ancillary content. Historically, it was a popular choice within the react-component ecosystem for creating fluid, accessible drawer interfaces. The package, currently stable at version 7.3.0, primarily offered imperative and declarative APIs for controlling visibility, position, and animation. However, rc-drawer has been superseded and effectively deprecated. Active development and new features are now exclusively happening under the renamed package, `@rc-component/drawer`, which started its versioning from 1.0.0 and is actively maintained with a regular release cadence. Developers are strongly advised to migrate to `@rc-component/drawer` for ongoing support, bug fixes, and new functionalities like resizable drawers.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import and use the `Drawer` component with basic open/close functionality, including state management and common props. Note that `rc-drawer` is superseded by `@rc-component/drawer`.

import Drawer from 'rc-drawer';
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import './index.css'; // Assume basic styling for visibility

const App = () => {
  const [open, setOpen] = useState(false);

  const toggleDrawer = () => {
    setOpen(!open);
  };

  return (
    <div>
      <button onClick={toggleDrawer}>Open Drawer</button>
      <Drawer
        open={open}
        onClose={toggleDrawer}
        placement="right"
        width={300}
        handler={false} // Disable default handler
        maskClosable={true}
      >
        <div style={{ padding: '20px' }}>
          <h2>Drawer Content</h2>
          <p>This is the content inside the drawer.</p>
          <button onClick={toggleDrawer}>Close Drawer</button>
        </div>
      </Drawer>
    </div>
  );
};

// Mount the app to a DOM element, e.g., <div id="root"></div>
ReactDOM.render(<App />, document.getElementById('root'));

/* Example index.css to make drawer visible: */
/*
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
}
*/

view raw JSON →