トーストは、画面上のメッセージを通じて操作に関する簡単なフィードバックを提供します。
次のコンポーネントが含まれています
トースト
名前 | タイプ | デフォルト | 説明 |
---|---|---|---|
button | ReactNode | トーストボタンの内容 | |
colors | object | Tailwind CSSのカラークラスを持つオブジェクト | |
colors.bgIos | string | 'bg-black' | |
colors.bgMaterial | string | 'bg-md-light-surface-5 dark:bg-md-dark-surface-5' | |
colors.textIos | string | 'text-white' | |
colors.textMaterial | string | 'text-md-light-primary dark:text-md-dark-primary' | |
component | string | 'div' | コンポーネントのHTML要素 |
opened | boolean | false | トーストを開閉し、初期状態を設定できます |
position | 'left' | 'right' | 'center' | 'left' | トーストの位置(ワイドスクリーンのみ)。 |
translucent | boolean | true | iOSテーマでトーストの背景を半透明にします( |
import React, { useState } from 'react';import {Page,Navbar,NavbarBackLink,Button,Toast,Block,} from 'konsta/react';export default function ToastPage() {const [toastLeftOpened, setToastLeftOpened] = useState(false);const [toastCenterOpened, setToastCenterOpened] = useState(false);const [toastRightOpened, setToastRightOpened] = useState(false);const openToast = (setter) => {// close other toastsetToastLeftOpened(false);setToastCenterOpened(false);setToastRightOpened(false);setter(true);};return (<Page><Navbartitle="Toast"/><Block strongIos outlineIos className="space-y-4"><Toastposition="left"opened={toastLeftOpened}button={<ButtonroundedclearsmallinlineonClick={() => setToastLeftOpened(false)}>Close</Button>}><div className="shrink">Hello this is left toast!</div></Toast><Toastposition="center"opened={toastCenterOpened}button={<ButtonroundedclearsmallinlineonClick={() => setToastCenterOpened(false)}>Close</Button>}><div className="shrink">Hello this is center toast!</div></Toast><Toastposition="right"opened={toastRightOpened}button={<ButtonroundedclearsmallinlineonClick={() => setToastRightOpened(false)}>Close</Button>}><div className="shrink">Hello this is right toast!</div></Toast><p>Toasts provide brief feedback about an operation through a message onthe screen.</p><p><Button onClick={() => openToast(setToastLeftOpened)}>Toast on Left</Button></p><p><Button onClick={() => openToast(setToastCenterOpened)}>Toast on Center</Button></p><p><Button onClick={() => openToast(setToastRightOpened)}>Toast on Right</Button></p></Block></Page>);}