操作表單是一個向上滑出的窗格,用於向用戶呈現一組關於如何處理給定任務的替代方案。
您也可以使用操作表單來提示用戶確認可能具有危險性的操作。
操作表單包含一個可選的標題和一個或多個按鈕,每個按鈕對應一個要執行的操作。
包括以下組件
Actions
ActionsButton
ActionsLabel
ActionsGroup
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
backdrop | 布林值 | true | 啟用操作表單背景(後面的深色半透明層) |
opened | 布林值 | false | 允許開啟/關閉操作表單並設定其初始狀態 |
onBackdropClick | function(e) | 背景元素上的點擊處理程序 |
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
bold | 布林值 | 未定義 | 使按鈕文字變粗。覆寫 |
boldIos | 布林值 | false | 在 iOS 主題中使按鈕文字變粗 |
boldMaterial | 布林值 | false | 在 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 | 字串 | 'bg-md-light-surface-3 dark:bg-md-dark-surface-3' | |
colors.textIos | 字串 | 'text-primary' | |
colors.textMaterial | 字串 | 'text-md-light-on-surface dark:text-md-dark-on-surface' | |
dividers | 布林值 | 未定義 | 呈現按鈕外部細線(邊框)。如果未指定,則會在 iOS 主題中啟用 |
fontSizeIos | 字串 | 'text-xl' | iOS 主題中的按鈕文字字體大小 |
fontSizeMaterial | 字串 | 'text-base' | Material 主題中的按鈕文字字體大小 |
href | 字串 | 連結的 | |
touchRipple | 布林值 | true | 在 Material 主題中啟用觸摸漣漪效果 |
onClick | function(e) |
|
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
colors | 物件 | 具有 Tailwind CSS 顏色類別的物件 | |
colors.bgIos | 字串 | 'bg-white dark:bg-neutral-800' | |
colors.bgMaterial | 字串 | 'bg-md-light-surface-3 dark:bg-md-dark-surface-3' | |
colors.textIos | 字串 | 'text-black text-opacity-55 dark:text-white dark:text-opacity-55' | |
colors.textMaterial | 字串 | 'text-md-light-primary dark:text-md-dark-primary' | |
dividers | 布林值 | 未定義 | 呈現按鈕外部細線(邊框)。如果未指定,則會在 iOS 主題中啟用 |
fontSizeIos | 字串 | 'text-sm' | iOS 主題中的按鈕文字字體大小 |
fontSizeMaterial | 字串 | 'text-sm' | Material 主題中的按鈕文字字體大小 |
名稱 | 類型 | 預設值 | 描述 |
---|---|---|---|
dividers | 布林值 | true | 呈現群組外部細線(邊框)。(僅在 Material 主題中) |
<script>import {Page,Navbar,NavbarBackLink,BlockTitle,Block,Button,Actions,ActionsButton,ActionsLabel,ActionsGroup,} from 'konsta/svelte';let actionsOneOpened = false;let actionsTwoOpened = false;</script><Page><Navbar title="Action Sheet" /><Block strong inset class="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 class="flex space-x-4 rtl:space-x-reverse"><Button onClick={() => (actionsOneOpened = true)}>One group</Button><Button onClick={() => (actionsTwoOpened = true)}>Two groups</Button></Block><Actionsopened={actionsOneOpened}onBackdropClick={() => (actionsOneOpened = false)}><ActionsGroup><ActionsLabel>Do something</ActionsLabel><ActionsButton onClick={() => (actionsOneOpened = false)} bold>Button 1</ActionsButton><ActionsButton onClick={() => (actionsOneOpened = false)}>Button 2</ActionsButton><ActionsButton onClick={() => (actionsOneOpened = false)}>Cancel</ActionsButton></ActionsGroup></Actions><Actionsopened={actionsTwoOpened}onBackdropClick={() => (actionsTwoOpened = false)}><ActionsGroup><ActionsLabel>Do something</ActionsLabel><ActionsButton onClick={() => (actionsTwoOpened = false)} bold>Button 1</ActionsButton><ActionsButton onClick={() => (actionsTwoOpened = false)}>Button 2</ActionsButton></ActionsGroup><ActionsGroup><ActionsButton onClick={() => (actionsTwoOpened = false)}>Cancel</ActionsButton></ActionsGroup></Actions></Page>