Sonner
トースト通知コンポーネント。ユーザーへのフィードバックを表示します。
インポート
セットアップ
アプリケーションのルートレイアウトに Toaster を配置します。
基本的な使い方
Loading...
バリエーション
成功
Loading...
エラー
Loading...
警告
Loading...
情報
Loading...
説明付き
Loading...
アクションボタン付き
Loading...
Promise対応
非同期処理の状態を表示できます。
Loading...
カスタム表示時間
Loading...
位置の変更
Toaster の position プロパティで表示位置を変更できます。
利用可能な位置:
top-lefttop-centertop-rightbottom-leftbottom-centerbottom-right(デフォルト)
Props
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
theme | 'light' | 'dark' | 'system' | 'system' | テーマ設定 |
position | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'top-center' | 表示位置 |
richColors | boolean | false | バリエーションごとに背景色も変える(デフォルトは背景白でborder・文字・アイコン色のみ変更) |
expand | boolean | false | トーストを展開表示 |
duration | number | 4000 | デフォルトの表示時間(ミリ秒) |
closeButton | boolean | false | 閉じるボタンを表示 |
toast関数
| 関数 | 説明 |
|---|---|
toast(message) | デフォルトのトースト |
toast.success(message) | 成功トースト |
toast.error(message) | エラートースト |
toast.warning(message) | 警告トースト |
toast.info(message) | 情報トースト |
toast.promise(promise, options) | 非同期処理のトースト |
toast.dismiss(id?) | トーストを閉じる |