wt-navigation-rail.vue β
ΠΠ΅ΡΡΠΈΠΊΠ°Π»ΡΠ½Π° Π½Π°Π²ΡΠ³Π°ΡΡΠΉΠ½Π° ΠΏΠ°Π½Π΅Π»Ρ ΡΠ· ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ Π·Π²Π΅ΡΡ
Ρ ΡΠ° Π·Π½ΠΈΠ·Ρ. ΠΠ΅ ΠΌΡΡΡΠΈΡΡ Π»ΠΎΠ³ΡΠΊΠΈ Π½Π°Π²ΡΠ³Π°ΡΡΡ: ΠΏΡΠΈ ΠΊΠ»ΡΠΊΡ Π΅ΠΌΡΡΠΈΡΡ select, Π° Π°ΠΏΠ»ΡΠΊΠ΅ΠΉΡΠ½ Π²ΠΈΡΡΡΡΡ, ΡΠΎ ΡΠΎΠ±ΠΈΡΠΈ.
ΠΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ Π½Π΅ Π²ΠΈΠΊΠΎΡΠΈΡΡΠΎΠ²ΡΡΡΡΡΡ Π½Π°ΠΏΡΡΠΌΡ: ΠΉΠΎΠ³ΠΎ ΡΠ΅Π½Π΄Π΅ΡΠΈΡΡ wt-page Π· ΠΏΡΠΎΠΏΠ° navigationRail ({ topItems, bottomItems, activeItemId }), Π° ΠΏΠΎΠ΄ΡΡ select Π²ΡΠ½ ΡΠ΅ΡΡΠ°Π½ΡΠ»ΡΡ ΡΠΊ navigation-select. ΠΠ°Π½Π΅Π»Ρ Π²ΡΠ΄ΠΎΠ±ΡΠ°ΠΆΠ°ΡΡΡΡΡ, Π»ΠΈΡΠ΅ ΡΠΊΡΠΎ Ρ
ΠΎΡΠ° Π± ΠΎΠ΄ΠΈΠ½ Π·Ρ ΡΠΏΠΈΡΠΊΡΠ² Π½Π΅ ΠΏΠΎΡΠΎΠΆΠ½ΡΠΉ; ΡΠΊΡΠΎ ΠΎΠ±ΠΈΠ΄Π²Π° ΠΏΠΎΡΠΎΠΆΠ½Ρ, Π½ΡΡΠΎΠ³ΠΎ Π½Π΅ ΡΠ΅Π½Π΄Π΅ΡΠΈΡΡΡΡ.
<wt-page
:navigation-rail="{ topItems: top, bottomItems: bottom, activeItemId: active }"
@navigation-select="active = $event.id"
>
<wt-layout>
<wt-content-wrapper>...</wt-content-wrapper>
</wt-layout>
</wt-page>Specs β
Props
| Name | Required | Types | Default | Description | Example | Deprecated |
|---|---|---|---|---|---|---|
topItems |
Array |
() => [] |
Buttons pinned to the top | |||
bottomItems |
Array |
() => [] |
Buttons pinned to the bottom | |||
activeItemId |
string |
'' |
Id of the active item |
Events
| Name | Params | Description |
|---|---|---|
select |
Fires on click of enabled item |
Item β
NavigationRailItem: { id, icon, label?, disabled?, badge?: { value, severity? } }.
badgeΠΌΠ°Π»ΡΡ Π±Π΅ΠΉΠ΄ΠΆ Π½Π°Π΄ ΠΊΠ½ΠΎΠΏΠΊΠΎΡ;severityΠ·Π° Π·Π°ΠΌΠΎΠ²ΡΡΠ²Π°Π½Π½ΡΠΌsuccess(Π½Π°ΠΏΡ.errorΠ΄Π»Ρ ΠΏΡΠΎΠΏΡΡΠ΅Π½ΠΈΡ Π΄Π·Π²ΡΠ½ΠΊΡΠ²).- Π‘ΡΠ°Π½ΠΈ ΠΊΠ½ΠΎΠΏΠΊΠΈ: default, hover, active (
activeItemId=idΠ°ΠΊΡΠΈΠ²Π½ΠΎΡ ΠΊΠ½ΠΎΠΏΠΊΠΈ). - ΠΡΠ°Π΄ΡΡΠ½Ρ ΡΠΎΠ½Ρ Π·Π°Π»Π΅ΠΆΠΈΡΡ Π²ΡΠ΄ ΡΠ΅ΠΌΠΈ (
:root.theme--dark).
CSS variables β
ΠΠΈΠ². src/components/wt-navigation-rail/_variables.css.
Example β
Last select event: β
Last select event: β
Code
<script setup>
import { computed, ref } from 'vue';
const active = ref('calls');
const lastSelected = ref('');
const showItems = ref(true);
const topList = [
{
id: 'calls',
icon: 'call',
label: 'Calls',
badge: {
value: 1,
severity: 'error',
},
},
{
id: 'chats',
icon: 'chat',
label: 'Chats',
badge: {
value: 3,
},
},
{
id: 'comments',
icon: 'comment',
label: 'Comments',
},
{
id: 'emails',
icon: 'email',
label: 'Emails',
},
];
const bottomList = [
{
id: 'docs',
icon: 'docs',
label: 'Knowledge base',
},
{
id: 'contacts',
icon: 'contacts',
label: 'Contacts',
},
{
id: 'history',
icon: 'history',
label: 'History',
disabled: true,
},
];
// rail is hidden when both lists are empty
const top = computed(() => (showItems.value ? topList : []));
const bottom = computed(() => (showItems.value ? bottomList : []));
</script>
<template>
<div style="display: flex; flex-direction: column; gap: 16px">
<wt-checkbox v-model:selected="showItems" label="Show navigation items" />
<div
v-for="theme of ['', 'theme--dark']"
:key="theme"
:class="theme"
style="height: 360px"
>
<wt-page
:navigation-rail="{ topItems: top, bottomItems: bottom, activeItemId: active }"
@navigation-select="active = lastSelected = $event.id"
>
<wt-layout>
<wt-content-wrapper>
Active: {{ active }}<br />
Last select event: {{ lastSelected || 'β' }}
</wt-content-wrapper>
</wt-layout>
</wt-page>
</div>
</div>
</template>