Skip to content

Menu

EMenu is a key feature in web development, it provides a handy means of presenting users with a list of choices. They appear at the position the element that generates them. Demo Here

Import

jsx
import EMenu from "@components/Elements/EMenu";

Usage

jsx
<EMenu color="primary" title="Drop down menu">
    <ul>
        <li>Action 1</li>
        <li>Action 2</li>
    </ul>
</EMenu>
controlled EMenu

You can control menu open state by using isOpen and onChange props.

jsx
const MenuExample = () => {
    const [isOpen, setIsOpen] = useState(true); 

    const onChangeHandler = (event, isMenuOpen) => {
        setIsOpen(isMenuOpen);
    };

    return (
        <EMenu
          color="primary" 
          title="Menu" 
          isOpen={isOpen}
          onChange={onChangeHandler}
        >
            <ul>
                <li>Action 1</li>
                <li>Action 2</li>
            </ul>
        </EMenu>
    );
};

export default MenuExample;

Props

For EMenu component, the following props are available:

PropTypeDefaultNote
width[String, Number]-Sets the component's width. Default unit is px.
height[String, Number]-Sets the component's height. Default unit is px.
disabledBooleanfalseDisables the menu.
roundedBooleanfalseIt creates a circular menu.
squareBooleanfalseSquares the corners of the menu.
isOpenBooleanfalseControls the open state of menu.
titleString-Adds a title to the EMenu element.
closeOnContentClickBooleanfalseIt closes the menu on content click.
classNameString-Overrides or extends the component's wrapper styles.
contentClassNameString-Overrides or extends the component's content styles.
btnClassNameString-Overrides or extends the component's button styles.
sizeString"md"The EMenu element has three predefined sizes: sm, md, lg.
customColorString-A custom color in rgb format is applied to the menu (e.g, customColor="101, 89, 204").
positionString"bottom"The position prop allows the menu to be offset relative to the activator.The element can appear from the left, right,top or bottom edge of the parent.
colorString"primary"The given color is applied to the menu - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.
arrowIcon[Boolean, Object]trueBy using this prop you can hide/display the arrow icon of the menu title or you can change it. More Info about icons here.
iconObject-By using icon prop the EMenu element will be visualized with an Icon.The icon appears before the default slot. More Info about icons here.
iconBtnObject-By using iconBtn prop the EMenu element will be visualized in an Icon form. More Info about icons here.
variantString"fill"The EMenu element can be represented in two ways: fill, alternate, outline ,text. alternate displays the menu with a light background, outline draws a border around an element and text displays the menu with only text and no background color.
animationString"expand"The EMenu element can be animated in many ways. Defined animations here.
animationOriginString"origin-center"Defines the animation origin, values: Tailwind css classes for origin.

Callback Functions

The EMenu component contains following callback functions.

FunctionDescription
onChangeCallback fired when the open state is changed. function(event: React.SyntheticEvent, isOpen: Boolean) => void 👇

event: The event source of the callback.
isOpen: open state value.

Children

The EMenu component provides a children props that enable you to customize the content.

ChildrenDescription
✔️Component's content.

COPYRIGHT