Navigation
These components help shoppers find their way around a shop. Use them for menus, trails, tabs, paging and step-by-step flows like checkout.
Breadcrumb
Shows where the current page sits in the shop, so a shopper can step back up a level.
<script setup lang="ts">
import { Breadcrumb } from '@eldrajs/ui';
const trail = [
{ label: 'Home', href: '/' },
{ label: 'Women', href: '/women' },
{ label: 'Knitwear', href: '/women/knitwear' },
{ label: 'Sweaters', href: '/women/knitwear/sweaters' },
{ label: 'Lopi wool sweater' },
];
</script>
<template>
<Breadcrumb :items="trail" :structured-data="false" />
</template>| Prop | Default | What it does |
|---|---|---|
items | required | The trail, starting at the home page. Each entry has a label and an href. |
collapseAfter | 1 | How many levels stay visible at the start when the trail is shortened. |
keepLast | 2 | How many levels stay visible at the end when the trail is shortened. |
linkAs | 'a' | Renders each link with your router's link component, such as RouterLink or NuxtLink. |
structuredData | true | Adds breadcrumb data for search engines. |
TIP
The last item is always shown as the current page, never as a link. Leave its href out.
NavMenu
The shop's main menu. It shows dropdown panels on wide screens and a drawer on phones.
<script setup lang="ts">
import { NavMenu } from '@eldrajs/ui';
const menu = [
{
label: 'Women',
children: [
{ label: 'Sweaters', href: '/women/sweaters' },
{ label: 'Cardigans', href: '/women/cardigans' },
{ label: 'Hats and mittens', href: '/women/hats' },
],
},
{
label: 'Men',
children: [
{ label: 'Sweaters', href: '/men/sweaters' },
{ label: 'Scarves', href: '/men/scarves' },
],
},
{ label: 'Journal', href: '/journal' },
{ label: 'Sale', href: '/sale', tone: 'accent' as const },
];
</script>
<template>
<NavMenu :items="menu" aria-label="Main menu" />
</template>| Prop | Default | What it does |
|---|---|---|
items | required | The top-level entries. An entry with children or sections opens a panel. |
collapseBelow | 'lg' | The width below which the menu turns into a drawer button. 'never' keeps the bar. |
variant | 'ghost' | The look of the top-level links: 'ghost' or 'muted'. |
openOnHover | false | Opens panels when the pointer rests on an entry, not only on click. |
linkAs | 'a' | Renders each link with your router's link component. |
TIP
Mark the page the shopper is on with current: true on its entry. Screen readers announce it.
Tabs, Tab and TabPanel
Splits related content into panels, such as a product's description, materials and shipping.
<script setup lang="ts">
import { ref } from 'vue';
import { Tab, TabPanel, Tabs } from '@eldrajs/ui';
const productTab = ref('description');
const sizeTab = ref('s');
const sizeTabs = [
{ value: 's', title: 'S', content: 'Chest 96 cm, length 64 cm.' },
{ value: 'm', title: 'M', content: 'Chest 104 cm, length 67 cm.' },
{ value: 'l', title: 'L', content: 'Chest 112 cm, length 70 cm.' },
];
</script>
<template>
<Tabs v-model="productTab" aria-label="Product information">
<template #tabs>
<Tab value="description">Description</Tab>
<Tab value="materials">Materials and care</Tab>
<Tab value="shipping">Shipping</Tab>
</template>
<TabPanel value="description"
>A relaxed crew neck sweater, hand knitted from Icelandic lopi wool.</TabPanel
>
<TabPanel value="materials">100% Icelandic wool. Hand wash cold and dry flat.</TabPanel>
<TabPanel value="shipping">Ships in 2 to 3 working days. Free returns within 30 days.</TabPanel>
</Tabs>
<Tabs v-model="sizeTab" variant="pills" aria-label="Sizes" :items="sizeTabs" />
</template>| Prop | Default | What it does |
|---|---|---|
ariaLabel | required | Names the set of tabs for screen readers. |
v-model | first tab | The value of the selected tab. |
items | none | A quick way to build tabs from plain text: value, title and content. |
variant | 'underline' | 'underline' or 'pills'. |
fill | false | Stretches the tabs to share the full width. |
Each Tab and its TabPanel share the same value. Put the Tabs in the tabs slot and the TabPanels in the default slot.
TIP
Use tabs for content a shopper reads one part at a time. If they need to compare parts, use an accordion or a plain page.
Accordion and AccordionItem
A list of sections that open and close, ideal for product details and FAQs.
How do I wash a wool sweater?
Will it shrink?Only with warm water
Can I return it?
<script setup lang="ts">
import { ref } from 'vue';
import { Accordion, AccordionItem } from '@eldrajs/ui';
const careOpen = ref(true);
</script>
<template>
<Accordion>
<AccordionItem v-model="careOpen" title="How do I wash a wool sweater?">
Hand wash in cold water with wool soap. Lay it flat to dry.
</AccordionItem>
<AccordionItem title="Will it shrink?" help="Only with warm water">
Not if you wash it cold. Warm water and tumble drying will shrink it.
</AccordionItem>
<AccordionItem title="Can I return it?">
Yes, within 30 days, as long as it is unworn.
</AccordionItem>
</Accordion>
</template>| Prop | Default | What it does |
|---|---|---|
multiple (Accordion) | true | Lets several items stay open. Set false to close the others when one opens. |
title (AccordionItem) | required | The text on the item's header. |
help (AccordionItem) | none | A short line under the title. |
v-model (AccordionItem) | false | Whether the item is open. |
headingLevel (AccordionItem) | none | Wraps the header in an h2, h3 or h4 to fit your page outline. |
TIP
The content stays in the page while closed, so search engines and in-page search still find it.
Pagination
Lets shoppers move between pages of a long product list.
<script setup lang="ts">
import { ref } from 'vue';
import { Pagination } from '@eldrajs/ui';
const page = ref(3);
</script>
<template>
<Pagination v-model:page="page" :total-pages="12" />
<Pagination v-model:page="page" :total-pages="12" compact />
</template>| Prop | Default | What it does |
|---|---|---|
page | required | The current page, starting at 1. Use v-model:page to keep it in sync. |
totalPages | required | How many pages there are. Nothing shows when there is only one. |
hrefForPage | none | Builds a link for each page. Without it, the pages are buttons. |
compact | false | Always shows the short "Page 3 of 12" form. |
siblings | 1 | How many page numbers show on each side of the current page. |
TIP
Pass hrefForPage on a category page, for example (p) => '?page=' + p. Real links let search engines reach every page.
LoadMore
A button that adds the next batch of products below the list, with a count of how many are shown.
Showing 24 of 60 sweaters
<script setup lang="ts">
import { ref } from 'vue';
import { LoadMore } from '@eldrajs/ui';
const shown = ref(24);
const loading = ref(false);
function loadMore() {
loading.value = true;
setTimeout(() => {
shown.value = Math.min(shown.value + 24, 60);
loading.value = false;
}, 800);
}
</script>
<template>
<LoadMore :shown="shown" :total="60" noun="sweaters" :pending="loading" @load="loadMore" />
</template>| Prop | Default | What it does |
|---|---|---|
shown | required | How many items are on the page now. |
total | required | How many items there are in all. The button hides when all are shown. |
noun | 'products' | The word in the count, as in "Showing 24 of 60 sweaters". |
pending | false | Shows the button as busy while the next batch loads. |
It emits load when the shopper clicks the button. Fetch the next batch there.
StepIndicator
Shows where a shopper is in a multi-step flow, such as checkout.
- Cart (completed)
- DeliveryPósturinn or pickup
- Payment (not started)
- Confirmation (not started)
- Cart (completed)
- Delivery (completed)Pósturinn or pickup
- Payment
- Confirmation (not started)
<script setup lang="ts">
import { StepIndicator } from '@eldrajs/ui';
const checkoutSteps = [
{ label: 'Cart' },
{ label: 'Delivery', description: 'Pósturinn or pickup' },
{ label: 'Payment' },
{ label: 'Confirmation' },
];
</script>
<template>
<StepIndicator :steps="checkoutSteps" :current="1" />
<StepIndicator :steps="checkoutSteps" :current="2" orientation="vertical" />
</template>| Prop | Default | What it does |
|---|---|---|
steps | required | The steps in order. Each has a label and an optional description. |
current | required | The current step, counting from 0. Steps before it show as done. |
orientation | 'horizontal' | 'horizontal' or 'vertical'. Vertical fits narrow screens best. |
TIP
current counts from 0, so the second step is 1. Set it to the number of steps to mark them all done.
Carousel
A row of slides a shopper can scroll through, such as bestsellers or a photo gallery.
Bestsellers
Lopi wool sweater
24.900 kr.
Merino beanie
6.490 kr.
Wool mittens
5.990 kr.
Knitted scarf
9.900 kr.
Wool socks
3.490 kr.
<script setup lang="ts">
import { Carousel } from '@eldrajs/ui';
const bestsellers = [
{ name: 'Lopi wool sweater', price: '24.900 kr.', colour: '#c8d5c0' },
{ name: 'Merino beanie', price: '6.490 kr.', colour: '#e6d3bd' },
{ name: 'Wool mittens', price: '5.990 kr.', colour: '#cdd6e4' },
{ name: 'Knitted scarf', price: '9.900 kr.', colour: '#e2c6c6' },
{ name: 'Wool socks', price: '3.490 kr.', colour: '#d9d2e6' },
];
</script>
<template>
<Carousel aria-label="Bestsellers" :per-view="{ base: 1.25, md: 3 }">
<template #header>
<h3 style="margin: 0">Bestsellers</h3>
</template>
<li v-for="item in bestsellers" :key="item.name" style="list-style: none">
<div :style="{ background: item.colour, aspectRatio: '4 / 5', borderRadius: '8px' }"></div>
<p style="margin: 8px 0 0; font-weight: 600">{{ item.name }}</p>
<p style="margin: 0">{{ item.price }}</p>
</li>
</Carousel>
</template>| Prop | Default | What it does |
|---|---|---|
ariaLabel | required | Names the carousel for screen readers. |
perView | 1.25 | Slides visible at once. Pass { base, md, lg } to change it by width. |
controls | 'header' | Where the arrows sit: 'header' or 'below'. |
dots | false | Shows one dot per slide. Use it only for one-slide-at-a-time galleries. |
autoplay | 0 | Milliseconds between automatic moves. 0 turns it off. |
Each direct child of the carousel is one slide.
TIP
Autoplay always shows a pause button, and it never starts for shoppers who ask for reduced motion.