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

Sheet React 組件

工作表模式是一種特殊的覆蓋類型。這種模式允許使用自訂內容建立自訂選取器覆蓋。

工作表模式元件

包含以下元件

  • Sheet - 工作表模式元素

工作表屬性

名稱類型預設值描述
backdropbooleantrue

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

colorsobject

具有 Tailwind CSS 顏色類別的物件

colors.bgIosstring'bg-white dark:bg-black'
colors.bgMaterialstring'bg-md-light-surface dark:bg-md-dark-surface'
componentstring'div'

元件的 HTML 元素

openedbooleanfalse

允許開啟/關閉工作表模式並設定其初始狀態

onBackdropClickfunction(e)

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

範例

SheetModal.jsx
import React, { useState } from 'react';
import {
Page,
Navbar,
NavbarBackLink,
Sheet,
Block,
Button,
Toolbar,
Link,
} from 'konsta/react';
export default function SheetModalPage() {
const [sheetOpened, setSheetOpened] = useState(false);
return (
<Page>
<Navbar
title="Sheet Modal"
/>
<Block strongIos outlineIos className="space-y-4">
<p>
Sheet Modals slide up from the bottom of the screen to reveal more
content. Such modals allow to create custom overlays with custom
content.
</p>
<p>
<Button onClick={() => setSheetOpened(true)}>Open Sheet</Button>
</p>
</Block>
<Sheet
className="pb-safe"
opened={sheetOpened}
onBackdropClick={() => setSheetOpened(false)}
>
<Toolbar top>
<div className="left" />
<div className="right">
<Link toolbar onClick={() => setSheetOpened(false)}>
Done
</Link>
</div>
</Toolbar>
<Block>
<p>
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Harum ad
excepturi nesciunt nobis aliquam. Quibusdam ducimus neque
necessitatibus, molestias cupiditate velit nihil alias incidunt,
excepturi voluptatem dolore itaque sapiente dolores!
</p>
<div className="mt-4">
<Button onClick={() => setSheetOpened(false)}>Action</Button>
</div>
</Block>
</Sheet>
</Page>
);
}
程式碼授權使用 MIT.
2022 © Konsta UI by nolimits4web.