Skip to content

Canvas

ECanvas is similar to the EModal component, often hidden and displayed when triggered. However, off-canvas is frequently used as a sidebar navigation menu. Demo Here

Import

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

Usage

jsx
const CanvasExample = () => {
    const [isCanvasShown, setIsCanvasShown] = useState(false);

    const onBtnClick = () => {
        setIsCanvasShown(true)
    }

    const onBackdropClick = () => {
        setIsCanvasShown(false)
    }

    return (
        <Fragment>
            <EBtn onClick={onBtnClick}>
                Open Canvas
            </Btn>
            <ECanvas
                status={isCanvasShown}
                toggleCanvas={onBackdropClick}
                title="Canvas title"
            >
                Canvas content
            </ECanvas>
        </Fragment>
    );
};

export default CanvasExample;

Props

For ECanvas component, the following props are available:

PropTypeDefaultNote
title[Node ,String]-Adds a title to the ECanvas element.
footernode-Footer content
portalBooleantrueEnables react portal.
blurEffectBooleantrueApplies background blur.
width[String, Number]-Sets the component's width. Default unit is px.
height[String, Number]-Sets the component's height. Default unit is px.
bodyClassNameString-Classes to card body of canvas.
squareBooleanfalseRemoves rounded corners of the element.
closeIconBooleantrueAdds close icon to the canvas header.
statusBooleanfalseControls the visible/hidden state of canvas.
persistentBooleanfalsepersistent ECanvas is not discarded when touching outside.
positionString"left"The ECanvas element can appear from the left, right, top or bottom edge of the viewport.
classNameString-Overrides or extends the component's styles.

Callback Functions

The ECanvas component contains following callback functions.

FunctionDescription
toggleCanvasToggles canvas active state. function(event: React.SyntheticEvent, isOpen: Boolean) => void 👇

event: The event source of the callback.
isOpen: visible/hidden state of canvas

Children

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

ChildrenDescription
✔️Component's content.

COPYRIGHT