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

rc-drawer

Package Overview
Dependencies
Maintainers
5
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-drawer

drawer component for react

  • 6.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
decreased by-12.79%
Maintainers
5
Weekly downloads
 
Created

What is rc-drawer?

The rc-drawer package is a React component that provides a drawer panel that can slide in from the edge of the screen. It is commonly used for implementing side menus, navigation, or other hidden content that can be revealed interactively.

What are rc-drawer's main functionalities?

Basic Drawer

This code sample demonstrates how to create a basic drawer that can be toggled open and closed with a button. The drawer's visibility is controlled by the 'open' state.

import Drawer from 'rc-drawer';
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  state = {
    open: false,
  };

  onOpenChange = (open) => {
    this.setState({ open });
  };

  render() {
    return (
      <div>
        <button onClick={() => this.onOpenChange(true)}>Open Drawer</button>
        <Drawer
          open={this.state.open}
          onOpenChange={this.onOpenChange}
        >
          <p>This is the content of the drawer.</p>
        </Drawer>
      </div>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('container'));

Positioning

This code sample shows how to position the drawer on the right side of the screen. The 'position' prop can be set to 'left', 'right', 'top', or 'bottom'.

import Drawer from 'rc-drawer';
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  state = {
    open: false,
  };

  onOpenChange = (open) => {
    this.setState({ open });
  };

  render() {
    return (
      <Drawer
        open={this.state.open}
        position='right'
        onOpenChange={this.onOpenChange}
      >
        <p>This drawer slides in from the right.</p>
      </Drawer>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('container'));

Custom Styling

This code sample illustrates how to apply custom styles to the drawer. The 'style' prop accepts a JavaScript object with CSS properties.

import Drawer from 'rc-drawer';
import React from 'react';
import ReactDOM from 'react-dom';

class App extends React.Component {
  render() {
    return (
      <Drawer
        open={true}
        style={{ backgroundColor: 'lightblue' }}
      >
        <p>Custom styled drawer content.</p>
      </Drawer>
    );
  }
}

ReactDOM.render(<App />, document.getElementById('container'));

Other packages similar to rc-drawer

Keywords

FAQs

Package last updated on 16 Feb 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