🔥 遇见我们的新项目 t0ggles - 你终极的项目管理工具! 🔥

面板 Vue 组件

面板组件

包含以下组件

  • Panel - 侧面板元素

面板道具

名称类型默认值描述
backdrop布尔值true

启用面板背景(面板后面的半透明暗层)

colors对象

包含 Tailwind CSS 颜色类的对象

colors.bg字符串'bg-white dark:bg-black'

面板背景颜色

component字符串'div'

组件的 HTML 元素

floating布尔值false

启用后,打开的面板将在两侧留出额外的空间

opened布尔值false

允许打开/关闭面板并设置其初始状态

side'left' | 'right''left'

面板侧边

size字符串'w-72 h-screen'

Tailwind CSS 大小类

面板事件

名称类型描述
backdropclickfunction(e)

在背景元素上的点击处理程序

例子

SidePanels.vue
<template>
<k-page>
<k-navbar title="Panel / Side Panel" />
<k-block strong-ios outline-ios 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>
</k-block>
<k-block strong-ios outline-ios class="flex space-x-4 rtl:space-x-reverse">
<k-button @click="() => (leftPanelOpened = true)">Left Panel</k-button>
<k-button @click="() => (rightPanelOpened = true)">Right Panel</k-button>
</k-block>
<k-block-title>Floating Panels</k-block-title>
<k-block strong-ios outline-ios class="flex space-x-4 rtl:space-x-reverse">
<k-button @click="() => (leftFloatingPanelOpened = true)"
>Left Panel</k-button
>
<k-button @click="() => (rightFloatingPanelOpened = true)"
>Right Panel</k-button
>
</k-block>
<k-panel
side="left"
:opened="leftPanelOpened"
@backdropclick="() => (leftPanelOpened = false)"
>
<k-page>
<k-navbar title="Left Panel">
<template #right>
<k-link navbar @click="() => (leftPanelOpened = false)">
Close
</k-link>
</template>
</k-navbar>
<k-block class="space-y-4">
<p>Here comes left panel.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
faucibus 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 venenatis
dignissim. Suspendisse non nisl semper tellus malesuada suscipit eu
et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare
consequat nunc viverra pellentesque. Aenean semper eu massa sit amet
aliquam. Integer et neque sed libero mollis elementum at vitae
ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a
faucibus lectus.
</p>
</k-block>
</k-page>
</k-panel>
<k-panel
side="right"
:opened="rightPanelOpened"
@backdropclick="() => (rightPanelOpened = false)"
>
<k-page>
<k-navbar title="Right Panel">
<template #right>
<k-link navbar @click="() => (rightPanelOpened = false)">
Close
</k-link>
</template>
</k-navbar>
<k-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,
auctor vel tristique ac, malesuada ut ante. Sed molestie, est in
eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros
sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce
dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque
tempor congue massa quis faucibus. Vestibulum nunc eros, convallis
blandit dui sit amet, gravida adipiscing libero.
</p>
</k-block>
</k-page>
</k-panel>
<k-panel
side="left"
floating
:opened="leftFloatingPanelOpened"
@backdropclick="() => (leftFloatingPanelOpened = false)"
>
<k-page class="no-safe-areas-top no-safe-areas-bottom">
<k-navbar title="Left Panel">
<template #right>
<k-link navbar @click="() => (leftFloatingPanelOpened = false)">
Close
</k-link>
</template>
</k-navbar>
<k-block class="space-y-4">
<p>Here comes left panel.</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
faucibus 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 venenatis
dignissim. Suspendisse non nisl semper tellus malesuada suscipit eu
et eros. Nulla eu enim quis quam elementum vulputate. Mauris ornare
consequat nunc viverra pellentesque. Aenean semper eu massa sit amet
aliquam. Integer et neque sed libero mollis elementum at vitae
ligula. Vestibulum pharetra sed libero sed porttitor. Suspendisse a
faucibus lectus.
</p>
</k-block>
</k-page>
</k-panel>
<k-panel
side="right"
floating
:opened="rightFloatingPanelOpened"
@backdropclick="() => (rightFloatingPanelOpened = false)"
>
<k-page class="no-safe-areas-top no-safe-areas-bottom">
<k-navbar title="Right Panel">
<template #right>
<k-link navbar @click="() => (rightFloatingPanelOpened = false)">
Close
</k-link>
</template>
</k-navbar>
<k-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,
auctor vel tristique ac, malesuada ut ante. Sed molestie, est in
eleifend sagittis, leo tortor ullamcorper erat, at vulputate eros
sapien nec libero. Mauris dapibus laoreet nibh quis bibendum. Fusce
dolor sem, suscipit in iaculis id, pharetra at urna. Pellentesque
tempor congue massa quis faucibus. Vestibulum nunc eros, convallis
blandit dui sit amet, gravida adipiscing libero.
</p>
</k-block>
</k-page>
</k-panel>
</k-page>
</template>
<script>
import { ref } from 'vue';
import {
kPage,
kNavbar,
kNavbarBackLink,
kPanel,
kBlock,
kBlockTitle,
kLink,
kButton,
} from 'konsta/vue';
export default {
components: {
kPage,
kNavbar,
kNavbarBackLink,
kPanel,
kBlock,
kBlockTitle,
kLink,
kButton,
},
setup() {
const leftPanelOpened = ref(false);
const rightPanelOpened = ref(false);
const leftFloatingPanelOpened = ref(false);
const rightFloatingPanelOpened = ref(false);
return {
leftPanelOpened,
rightPanelOpened,
leftFloatingPanelOpened,
rightFloatingPanelOpened,
};
},
};
</script>
代码许可证 MIT.
2022 © Konsta UI 由 nolimits4web.