flymodal
react 용 modal 콤포넌트 (ts) - flymodal
web data
2026. 8. 4. 23:30
flymodal
* react 용 modal 콤포넌트 (typescript)
- 토스트메세지 띄우기
- 대화상자 띄우기
리액트 상태값, 랜더링 어쩌구 복잡한거 없이 그냥 함수 호출로 간단히 토스트, 다이얼로그 창 띄우기 좋다.
* DEMO
* npm 링크
https://www.npmjs.com/package/flymodal
* 설치
- npm i flymodal
* 임포트
- import flyModal from 'flymodal';
- import 'flymodal/dist/flymodal.css';
* 토스트 메세지 띄우기
- const showToast = (pos: 'top' | 'center' | 'bottom' = 'center') => {
- flyModal.showToast({
- msg: 'This is a toast message.' + pos,
- duration: 1,
- pos,
- });
- };
* 다이얼로그 띄우기
- const showDialog = () => {
- flyModal.showDialog({
- title: 'dialog title',
- content: 'dialog content | multi line,
- buttonList: [
- {
- label: 'cancel',
- onClick: () => {
- console.log('cancel');
- flyModal.closeDialog();
- },
- },
- {
- label: 'ok',
- onClick: () => {
- console.log('ok');
- flyModal.closeDialog();
- },
- isDefault: true,
- },
- ],
- // onShow: () => {
- // console.log('onload function');
- // },
- // onClose: () => {
- // console.log('onClose function');
- // },
- // overlayClose: true,
- // escClose: true,
- });
- };