包含以下组件
Panel
- 侧边栏元素名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
backdrop | 布尔值 | true | 启用面板背景(面板后面的半透明暗层) |
colors | 对象 | 包含 Tailwind CSS 颜色类别的对象 | |
colors.bg | 字符串 | 'bg-white dark:bg-black' | 面板背景颜色 |
floating | 布尔值 | false | 启用后,打开的面板将在两侧留出额外空间 |
opened | 布尔值 | false | 允许打开/关闭面板并设置其初始状态 |
side | 'left' | 'right' | 'left' | 面板侧边 |
size | 字符串 | 'w-72 h-screen' | Tailwind CSS 尺寸类 |
onBackdropClick | function(e) | 背景元素上的点击处理程序 |
<script>import {Page,Navbar,NavbarBackLink,Panel,Block,BlockTitle,Link,Button,} from 'konsta/svelte';let leftPanelOpened = false;let rightPanelOpened = false;let leftFloatingPanelOpened = false;let rightFloatingPanelOpened = false;</script><Page><Navbar title="Panel / Side Panel" /><Block strongIos outlineIos class="space-y-4"><p>Konsta UI comes with 2 panels (on left and on right), both are optional.You can put absolutely anything inside: data lists, forms, custom content,etc.</p></Block><Block strongIos outlineIos class="flex space-x-4 rtl:space-x-reverse"><Button onClick={() => (leftPanelOpened = true)}>Left Panel</Button><Button onClick={() => (rightPanelOpened = true)}>Right Panel</Button></Block><BlockTitle>Floating Panels</BlockTitle><Block strongIos outlineIos class="flex space-x-4 rtl:space-x-reverse"><Button onClick={() => (leftFloatingPanelOpened = true)}>Left Panel</Button><Button onClick={() => (rightFloatingPanelOpened = true)}>Right Panel</Button></Block><Panelside="left"opened={leftPanelOpened}onBackdropClick={() => (leftPanelOpened = false)}><Page><Navbar title="Left Panel"><Link slot="right" navbar onClick={() => (leftPanelOpened = false)}>Close</Link></Navbar><Block class="space-y-4"><p>Here comes left panel.</p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendissefaucibus mauris leo, eu bibendum neque congue non. Ut leo mauris,eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus,viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatisdignissim. Suspendisse non nisl semper tellus malesuada suscipit eu eteros. Nulla eu enim quis quam elementum vulputate. Mauris ornareconsequat nunc viverra pellentesque. Aenean semper eu massa sit ametaliquam. Integer et neque sed libero mollis elementum at vitae ligula.Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibuslectus.</p></Block></Page></Panel><Panelside="right"opened={rightPanelOpened}onBackdropClick={() => (rightPanelOpened = false)}><Page><Navbar title="Right Panel"><Link slot="right" navbar onClick={() => (rightPanelOpened = false)}>Close</Link></Navbar><Block class="space-y-4"><p>Here comes right panel.</p><p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula.Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh,suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctorvel tristique ac, malesuada ut ante. Sed molestie, est in eleifendsagittis, leo tortor ullamcorper erat, at vulputate eros sapien neclibero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem,suscipit in iaculis id, pharetra at urna. Pellentesque tempor conguemassa quis faucibus. Vestibulum nunc eros, convallis blandit dui sitamet, gravida adipiscing libero.</p></Block></Page></Panel><Panelside="left"floatingopened={leftFloatingPanelOpened}onBackdropClick={() => (leftFloatingPanelOpened = false)}><Page class="no-safe-areas-top no-safe-areas-bottom"><Navbar title="Left Panel"><Linkslot="right"navbaronClick={() => (leftFloatingPanelOpened = false)}>Close</Link></Navbar><Block class="space-y-4"><p>Here comes left panel.</p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendissefaucibus mauris leo, eu bibendum neque congue non. Ut leo mauris,eleifend eu commodo a, egestas ac urna. Maecenas in lacus faucibus,viverra ipsum pulvinar, molestie arcu. Etiam lacinia venenatisdignissim. Suspendisse non nisl semper tellus malesuada suscipit eu eteros. Nulla eu enim quis quam elementum vulputate. Mauris ornareconsequat nunc viverra pellentesque. Aenean semper eu massa sit ametaliquam. Integer et neque sed libero mollis elementum at vitae ligula.Vestibulum pharetra sed libero sed porttitor. Suspendisse a faucibuslectus.</p></Block></Page></Panel><Panelside="right"floatingopened={rightFloatingPanelOpened}onBackdropClick={() => (rightFloatingPanelOpened = false)}><Page className="no-safe-areas-top no-safe-areas-bottom"><Navbar title="Right Panel"><Linkslot="right"navbaronClick={() => (rightFloatingPanelOpened = false)}>Close</Link></Navbar><Block class="space-y-4"><p>Here comes right panel.</p><p>Duis ut mauris sollicitudin, venenatis nisi sed, luctus ligula.Phasellus blandit nisl ut lorem semper pharetra. Nullam tortor nibh,suscipit in consequat vel, feugiat sed quam. Nam risus libero, auctorvel tristique ac, malesuada ut ante. Sed molestie, est in eleifendsagittis, leo tortor ullamcorper erat, at vulputate eros sapien neclibero. Mauris dapibus laoreet nibh quis bibendum. Fusce dolor sem,suscipit in iaculis id, pharetra at urna. Pellentesque tempor conguemassa quis faucibus. Vestibulum nunc eros, convallis blandit dui sitamet, gravida adipiscing libero.</p></Block></Page></Panel></Page>