1.1.6 • Published 11 months ago

rn-floating-menu v1.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

React Native Floating Menu

A customizable floating menu component for React Native with animated background functionality.

Installation

Install the package using npm or yarn:

npm install rn-floating-menu
# or
yarn add rn-floating-menu

Demo Video

Watch the demo video to see how the react-native-floating-menu works: Link to Demo Video

Usage

import { FloatingMenu } from "rn-floating-menu";

const actionMenus = [
  {
    title: "Menu1",
    icon: "menu1_icon",
    handler: () => console.log("Menu1"),
  },
  {
    title: "Menu2",
    icon: "menu2_icon",
    handler: () => console.log("Menu2"),
  },
];

<FloatingMenu actionMenus={actionMenus} />;

Example

<FloatingMenu
  actionMenus={actionMenus}
  subActionButtonStyle={{ backgroundColor: "red" }}
  backShadow={true}
  subActionTextStyle={{ color: "yellow" }}
  backShadowStyle={{ backgroundColor: "rgba(0, 0, 0, 0.7)" }}
  mainActionButtonStyle={{ backgroundColor: "green" }}
  subActionContainerStyle={{ bottom: 100, right: 50 }}
/>

Props

PropTypeRequiredDescription
actionMenusarrayYesAn array of menu items to display. Each item should be an object with title, icon, and handler.
subActionButtonStyleobjectNoCustom styles for the submenu buttons.
backShadowbooleanNoEnables/disables the background shadow animation when the menu expands. Default is false.
subActionTextStyleobjectNoCustom styles for the submenu text.
backShadowStyleobjectNoCustom styles for the background shadow.
mainActionButtonStyleobjectNoCustom styles for the main action button.
subActionContainerStyleobjectNoCustom styles for the submenu container.

actionMenus Example

Each object in the actionMenus array should have the following properties:

  • title: (string) The title text to display for the menu item.
  • icon: (string) The name of the icon to display for the menu item. Ensure that the icon name is compatible with the react-native-vector-icons library.
  • handler: (function) The function to be executed when the menu item is pressed.

Customization Example

You can customize various parts of the floating menu using the optional props. Here’s an example showing how to customize the appearance of the submenu and the background shadow:

<FloatingMenu
  actionMenus={actionMenus}
  subActionButtonStyle={{ backgroundColor: "red" }}
  backShadow={true}
  subActionTextStyle={{ color: "yellow" }}
  backShadowStyle={{ backgroundColor: "rgba(0, 0, 0, 0.7)" }}
  mainActionButtonStyle={{ backgroundColor: "green" }}
  subActionContainerStyle={{ bottom: 100, right: 50 }}
/>