Layout
Каркас экрана приложения с боковым меню и верхней панелью.
Два заказа ждут оплаты, три едут к покупателям.
<template> <div class="w-full h-96 overflow-hidden rounded-lg border"> <NuiLayout v-model:open="open" content-as="div" :shortcut="false" class="h-full"> <template #sidebar> <NuiSidebar collapsible="icon" label="Разделы кабинета"> <NuiSidebarContent> <NuiSidebarGroup> <NuiSidebarItem v-for="section in sections" :key="section.key" :label="section.label" :icon="section.icon" :badge="section.badge" :current="active === section.key" @click="active = section.key" /> </NuiSidebarGroup> </NuiSidebarContent> <NuiSidebarFooter> <NuiSidebarGroup> <NuiSidebarItem :label="manager.name" icon="user" /> </NuiSidebarGroup> </NuiSidebarFooter> </NuiSidebar> </template> <template #header> <NuiAppBar> <template #start> <NuiSidebarTrigger /> </template> {{ current.label }} </NuiAppBar> </template> <p class="m-0 px-layout-gutter py-6">{{ current.summary }}</p> </NuiLayout> </div></template><script setup lang="ts">import { computed, ref, type Component } from 'vue';import { ChartColumn, Package, ShoppingCart, Users, Warehouse } from '@lucide/vue';import { NuiAppBar, NuiLayout, NuiSidebar, NuiSidebarContent, NuiSidebarFooter, NuiSidebarGroup, NuiSidebarItem, NuiSidebarTrigger,} from '@numior/kit';import { team } from './team';interface Section { readonly key: string; readonly label: string; readonly icon: Component; readonly summary: string; readonly badge?: number;}const sections: readonly [Section, ...Section[]] = [ { key: 'orders', label: 'Заказы', icon: ShoppingCart, summary: 'Два заказа ждут оплаты, три едут к покупателям.', badge: 2, }, { key: 'products', label: 'Товары', icon: Package, summary: 'Табурет «Лофт» закончился, комодов «Фьорд» осталось четыре.', }, { key: 'customers', label: 'Клиенты', icon: Users, summary: 'Пётр Волков оформил 14 заказов, больше всех.', }, { key: 'warehouse', label: 'Склад', icon: Warehouse, summary: 'Игорь Белов собирает заказы 20409 и 20410.', }, { key: 'reports', label: 'Отчёты', icon: ChartColumn, summary: 'Отчёт по продажам за сентябрь готов.', },];const [manager] = team;const open = ref(true);const active = ref('orders');const current = computed( () => sections.find((section) => section.key === active.value) ?? sections[0],);</script>export interface Employee { readonly id: string; readonly name: string; readonly role: string; readonly email: string;}export const team: readonly [Employee, Employee, Employee, Employee, Employee] = [ { id: 'anna', name: 'Анна Титова', role: 'Менеджер заказов', email: 'anna@example.com' }, { id: 'igor', name: 'Игорь Белов', role: 'Кладовщик', email: 'igor@example.com' }, { id: 'maria', name: 'Мария Ким', role: 'Поддержка', email: 'maria@example.com' }, { id: 'oleg', name: 'Олег Смирнов', role: 'Закупки', email: 'oleg@example.com' }, { id: 'dina', name: 'Дина Ахметова', role: 'Маркетинг', email: 'dina@example.com' },];Положите Sidebar в слот sidebar, а NuiAppBar — в слот header. v-model:open хранит, раскрыто ли меню на широком экране, а v-model:mobileOpen — открыто ли оно на телефоне.
Установка
import { NuiAppBar, NuiLayout } from '@numior/kit';Примеры
Растянуть панель на всю ширину
Задайте header="full".
Заказ 20408
Состав
Комод «Фьорд» × 1, 21 900 ₽
Лампа «Нурд» × 1, 4 900 ₽
Доставка
Курьер, Москва, получит Павел Соколов.
Курьер позвонит за час до приезда.
Оплата
Картой, 26 800 ₽.
Чек отправлен покупателю на почту.
История
Оформлен 23 сентября, заказ ведёт Анна Титова.
<template> <div class="w-full h-96 overflow-hidden rounded-lg border"> <NuiLayout v-model:open="open" content-as="div" header="full" sidebar-width="12rem" end-width="10rem" :shortcut="false" class="h-full" > <template #header> <NuiAppBar> <template #start> <NuiSidebarTrigger /> </template> Кабинет магазина </NuiAppBar> </template> <template #sidebar> <NuiSidebar label="Заказы в доставке"> <NuiSidebarContent> <NuiSidebarGroup label="В доставке"> <NuiSidebarItem v-for="entry in shipped" :key="entry.id" :label="`Заказ ${entry.id}`" :current="active === entry.id" @click="active = entry.id" /> </NuiSidebarGroup> </NuiSidebarContent> </NuiSidebar> </template> <div ref="article" class="flex h-full flex-col gap-2 overflow-auto p-6" tabindex="0"> <template v-if="order"> <h2 class="m-0 text-lg font-semibold">Заказ {{ order.id }}</h2> <h3 id="layout-order-items" class="mb-0 mt-3 text-base font-semibold">Состав</h3> <p v-for="line in order.lines" :key="line.sku" class="m-0"> {{ line.name }} × {{ line.quantity }}, {{ money.format(line.price * line.quantity) }} </p> <h3 id="layout-order-delivery" class="mb-0 mt-3 text-base font-semibold">Доставка</h3> <p class="m-0"> {{ DELIVERIES[order.delivery] }}, {{ order.city }}, получит {{ order.customer }}. </p> <p class="m-0">Курьер позвонит за час до приезда.</p> <h3 id="layout-order-payment" class="mb-0 mt-3 text-base font-semibold">Оплата</h3> <p class="m-0">{{ PAYMENTS[order.payment] }}, {{ money.format(order.total) }}.</p> <p class="m-0">Чек отправлен покупателю на почту.</p> <h3 id="layout-order-history" class="mb-0 mt-3 text-base font-semibold">История</h3> <p class="m-0"> Оформлен {{ dayFormat.format(new Date(order.date)) }}, заказ ведёт {{ order.manager }}. </p> </template> </div> <template #end> <div class="p-4"> <NuiToc :items="toc" :root="article" title="На странице" /> </div> </template> </NuiLayout> </div></template><script setup lang="ts">import { computed, ref, useTemplateRef } from 'vue';import { NuiAppBar, NuiLayout, NuiSidebar, NuiSidebarContent, NuiSidebarGroup, NuiSidebarItem, NuiSidebarTrigger, NuiToc, type NuiTocItem,} from '@numior/kit';import { DELIVERIES, PAYMENTS, orders } from './orders';const money = new Intl.NumberFormat('ru-RU', { style: 'currency', currency: 'RUB', maximumFractionDigits: 0,});const dayFormat = new Intl.DateTimeFormat('ru-RU', { day: 'numeric', month: 'long', timeZone: 'UTC',});const toc: readonly NuiTocItem[] = [ { id: 'layout-order-items', label: 'Состав' }, { id: 'layout-order-delivery', label: 'Доставка' }, { id: 'layout-order-payment', label: 'Оплата' }, { id: 'layout-order-history', label: 'История' },];const shipped = orders.filter((entry) => entry.status === 'shipped');const article = useTemplateRef<HTMLElement>('article');const open = ref(true);const active = ref(20408);const order = computed(() => shipped.find((entry) => entry.id === active.value));</script>export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Ждёт оплаты', paid: 'Оплачен', shipped: 'В доставке', delivered: 'Доставлен', cancelled: 'Отменён',};export const PAYMENTS: Record<Payment, string> = { card: 'Картой', transfer: 'Переводом', cash: 'При получении',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Курьер', pickup: 'Самовывоз', post: 'Почта',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Пётр Волков', city: 'Москва', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Анна Титова', total: 22700, lines: [ { sku: 'S-101', name: 'Кресло «Осло»', quantity: 1, price: 18900 }, { sku: 'X-507', name: 'Подушка «Лён»', quantity: 2, price: 1900 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Лена Орлова', city: 'Санкт-Петербург', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Анна Титова', total: 9800, lines: [{ sku: 'L-401', name: 'Лампа «Нурд»', quantity: 2, price: 4900 }], }, { id: 20403, date: '2026-09-18', customer: 'Тимур Саидов', city: 'Казань', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Мария Ким', total: 37300, lines: [ { sku: 'T-201', name: 'Стол «Мальмё»', quantity: 1, price: 24500 }, { sku: 'S-104', name: 'Стул «Берген»', quantity: 2, price: 6400 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Вера Лапина', city: 'Москва', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Анна Титова', total: 12800, lines: [{ sku: 'S-110', name: 'Табурет «Лофт»', quantity: 4, price: 3200 }], }, { id: 20405, date: '2026-09-20', customer: 'Глеб Носов', city: 'Екатеринбург', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Мария Ким', total: 11500, lines: [ { sku: 'X-501', name: 'Плед «Шерсть»', quantity: 1, price: 3900 }, { sku: 'X-507', name: 'Подушка «Лён»', quantity: 4, price: 1900 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Иван Попов', city: 'Новосибирск', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Анна Титова', total: 14200, lines: [{ sku: 'H-301', name: 'Стеллаж «Вик»', quantity: 1, price: 14200 }], }, { id: 20407, date: '2026-09-22', customer: 'Мария Кузнецова', city: 'Самара', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Мария Ким', total: 30600, lines: [ { sku: 'L-408', name: 'Торшер «Арка»', quantity: 1, price: 8700 }, { sku: 'L-412', name: 'Подвес «Сфера»', quantity: 3, price: 7300 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Павел Соколов', city: 'Москва', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Анна Титова', total: 26800, lines: [ { sku: 'H-305', name: 'Комод «Фьорд»', quantity: 1, price: 21900 }, { sku: 'L-401', name: 'Лампа «Нурд»', quantity: 1, price: 4900 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Ольга Громова', city: 'Санкт-Петербург', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Мария Ким', total: 9800, lines: [{ sku: 'T-207', name: 'Журнальный стол «Тромсё»', quantity: 1, price: 9800 }], }, { id: 20410, date: '2026-09-25', customer: 'Сергей Ильин', city: 'Казань', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Анна Титова', total: 62900, lines: [ { sku: 'S-104', name: 'Стул «Берген»', quantity: 6, price: 6400 }, { sku: 'T-201', name: 'Стол «Мальмё»', quantity: 1, price: 24500 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Нина Зайцева', city: 'Екатеринбург', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Мария Ким', total: 37800, lines: [{ sku: 'S-101', name: 'Кресло «Осло»', quantity: 2, price: 18900 }], }, { id: 20412, date: '2026-09-27', customer: 'Алина Юсупова', city: 'Самара', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Анна Титова', total: 12700, lines: [ { sku: 'X-501', name: 'Плед «Шерсть»', quantity: 2, price: 3900 }, { sku: 'L-401', name: 'Лампа «Нурд»', quantity: 1, price: 4900 }, ], },];Слот end добавляет колонку справа, например для оглавления. С sticky меню и колонки не уезжают при прокрутке, а каждая прокручивается сама.
Поведение
- Слот
footerвыводит подвал: сheader="full"он занимает всю ширину под меню и содержимым, сheader="inset"стоит под содержимым. - На телефоне меню прячется в Drawer. Его открывает кнопка
NuiSidebarTrigger, а выбор пункта закрывает. - Когда меню уходит в Drawer, решает медиазапрос
mobileQuery. По умолчанию это экран не шире 48rem. - Ctrl+B, а на Mac — Cmd+B, сворачивает и раскрывает меню, если фокус не в поле ввода.
- Панель рядом с меню стоит на отступе содержимого
--spacing-layout-gutter. Над меню сcollapsible="icon"полная панель ставит кнопку по центру колонки иконок, а остальное — на тот же отступ. Дайте этот отступ содержимому, например классомpx-layout-gutter.
До загрузки скриптов экран считается широким, поэтому страница с сервера выглядит так же, как первый кадр в браузере.
Доступность
Область содержимого выводится как <main>, верхняя панель — как <header>. Кнопка меню сообщает экранному диктору, открыто ли меню.
Первой на странице стоит ссылка «К содержимому». Она видна, только когда до неё доходят клавишей Tab, и переводит фокус сразу к содержимому мимо меню. Текст меняет skipLabel, а :skip-link="false" убирает ссылку, если на странице уже есть своя.
Клавиши | Действие | |
|---|---|---|
CtrlB | Сворачивает и раскрывает боковую панель. На Mac — ⌘B. |
API
NuiLayout
Свойства
Имя | Тип | По умолчанию | Описание | |
|---|---|---|---|---|
id | string | — | Основа id боковой панели и области содержимого. Без неё создаётся автоматически. | |
header | NuiLayoutHeader | "inset" | Где верхняя панель: inset — рядом с боковой, full — на всю ширину над ней. | |
sidebarWidth | string | "16rem" | Ширина раскрытой боковой панели, например 16rem. | |
railWidth | string | — | Ширина свёрнутой боковой панели, где видны только иконки. По умолчанию — токен --spacing-layout-rail. | |
endWidth | string | "14rem" | Ширина колонки из слота end. | |
mobileQuery | string | "(max-width: 48rem)" | Медиазапрос, при котором боковая панель открывается поверх страницы, например (max-width: 48rem). | |
shortcut | boolean | true | Включает сочетание Ctrl+B (⌘B на Mac), которое сворачивает и раскрывает боковую панель. | |
sticky | boolean | false | Закрепляет колонки на высоту окна. Каждая прокручивается отдельно. | |
contentAs | string | "main" | Тег области содержимого. По умолчанию — main. | |
skipLink | boolean | true | Добавляет первой на странице ссылку «К содержимому» для перехода с клавиатуры. | |
skipLabel | string | — | Текст ссылки для перехода к содержимому. По умолчанию — «К содержимому» из словаря. |
Модели
Имя | Тип | По умолчанию | Описание | |
|---|---|---|---|---|
v-model:open | boolean | true | Раскрыта ли боковая панель на широком экране. | |
v-model:mobileOpen | boolean | false | Открыта ли боковая панель на узком экране. |
Слоты
Имя | Свойства слота | Описание | |
|---|---|---|---|
sidebar | any | Боковая панель NuiSidebar. | |
header | any | Верхняя панель NuiAppBar. | |
default | any | Содержимое страницы. | |
end | any | Колонка после содержимого, например оглавление. | |
footer | any | Подвал. С header="full" занимает всю ширину под боковой панелью и содержимым, с header="inset" стоит под содержимым. |
NuiAppBar
Свойства
Имя | Тип | По умолчанию | Описание | |
|---|---|---|---|---|
sticky | boolean | true | Закрепляет панель у верхнего края окна при прокрутке. |
Слоты
Имя | Свойства слота | Описание | |
|---|---|---|---|
start | any | Начало панели: кнопка боковой панели и логотип. | |
default | any | Середина панели, например поиск. | |
end | any | Конец панели: кнопки действий и профиль. |
NuiSkipLink
Свойства
Имя | Тип | По умолчанию | Описание | |
|---|---|---|---|---|
target*обязательно обязательно | string | — | id элемента, на который перейдёт фокус, например main. | |
label | string | — | Текст ссылки. По умолчанию — «К содержимому» из словаря. |
Слоты
Имя | Свойства слота | Описание | |
|---|---|---|---|
default | any | Разметка вместо текста. |
Тексты
Ключ | Русский | English | |
|---|---|---|---|
skip | К содержимому | Skip to content |