3.0.0 • Published 3 years ago

@arterial/snackbar v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Arterial Snackbar

Another React Material Snackbar

Installation

npm install @arterial/snackbar

Usage

Styles

Sass

@use "@material/snackbar/index.scss" as snackbar;
@include snackbar.core-styles;

CSS

import '@material/snackbar/dist/mdc.snackbar.css';

JSX

import {Snackbar} from '@arterial/snackbar';

Regular Snackbar

function Regular() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button label="Open" onClick={() => setOpen(true)} unelevated />
      <Snackbar
        label="Can't send photo. Retry in 5 seconds."
        onClose={() => setOpen(false)}
        open={open}
      />
    </>
  );
}

Other Variants

Dismiss

function Dismiss() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button label="Open" onClick={() => setOpen(true)} unelevated />
      <Snackbar
        dismiss
        label="Can't send photo. Retry in 5 seconds."
        onClose={() => setOpen(false)}
        open={open}
      />
    </>
  );
}

Action and Dismiss

function ActionDismiss() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button label="Open" onClick={() => setOpen(true)} unelevated />
      <Snackbar
        action="Retry"
        dismiss
        label="Can't send photo. Retry in 5 seconds."
        onClose={() => setOpen(false)}
        open={open}
      />
    </>
  );
}

Leading

function Leading() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button label="Open" onClick={() => setOpen(true)} unelevated />
      <Snackbar
        action="Retry"
        dismiss
        label="Can't send photo. Retry in 5 seconds."
        leading
        onClose={() => setOpen(false)}
        open={open}
      />
    </>
  );
}

Leading

function Stacked() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button label="Open" onClick={() => setOpen(true)} unelevated />
      <Snackbar
        action="Retry"
        dismiss
        label="Can't send photo. Retry in 5 seconds."
        onClose={() => setOpen(false)}
        open={open}
        stacked
      />
    </>
  );
}

Props

Snackbar

NameTypeDescription
actionstringText to be displayed within action button of root element.
classNamestringClasses to be applied to the root element.
dismissbooleanEnables dismiss icon to be displayed within root element.
labelstringText to be displayed within the root element.
leadingbooleanEnables a leading variant.
onClosefunctionClose event handler.
openbooleanIndicates whether the element is open.
stackedbooleanEnables a stacked variant.
3.0.0

3 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-alpha.6

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.0

4 years ago