🔥 新しいプロジェクトをご紹介します t0ggles -究極のプロジェクト管理ツール! 🔥

Dialog React コンポーネント

Dialog は、重要な情報を提供したり、意思決定を促したりするために、アプリコンテンツの前に表示されるモーダルウィンドウの一種です。

Dialog コンポーネント

以下のコンポーネントが含まれています。

  • Dialog - ダイアログ要素
  • DialogButton - ダイアログボタン要素

Dialog プロパティ

名前デフォルト値説明
backdropbooleantrue

ポップアップの背景(半透明の暗いレイヤー)を有効にします。

buttonsReactNode

ダイアログボタンの内容

colorsobject

Tailwind CSS のカラークラスを含むオブジェクト

colors.bgIosstring'bg-white dark:bg-neutral-800'

iOS テーマでのダイアログの背景色

colors.bgMaterialstring'bg-md-light-surface-3 dark:bg-md-dark-surface-3'

iOS テーマでのダイアログの背景色

colors.contentTextIosstring''

iOS テーマでのコンテンツテキストの色

colors.contentTextMaterialstring'text-md-light-on-surface-variant dark:text-md-dark-on-surface-variant'

Material テーマでのコンテンツテキストの色

colors.titleIosstring''

iOS テーマでのタイトルテキストの色

colors.titleMaterialstring'text-md-light-on-surface dark:text-md-dark-on-surface'

Material テーマでのタイトルテキストの色

componentstring'div'

コンポーネントの HTML 要素

contentReactNode

ダイアログのメインコンテンツ

openedbooleanfalse

ポップアップを開閉し、初期状態を設定できます。

sizeIosstring'w-[16.875rem]'

iOS テーマの Tailwind CSS サイズクラス

sizeMaterialstring'w-[19.5rem]'

Material テーマの Tailwind CSS サイズクラス

titleReactNode

ダイアログのタイトルコンテンツ

titleFontSizeIosstring'text-[18px]'

iOS テーマのタイトルフォントサイズの Tailwind CSS クラス

titleFontSizeMaterialstring'text-[24px]'

Material テーマのタイトルフォントサイズの Tailwind CSS クラス

translucentbooleantrue

iOS テーマでダイアログの背景をトランスルーセントにします (backdrop-filter: blur を使用)

onBackdropClickfunction(e)

背景要素のクリックハンドラー

DialogButton プロパティ

名前デフォルト値説明
colorsobject

Tailwind CSS のカラークラスを含むオブジェクト

colors.activeBgIosstring'active:bg-black active:bg-opacity-10 dark:active:bg-white dark:active:bg-opacity-10'

iOS テーマでのアクティブ/押下状態の背景色

colors.disabledTextIosstring'text-black text-opacity-30 dark:text-white dark:text-opacity-30'

iOS テーマでの無効化されたボタンのテキストの色

colors.textIosstring'text-primary'

iOS テーマでのテキストの色

componentstring'button'

コンポーネントの HTML 要素

disabledbooleanfalse

ボタンを無効にします。

strongbooleanfalse

iOS テーマではボタンを太字にし、Material テーマでは塗りつぶしにします。strongIosstrongMaterial を上書きします。

strongIosbooleanfalse

iOS テーマでボタンを太字にします。

strongMaterialbooleanfalse

Material テーマでボタンを塗りつぶしにします。

onClickfunction(e)

DialogButton のクリックハンドラー

Dialog.jsx
import React, { useState } from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Dialog,
DialogButton,
Block,
List,
ListItem,
Radio,
Button,
} from 'konsta/react';
export default function DialogPage() {
const [basicOpened, setBasicOpened] = useState(false);
const [alertOpened, setAlertOpened] = useState(false);
const [confirmOpened, setConfirmOpened] = useState(false);
const [listOpened, setListOpened] = useState(false);
const [radioValue, setRadioValue] = useState('batman');
return (
<Page>
<Navbar
title="Dialog"
/>
<Block strong inset className="space-y-4">
<p>
Dialog is a type of modal window that appears in front of app content
to provide critical information, or prompt for a decision to be made.
</p>
</Block>
<Block strong inset>
<p className="grid grid-cols-2 md:grid-cols-4 gap-4">
<Button rounded onClick={() => setBasicOpened(true)}>
Basic
</Button>
<Button rounded onClick={() => setAlertOpened(true)}>
Alert
</Button>
<Button rounded onClick={() => setConfirmOpened(true)}>
Confirm
</Button>
<Button rounded onClick={() => setListOpened(true)}>
List
</Button>
</p>
</Block>
<Dialog
opened={basicOpened}
onBackdropClick={() => setBasicOpened(false)}
title="Dialog Title"
content="Dialog is a type of modal window that appears in front of app content to provide critical information, or prompt for a decision to be made."
buttons={
<>
<DialogButton onClick={() => setBasicOpened(false)}>
Action 2
</DialogButton>
<DialogButton onClick={() => setBasicOpened(false)}>
Action 1
</DialogButton>
</>
}
/>
<Dialog
opened={alertOpened}
onBackdropClick={() => setAlertOpened(false)}
title="Konsta UI"
content="Hello world!"
buttons={
<DialogButton onClick={() => setAlertOpened(false)}>Ok</DialogButton>
}
/>
<Dialog
opened={confirmOpened}
onBackdropClick={() => setConfirmOpened(false)}
title="Konsta UI"
content="All good today?"
buttons={
<>
<DialogButton onClick={() => setConfirmOpened(false)}>
No
</DialogButton>
<DialogButton strong onClick={() => setConfirmOpened(false)}>
Yes
</DialogButton>
</>
}
/>
<Dialog
opened={listOpened}
onBackdropClick={() => setListOpened(false)}
title="Your super hero"
content={
<List nested className="-mx-4">
<ListItem
label
title="Batman"
after={
<Radio
component="div"
value="batman"
checked={radioValue === 'batman'}
onChange={() => setRadioValue('batman')}
/>
}
/>
<ListItem
label
title="Spider-man"
after={
<Radio
component="div"
value="spiderman"
checked={radioValue === 'spiderman'}
onChange={() => setRadioValue('spiderman')}
/>
}
/>
<ListItem
label
title="Hulk"
after={
<Radio
component="div"
value="hulk"
checked={radioValue === 'hulk'}
onChange={() => setRadioValue('hulk')}
/>
}
/>
</List>
}
buttons={
<DialogButton onClick={() => setListOpened(false)}>
Confirm
</DialogButton>
}
/>
</Page>
);
}
ライセンス MIT.
2022 © Konsta UI by nolimits4web.