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

アクションシート React コンポーネント

アクションシートは、特定のタスクをどのように進めるかについて、ユーザーに選択肢を提示するためのスライドアップペインです。

アクションシートを使用して、ユーザーに潜在的に危険なアクションの確認を求めることもできます。

アクションシートには、オプションのタイトルと1つ以上のボタンが含まれており、それぞれが実行するアクションに対応しています。

アクションシートコンポーネント

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

  • Actions
  • ActionsButton
  • ActionsLabel
  • ActionsGroup

Actions プロパティ

名前タイプデフォルト説明
backdropbooleantrue

アクションシートのバックドロップ(背後にある暗い半透明レイヤー)を有効にします

componentstring'div'

コンポーネントのHTML要素

openedbooleanfalse

アクションシートを開閉し、初期状態を設定できます

onBackdropClickfunction(e)

バックドロップ要素のクリックハンドラー

ActionsButton プロパティ

名前タイプデフォルト説明
boldbooleanundefined

ボタンのテキストを太字にします。 boldIosboldMaterial を上書きします

boldIosbooleanfalse

iOSテーマでボタンのテキストを太字にします

boldMaterialbooleanfalse

マテリアルテーマでボタンのテキストを太字にします

colorsobject

Tailwind CSSカラースタイルクラスを持つオブジェクト

colors.activeBgIosstring'active:bg-neutral-200 dark:active:bg-neutral-700'
colors.activeBgMaterialstring''
colors.bgIosstring'bg-white dark:bg-neutral-800'
colors.bgMaterialstring'bg-md-light-surface-3 dark:bg-md-dark-surface-3'
colors.textIosstring'text-primary'
colors.textMaterialstring'text-md-light-on-surface dark:text-md-dark-on-surface'
componentstring'button'

コンポーネントのHTML要素

dividersbooleanundefined

ボタンの外側のヘアライン(境界線)をレンダリングします。指定しない場合、iOSテーマで有効になります

fontSizeIosstring'text-xl'

iOSテーマのボタンテキストのフォントサイズ

fontSizeMaterialstring'text-base'

マテリアルテーマのボタンテキストのフォントサイズ

hrefstring

リンクのhref属性。指定すると、<a>要素としてもレンダリングされます

touchRipplebooleantrue

マテリアルテーマでタッチリップル効果を有効にします

ActionsLabel プロパティ

名前タイプデフォルト説明
colorsobject

Tailwind CSSカラースタイルクラスを持つオブジェクト

colors.bgIosstring'bg-white dark:bg-neutral-800'
colors.bgMaterialstring'bg-md-light-surface-3 dark:bg-md-dark-surface-3'
colors.textIosstring'text-black text-opacity-55 dark:text-white dark:text-opacity-55'
colors.textMaterialstring'text-md-light-primary dark:text-md-dark-primary'
componentstring'div'

コンポーネントのHTML要素

dividersbooleanundefined

ボタンの外側のヘアライン(境界線)をレンダリングします。指定しない場合、iOSテーマで有効になります

fontSizeIosstring'text-sm'

iOSテーマのボタンテキストのフォントサイズ

fontSizeMaterialstring'text-sm'

マテリアルテーマのボタンテキストのフォントサイズ

ActionsGroup プロパティ

名前タイプデフォルト説明
componentstring'div'

コンポーネントのHTML要素

dividersbooleantrue

グループの外側のヘアライン(境界線)をレンダリングします。(マテリアルテーマのみ)

ActionSheet.jsx
import React, { useState } from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Button,
Block,
BlockTitle,
Actions,
ActionsGroup,
ActionsLabel,
ActionsButton,
} from 'konsta/react';
export default function ActionSheetPage() {
const isPreview = document.location.href.includes('examplePreview');
const [actionsOneOpened, setActionsOneOpened] = useState(false);
const [actionsTwoOpened, setActionsTwoOpened] = useState(false);
return (
<Page>
<Navbar
title="Action Sheet"
/>
<Block strong inset className="space-y-4">
<p>
Action Sheet is a slide-up pane for presenting the user with a set of
alternatives for how to proceed with a given task.
</p>
</Block>
<BlockTitle>Open Action Sheet</BlockTitle>
<Block strong inset className="flex space-x-4 rtl:space-x-reverse">
<Button onClick={() => setActionsOneOpened(true)}>One group</Button>
<Button onClick={() => setActionsTwoOpened(true)}>Two groups</Button>
</Block>
<Actions
opened={actionsOneOpened}
onBackdropClick={() => setActionsOneOpened(false)}
>
<ActionsGroup>
<ActionsLabel>Do something</ActionsLabel>
<ActionsButton onClick={() => setActionsOneOpened(false)} bold>
Button 1
</ActionsButton>
<ActionsButton onClick={() => setActionsOneOpened(false)}>
Button 2
</ActionsButton>
<ActionsButton onClick={() => setActionsOneOpened(false)}>
Cancel
</ActionsButton>
</ActionsGroup>
</Actions>
<Actions
opened={actionsTwoOpened}
onBackdropClick={() => setActionsTwoOpened(false)}
>
<ActionsGroup>
<ActionsLabel>Do something</ActionsLabel>
<ActionsButton onClick={() => setActionsTwoOpened(false)} bold>
Button 1
</ActionsButton>
<ActionsButton onClick={() => setActionsTwoOpened(false)}>
Button 2
</ActionsButton>
</ActionsGroup>
<ActionsGroup>
<ActionsButton onClick={() => setActionsTwoOpened(false)}>
Cancel
</ActionsButton>
</ActionsGroup>
</Actions>
</Page>
);
}
コードライセンス MIT.
2022 © Konsta UI by nolimits4web.