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

操作表單 Svelte 組件

操作表單是一個向上滑出的窗格,用於向用戶呈現一組關於如何處理給定任務的替代方案。

您也可以使用操作表單來提示用戶確認可能具有危險性的操作。

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

操作表單組件

包括以下組件

  • Actions
  • ActionsButton
  • ActionsLabel
  • ActionsGroup

Actions Props

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

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

opened布林值false

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

onBackdropClickfunction(e)

背景元素上的點擊處理程序

ActionsButton Props

名稱類型預設值描述
bold布林值未定義

使按鈕文字變粗。覆寫 boldIosboldMaterial

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字串

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

touchRipple布林值true

在 Material 主題中啟用觸摸漣漪效果

onClickfunction(e)

click 事件處理程序

ActionsLabel Props

名稱類型預設值描述
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 主題中的按鈕文字字體大小

ActionsGroup Props

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

呈現群組外部細線(邊框)。(僅在 Material 主題中)

範例

ActionSheet.svelte
<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 of
alternatives 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>
<Actions
opened={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>
<Actions
opened={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>
程式碼授權依據 MIT.
2022 © Konsta UI by nolimits4web.