Giter VIP home page Giter VIP logo

react-circular-menu's Introduction

React Circular Menu

Version Downloads

Circle based menu component for React with custom angle range and any number of menu items.

Demo: https://9inpachi.github.io/react-circular-menu

React Circular Menu

Table of Contents

Setup

Install the npm package.

npm install react-circular-menu
# or
yarn add react-circular-menu

Install external dependencies styled-components and @material-ui/core if you don't already have them.

npm install styled-components @material-ui/core
# or
yarn add styled-components @material-ui/core

Example

import MailIcon from "@material-ui/icons/Mail";
import HelpOutlineIcon from "@material-ui/icons/HelpOutline";
import MapIcon from "@material-ui/icons/Map";

// Import the circular menu
import { CircleMenu, CircleMenuItem } from "react-circular-menu";

export const TestMenuComponent = (props) => {
  return (
    <CircleMenu
      startAngle={-90}
      rotationAngle={360}
      itemSize={2}
      radius={5}
      /**
       * rotationAngleInclusive (default true)
       * Whether to include the ending angle in rotation because an
       * item at 360deg is the same as an item at 0deg if inclusive.
       * Leave this prop for angles other than 360deg unless otherwise desired.
       */
      rotationAngleInclusive={false}
    >
      <CircleMenuItem
        onClick={() => alert("Clicked the item")}
        tooltip="Email"
        tooltipPlacement="right"
      >
        <MailIcon />
      </CircleMenuItem>
      <CircleMenuItem tooltip="Help">
        <HelpOutlineIcon />
      </CircleMenuItem>
      <CircleMenuItem tooltip="Location">
        <MapIcon />
      </CircleMenuItem>
      <CircleMenuItem tooltip="Info">
        <InfoIcon />
      </CircleMenuItem>
    </CircleMenu>
  );
};

Props

All angles are in degrees.

CircleMenu

startAngle: number

The angle at which the circle menu starts. That is, the angle at which the first item exists.

Example: -90

rotationAngle: number

The angle by which the menu is to be rotated. For example, 360 for a complete circle.

Example: 270

rotationAngleInclusive?: boolean

Whether to include the ending angle in rotation. Because an item at 360 degrees is the same as an item at 0 degree if inclusive. Leave this prop for angles other than 360 degrees unless otherwise desired.

Example: false

radius?: number

Radius of the circle (in em).

Example: 5

itemSize?: number

Size of the menu toggle and menu items (in em).

Example: 2

className?: string

Class name to apply custom styles to circle menu wrapper.

Example: testClass

menuToggleClassName?: string

Class name to apply custom styles to circle menu toggle.

Example: testClass

onMenuToggle?: (menuActive: boolean) => void

Callback called on toggling the menu.

Example:

(menuActive) => console.log(menuActive);

CircleMenuItem

size?: number

Size of the menu item. Set by itemSize of CircleMenu component.

Example: 2

link?: string

Link to point to a URL.

Example: https://google.com

tooltipPlacement?: 'bottom-end' | 'bottom-start' | 'bottom' | 'left-end' | 'left-start' | 'left' | 'right-end' | 'right-start' | 'right' | 'top-end' | 'top-start' | 'top'

Placement position of the menu item tooltip.

Example: top

target?: string

The target attribute of anchor tag (<a target="_blank"></a>) if link prop is set.

Example: _blank

className?: string

Extra class name for applying custom styles.

Example: testClass

style?: CSSProperties

Extra inline styles for the component.

Example: { background: 'red' }

onClick?: (event: MouseEvent) => void

Callback when the component is clicked.

Example:

(event) => console.log("Clicked");

radius?: number

Radius of the menu item from the menu toggle. Set by CircleMenu component.

Example: 5

menuActive?: boolean

Whether the menu and thus the menu item is active or not. Set by CircleMenu component.

Example: true

rotationAngle?: number

Rotation angle in degrees of the menu item from the startAngle of CircleMenu. Set by CircleMenu component.

Example: 90

react-circular-menu's People

Contributors

9inpachi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.