🔥 認識我們的新專案 t0ggles - 您終極的專案管理工具! 🔥

操作表 React 組件

操作表是一個向上滑出的窗格,用於向使用者呈現一組關於如何繼續執行給定任務的替代方案。

您也可以使用操作表來提示使用者確認可能危險的操作。

操作表包含一個可選的標題和一個或多個按鈕,每個按鈕都對應一個要執行的操作。

操作表組件

包含以下組件

  • Actions
  • ActionsButton
  • ActionsLabel
  • ActionsGroup

Actions Props

名稱類型預設值描述
backdrop布林值true

啟用操作表背景(後方的半透明深色圖層)

component字串'div'

組件的 HTML 元素

opened布林值布林值

false

允許開啟/關閉操作表並設定其初始狀態onBackdropClick

函式(e)

點擊背景元素時的處理常式

名稱類型預設值描述
ActionsButton Props布林值bold

布林值

undefined布林值布林值

使按鈕文字變粗體。覆寫 boldIosboldMaterial

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 主題中的字體大小

名稱類型預設值描述
使按鈕文字在 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

連結的 href 屬性,當指定時也會呈現為 <a> 元素

touchRipple

布林值
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>
);
}