Skip to content

wt-navigation-rail.vue ​

Π’Π΅Ρ€Ρ‚ΠΈΠΊΠ°Π»ΡŒΠ½Π° Π½Π°Π²Ρ–Π³Π°Ρ†Ρ–ΠΉΠ½Π° панСль Ρ–Π· ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌΠΈ Π·Π²Π΅Ρ€Ρ…Ρƒ Ρ‚Π° Π·Π½ΠΈΠ·Ρƒ. НС ΠΌΡ–ΡΡ‚ΠΈΡ‚ΡŒ Π»ΠΎΠ³Ρ–ΠΊΠΈ Π½Π°Π²Ρ–Π³Π°Ρ†Ρ–Ρ—: ΠΏΡ€ΠΈ ΠΊΠ»Ρ–ΠΊΡƒ Π΅ΠΌΡ–Ρ‚ΠΈΡ‚ΡŒ select, Π° Π°ΠΏΠ»Ρ–ΠΊΠ΅ΠΉΡˆΠ½ Π²ΠΈΡ€Ρ–ΡˆΡƒΡ”, Ρ‰ΠΎ Ρ€ΠΎΠ±ΠΈΡ‚ΠΈ.

ΠšΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ Π½Π΅ Π²ΠΈΠΊΠΎΡ€ΠΈΡΡ‚ΠΎΠ²ΡƒΡ”Ρ‚ΡŒΡΡ напряму: ΠΉΠΎΠ³ΠΎ Ρ€Π΅Π½Π΄Π΅Ρ€ΠΈΡ‚ΡŒ wt-page Π· ΠΏΡ€ΠΎΠΏΠ° navigationRail ({ topItems, bottomItems, activeItemId }), Π° ΠΏΠΎΠ΄Ρ–ΡŽ select Π²Ρ–Π½ Ρ€Π΅Ρ‚Ρ€Π°Π½ΡΠ»ΡŽΡ” як navigation-select. ПанСль Π²Ρ–Π΄ΠΎΠ±Ρ€Π°ΠΆΠ°Ρ”Ρ‚ΡŒΡΡ, лишС якщо Ρ…ΠΎΡ‡Π° Π± ΠΎΠ΄ΠΈΠ½ Π·Ρ– списків Π½Π΅ ΠΏΠΎΡ€ΠΎΠΆΠ½Ρ–ΠΉ; якщо ΠΎΠ±ΠΈΠ΄Π²Π° ΠΏΠΎΡ€ΠΎΠΆΠ½Ρ–, Π½Ρ–Ρ‡ΠΎΠ³ΠΎ Π½Π΅ Ρ€Π΅Π½Π΄Π΅Ρ€ΠΈΡ‚ΡŒΡΡ.

vue
<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 ​

Active: calls
Last select event: β€”
Active: calls
Last select event: β€”
Code
vue
<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>