HomeOur TeamContact

Circular action menu

By Utkarsh Lubal
Published in Buttons
May 06, 2023
1 min read
Circular action menu

Table Of Contents

01
Introduction
02
Installation
03
Example
04
Tutorial

Introduction

Configuration

ActionButton:
PropertyTypeDefaultDescription
activebooleanfalseaction buttons visible or not
autoInactivebooleantrueAuto hide ActionButtons when ActionButton.Item is pressed.
positionstring“center”one of: left center and right
radiusnumber100radius of menu
bgColorstring“transparent”color of overlay when ActionButtons are visible
buttonColorstring“rgba(0,0,0,1)”background color of the +Button (must be rgba value!)
btnOutRangestringprops.buttonColorbutton background color to animate to
outRangeScalenumber1changes size of button during animation
onPressfunctionnullfires, when ActionButton is tapped
onLongPressfunctionnullfires, when ActionButton is long pressed
onOverlayPressfunctionnullfires, when Overlay is pressed
iconComponent+Custom component for ActionButton Icon
backdropComponentfalseCustom component for use as Backdrop)
degreesnumber135degrees to rotate icon
ActionButton.Item:
PropertyTypeDefaultDescription
onPressfuncnullrequired function, triggers when a button is tapped
buttonColorstringsame as + buttonbackground color of the Button
startDegreenumber0degrees to start the rotation of the Item
endDegreenumber720degrees to end the rotation of the Item

Installation

npm i react-native-circular-action-menu –save

Example

import React, { useState } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import ActionButton from 'react-native-circular-action-menu';
import Icon from 'react-native-vector-icons/MaterialIcons';

const App = () => {
  const [menuOpen, setMenuOpen] = useState(false);

  return (
    <View style={styles.container}>
      <Text style={styles.title}>Circular Action Menu</Text>
      <ActionButton
        buttonColor="rgba(231,76,60,1)"
        buttonTextStyle={styles.menuText}
        icon={<Icon name="menu" style={styles.menuIcon} />}
        onPress={() => setMenuOpen(!menuOpen)}
        bgColor="rgba(0,0,0,0.7)"
        radius={100}
        offsetY={-60}
        offsetX={-30}
        spacing={25}
        active={menuOpen}
      >
        <ActionButton.Item
          buttonColor="#9b59b6"
          title="Add"
          onPress={() => console.log('Add button pressed')}
        >
          <Icon name="add" style={styles.actionButtonIcon} />
        </ActionButton.Item>
        <ActionButton.Item
          buttonColor="#3498db"
          title="Edit"
          onPress={() => console.log('Edit button pressed')}
        >
          <Icon name="edit" style={styles.actionButtonIcon} />
        </ActionButton.Item>
        <ActionButton.Item
          buttonColor="#1abc9c"
          title="Delete"
          onPress={() => console.log('Delete button pressed')}
        >
          <Icon name="delete" style={styles.actionButtonIcon} />
        </ActionButton.Item>
      </ActionButton>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  title: {
    fontSize: 24,
    fontWeight: 'bold',
    marginBottom: 20,
  },
  menuIcon: {
    fontSize: 24,
    color: '#fff',
  },
  menuText: {
    color: '#fff',
  },
  actionButtonIcon: {
    fontSize: 20,
    height: 22,
    color: 'white',
  },
});

export default App;

Tutorial

Coming Soon…


Previous Article
Color Picker
Utkarsh Lubal

Utkarsh Lubal

Full Stack Developer

Related Posts

Custom Button 2
Custom Button 2
May 06, 2023
1 min

Quick Links

Advertise with usAbout UsContact Us

Social Media