Skip to content

Photon.Snackar()

Interact with <Snackar/> components in the DOM.

Importing

1
import Photon from "photoncss";

Use the default export

Usage

1
Photon.Snackbar(<Snackbar/>, options);
returns new Snackbar

Arguments

Argument Type Description
snackbar JSX Snackbar element.
options Object Snackbar options.
options.id? string Snackbar ID.
options.duration? number | null Time in milliseconds to show snackbar for, use null to show forever.

Class

Properties

.isOpen : boolean

Gets if the drawer is open.

.snackbar : jQuery

Get the drawer element on the DOM.

.options : Object

Get the options the snackbar was shown with.

Methods

.close() : this

Closes the drawer.

.open() : this

Closes the drawer.

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
import React, { Fragment } from "react";
import Photon from "photoncss";
import { Button, Snackbar } from "photoncss/react";

export function MySnackbar() {
    return (
        <Snackbar>
            <p>Hi, im a drawer</p>
        </Snackbar>
    );
}

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

            <Button
              color="primary"
              variant="raised"
              onClick={ () => Photon.Snackbar(<MySnackbar/>) }>Show snackbar</Button>

        </Fragment>
    );
}