Skip to content

Photon.Menu()

Interact with <Menu/> components in the DOM.

Importing

1
import Photon from "photoncss";

Use the default export

Usage

1
Photon.Menu(menu_element);
returns new Menu

Arguments

Argument Type Description
menu_element string | jQuery | Element Any of the allowed types that resolves to an element on the DOM.

Class

Properties

.isOpen : boolean

Gets if the menu is open.

.target : jQuery

Get the menu element on the DOM.

Methods

.anchor(positionX: number, positionY: number) : this

.anchor(anchorToElement: string | jQuery | Element) : this

Sets the menu position.

.close() : this

Closes the menu.

.open() : this

Closes the menu.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React, { Fragment } from "react";
import Photon from "photoncss";
import { Button, Menu } from "photoncss/react";

export function MyMenu() {
    return (
        <Menu id="my-menu">
            Hi, im a menu
        </Menu>
    );
}

export default function Component() {
    return (
        <Fragment>

            <MyMenu/>

            <Button
              color="primary"
              variant="raised"
              onClick={ () => Photon.Menu("#my-menu").open() }>Show menu</Button>

        </Fragment>
    );
}