Skip to content

SakuraWood/react-snack-bar

Repository files navigation

react-snack-bar

installation

npm install @sakurawood/react-snack-bar

or

yarn add @sakurawood/react-snack-bar

base usage

// example

import { useSnackBar } from '@sakurawood/react-snack-bar';

const App = () => {
  const snackBar = useSnackBar();
  snackBar.show('hello world', 'SUCCESS');
  return (
    <div>
      <div />
    </div>
  );
};

api

props

const props = {
  fontSize: 14 ,   // font size of text , default is 14
  align: 'bottom', // position of snack bar in the screen , optional value: ['top','bottom','center'], default is 'bottom'
  rtl: true        // right to left layout, default is false
}

useSnackBar(props)

methods

show : (text:string, type:'SUCCESS'|'WARN'|'INFO'|'ERROR'='ERROR')=> ...