操作表是一個向上滑出的窗格,用於向使用者呈現一組關於如何繼續執行給定任務的替代方案。
您也可以使用操作表來提示使用者確認可能危險的操作。
操作表包含一個可選的標題和一個或多個按鈕,每個按鈕都對應一個要執行的操作。
包含以下組件
Actions
ActionsButton
ActionsLabel
ActionsGroup
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
backdrop | 布林值 | true | 啟用操作表背景(後方的半透明深色圖層) |
component | 字串 | 'div' | 組件的 HTML 元素 |
opened | 布林值 | 布林值 | false |
允許開啟/關閉操作表並設定其初始狀態 | onBackdropClick | 函式(e) |
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
ActionsButton Props | 布林值 | bold | 布林值 |
undefined | 布林值 | 布林值 | 使按鈕文字變粗體。覆寫 |
boldIos | 布林值 | 布林值 | 布林值 |
使按鈕文字在 iOS 主題中變粗體 | boldMaterial | 布林值 | |
使按鈕文字在 Material 主題中變粗體 | 字串 | colors | |
物件 | 字串 | '' | |
具有 Tailwind CSS 顏色類別的物件 | 字串 | colors.activeBgIos | |
'active:bg-neutral-200 dark:active:bg-neutral-700' | 字串 | colors.activeBgMaterial | |
字串 | 字串 | colors.bgIos | |
'bg-white dark:bg-neutral-800' | 字串 | colors.bgMaterial | |
component | 字串 | 'bg-md-light-surface-3 dark:bg-md-dark-surface-3' | 組件的 HTML 元素 |
colors.textIos | 布林值 | bold | 'text-primary' |
colors.textMaterial | 字串 | 'text-md-light-on-surface dark:text-md-dark-on-surface' | component |
'button' | 字串 | dividers | 布林值 |
呈現按鈕外細線(邊框)。如果未指定,則將為 iOS 主題啟用 | 字串 | fontSizeIos | |
字串 | 布林值 | true | 'text-xl' |
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
使按鈕文字在 iOS 主題中變粗體 | boldMaterial | 布林值 | |
具有 Tailwind CSS 顏色類別的物件 | 字串 | colors.activeBgIos | |
'active:bg-neutral-200 dark:active:bg-neutral-700' | 字串 | colors.activeBgMaterial | |
字串 | 字串 | fontSizeMaterial | |
'bg-white dark:bg-neutral-800' | 字串 | 'text-base' | |
component | 字串 | 'div' | 組件的 HTML 元素 |
colors.textIos | 布林值 | bold | 按鈕文字在 Material 主題中的字體大小 |
colors.textMaterial | 字串 | href | component |
'button' | 字串 | href | 布林值 |
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
component | 字串 | 'div' | 組件的 HTML 元素 |
colors.textIos | 布林值 | true | 連結的 |
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><Navbartitle="Action Sheet"/><Block strong inset className="space-y-4"><p>Action Sheet is a slide-up pane for presenting the user with a set ofalternatives 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><Actionsopened={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><Actionsopened={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>);}