New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cloudflare/component-dropdown

Package Overview
Dependencies
Maintainers
0
Versions
647
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudflare/component-dropdown

Cloudflare Dropdown Component

  • 6.1.60
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
increased by11.79%
Maintainers
0
Weekly downloads
 
Created
Source

@cloudflare/component-dropdown

Cloudflare Dropdown Component

Installation

Installation with yarn is recommended


$ yarn add @cloudflare/component-dropdown

Usage

import React from 'react';
import { Dropdown, DropdownLink, DropdownSeparator } from '../../src';
import { Button, ButtonGroup } from '@cloudflare/component-button';
import { Code } from '@cloudflare/component-code';

class DropdownComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      dropdown1Open: false,
      dropdown2Open: false
    };
  }

  render() {
    return (
      <div>
        <ButtonGroup>
          <Button
            type="primary"
            onClick={() => this.setState({ dropdown1Open: true })}
          >
            Open Dropdown 1
          </Button>

          {this.state.dropdown1Open && (
            <Dropdown onClose={() => this.setState({ dropdown1Open: false })}>
              <DropdownLink to="/foo">Link to /foo</DropdownLink>
              <DropdownLink to="/bar">Link to /bar</DropdownLink>
              <DropdownSeparator />
              <DropdownLink to="/baz">Link to /baz</DropdownLink>
              <DropdownLink to="/bat">Link to /bat</DropdownLink>
              <DropdownLink disabled to="/bad">
                Disabled dropdown link
              </DropdownLink>
            </Dropdown>
          )}

          <Button
            type="success"
            onClick={() => this.setState({ dropdown2Open: true })}
          >
            Open Dropdown 2
          </Button>

          {this.state.dropdown2Open && (
            <Dropdown
              align="right"
              onClose={() => this.setState({ dropdown2Open: false })}
            >
              <DropdownLink to="/foo">Link to /foo</DropdownLink>
              <DropdownLink to="/bar">Link to /bar</DropdownLink>
              <DropdownSeparator />
              <DropdownLink to="/baz">Link to /baz</DropdownLink>
              <DropdownLink to="/bat">Link to /bat</DropdownLink>
            </Dropdown>
          )}
        </ButtonGroup>
        <p>
          {`You can also optionally pass an align prop with either "left" or
          "right"`}
        </p>
        <Code isCodeBlock={true}>{`<Dropdown align="right" ...>`}</Code>
        <p>
          <Code>{`<DropdownLink/>`}</Code> just wraps cf-component-link so you
          can use either to to specify a route or pass an onClick handler.
        </p>
        <Code isCodeBlock={true}>{`<DropdownLink to="/my-route"/>`}</Code>
        <Code
          isCodeBlock={true}
        >{`<DropdownLink onClick={this.handleClick}/>`}</Code>
        <p>
          Note: to requires that you setup cf-util-route-handler prior to
          routing.
        </p>
      </div>
    );
  }
}

export default DropdownComponent;

FAQs

Package last updated on 10 Dec 2024

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