Skip to content

Overlays and feedback ​

These components open on top of the page or tell the shopper what just happened. Use them for dialogs, side panels, menus, hints and messages.

Dialog ​

A modal window for a short question or a small form that needs the shopper's answer before they go on.

Saved to your wishlist

You can find it any time under Account, Wishlist.

Empty your cart?

This removes all 3 items. You cannot undo it.

vue
<script setup lang="ts">
import { ref } from 'vue';
import { Button, Dialog } from '@eldrajs/ui';

const dialogOpen = ref(false);
const confirmOpen = ref(false);
</script>

<template>
  <Button variant="outline" @click="dialogOpen = true">Save to wishlist</Button>
  <Dialog
    v-model="dialogOpen"
    title="Saved to your wishlist"
    description="You can find it any time under Account, Wishlist."
  >
    <template #footer>
      <Button variant="primary" @click="dialogOpen = false">Got it</Button>
    </template>
  </Dialog>

  <Button variant="danger" @click="confirmOpen = true">Empty cart</Button>
  <Dialog
    v-model="confirmOpen"
    size="sm"
    title="Empty your cart?"
    description="This removes all 3 items. You cannot undo it."
    :dismissable="false"
  >
    <template #footer>
      <Button variant="ghost" @click="confirmOpen = false">Keep items</Button>
      <Button variant="danger" @click="confirmOpen = false">Empty cart</Button>
    </template>
  </Dialog>
</template>
PropDefaultWhat it does
v-modelfalseOpens and closes the dialog.
titlenoneThe heading. It also names the dialog for screen readers.
descriptionnoneA line of text under the title. Leave it out when the body is a form.
size"md""sm" for a short message, "md" for most dialogs.
dismissabletrueWhether a click on the backdrop closes it. Esc and the close button always do.

Put the body in the default slot and the buttons in the footer slot.

TIP

Set :dismissable="false" on a destructive confirm or a half-filled form. A stray click outside should not count as an answer.

Drawer ​

A panel that slides in from the side of the screen, for the cart, filters or the mobile menu.

Your cart (3)

Wool sweater · Oatmeal · M

Wool beanie · Moss

Wool socks · Fjord blue · 2 pairs

vue
<script setup lang="ts">
import { ref } from 'vue';
import { Button, Drawer } from '@eldrajs/ui';

const cartOpen = ref(false);
const menuOpen = ref(false);
</script>

<template>
  <Button variant="primary" @click="cartOpen = true">Open cart</Button>
  <Drawer v-model="cartOpen" title="Your cart" :count="3">
    <p>Wool sweater · Oatmeal · M</p>
    <p>Wool beanie · Moss</p>
    <p>Wool socks · Fjord blue · 2 pairs</p>
    <template #footer>
      <Button variant="primary" block @click="cartOpen = false">Go to checkout · 32.970 kr.</Button>
    </template>
  </Drawer>

  <Button variant="outline" @click="menuOpen = true">Open menu</Button>
  <Drawer v-model="menuOpen" side="left" aria-label="Menu">
    <nav>
      <p><a href="#drawer">Women</a></p>
      <p><a href="#drawer">Men</a></p>
      <p><a href="#drawer">Knitwear</a></p>
    </nav>
  </Drawer>
</template>
PropDefaultWhat it does
v-modelfalseOpens and closes the drawer.
side"right""left" for the mobile menu, "right" for everything else.
titlenoneThe visible heading, such as "Your cart".
aria-labelnoneA name for screen readers when there is no visible title.
countnoneA number after the title: "Your cart (3)".
mobile-sheetfalseOn phones, open as a sheet from the bottom instead of full screen.

TIP

Give every drawer a title or an aria-label. Without one, screen reader users do not know what opened.

Popover ​

A small panel that opens under a button, for a short menu or a quick filter.

vue
<script setup lang="ts">
import { h } from 'vue';
import { Button, Popover, TablerIcon } from '@eldrajs/ui';

const ShareIcon = () => h(TablerIcon, { name: 'share' });
</script>

<template>
  <Popover aria-label="Share this product">
    <template #trigger="{ attrs }">
      <Button variant="outline" :icon-left="ShareIcon" v-bind="attrs">Share</Button>
    </template>
    <template #default="{ close }">
      <div style="display: flex; flex-direction: column; padding: 0.5rem; gap: 0.25rem;">
        <a href="#popover" @click="close()">Copy link</a>
        <a href="#popover" @click="close()">Send by email</a>
      </div>
    </template>
  </Popover>
</template>
PropDefaultWhat it does
v-modelfalseOpens and closes the panel. Optional: the popover manages itself when unbound.
placement"auto"Where the panel opens: "auto" (below, flips above), "above", or a corner like "bottom-end".
aria-labelnoneA name for the panel when it has no visible heading.
match-widthnonetrue keeps the panel at least as wide as the button.
close-on-outside-clicktrueClose when the shopper clicks elsewhere.

The button goes in the trigger slot. The panel content goes in the default slot, which also gives you a close function.

TIP

Spread the trigger slot's attrs onto your button with v-bind="attrs". That wires up the click, the keyboard and the screen reader state.

Tooltip ​

A small label that shows when the shopper hovers over or focuses a button. Use it to name an icon-only button.

vue
<script setup lang="ts">
import { h } from 'vue';
import { Button, TablerIcon, Tooltip } from '@eldrajs/ui';

const HeartIcon = () => h(TablerIcon, { name: 'heart' });
const ShareIcon = () => h(TablerIcon, { name: 'share' });
</script>

<template>
  <Tooltip text="Add to wishlist">
    <Button variant="ghost" icon-only :icon="HeartIcon" label="Add wool sweater to wishlist" />
  </Tooltip>
  <Tooltip text="Opens a share menu" role="description" placement="bottom">
    <Button variant="outline" :icon-left="ShareIcon">Share</Button>
  </Tooltip>
</template>
PropDefaultWhat it does
textrequiredThe label, a few words.
placement"top""top" or "bottom" of the button.
align"center""start" or "end" for a button near the edge of the screen.
role"label""label" names an icon-only button. "description" adds a hint to a button that already has text.

TIP

Never put a price, an error or a link in a tooltip. Touch screens cannot hover, so many shoppers never see it.

Toast and Toaster ​

A toast is a short message that pops up in a corner, such as "Added to cart". Put one Toaster in your app and raise toasts from anywhere with useToast().

vue
<script setup lang="ts">
import { Button, Toaster, useToast } from '@eldrajs/ui';

const toast = useToast();
function addToCart() {
  toast.show({
    title: 'Added to cart',
    text: 'Wool sweater · Oatmeal · M',
    action: { label: 'View cart (3)', href: '#toast-and-toaster' },
  });
}
function lowStock() {
  toast.show({ variant: 'warning', title: 'Only 2 left in stock' });
}
</script>

<template>
  <Button variant="primary" @click="addToCart">Add to cart</Button>
  <Button variant="outline" @click="lowStock">Show stock warning</Button>
  <Toaster />
</template>

You can also draw a single Toast yourself, for example in a layout preview:

Added to cart

Wool sweater · Oatmeal · M

vue
<script setup lang="ts">
import { Toast } from '@eldrajs/ui';
</script>

<template>
  <Toast title="Added to cart" text="Wool sweater · Oatmeal · M" :closable="false" />
  <Toast variant="danger" title="Couldn't update your cart" :closable="false" />
</template>
toast.show() optionDefaultWhat it does
titlerequiredThe message.
variant"success""success", "info", "warning" or "danger". Sets the icon, colour and timing.
textnoneOne supporting line under the title.
actionnoneOne link ({ label, href }) or button ({ label, onActivate }).
durationper variantMilliseconds before it closes. 0 keeps it open. A danger toast always stays.
Toaster propDefaultWhat it does
position"bottom-right"The corner the stack sits in, such as "top-center".
newest-on-topfalseShow the newest toast first.
max-visibleallShow at most this many toasts at once.

TIP

Mount Toaster once, near the root of your app. Two toasters would show every toast twice.

Notice ​

A message that sits in the page, such as a delivery note or an order confirmation. Unlike a toast, it stays.

Free delivery

Orders over 15.000 kr. ship free within Iceland.

Thank you for your order

We have sent a receipt to your email.
Only 2 left in stock in size M.
vue
<script setup lang="ts">
import { Notice } from '@eldrajs/ui';
</script>

<template>
  <Notice
    title="Free delivery"
    text="Orders over 15.000 kr. ship free within Iceland."
    :announce="false"
  />
  <Notice
    tone="success"
    title="Thank you for your order"
    text="We have sent a receipt to your email."
    :announce="false"
  />
  <Notice tone="warning" text="Only 2 left in stock in size M." :announce="false" />
</template>
PropDefaultWhat it does
tone"info""info", "success", "warning" or "danger". Sets the colour and icon.
titlenoneAn optional heading line.
textnoneThe message. Use the default slot instead for links or several paragraphs.
heading-levelnoneMakes the title a real heading, such as 2 for a confirmation page.
announcetrueReads the notice aloud when it appears. Set false for a notice that is there from page load.

Buttons or links for the notice go in the actions slot.

TIP

Keep the icon on success, warning and danger notices. Colour alone is not enough for shoppers who cannot see it.

A full-screen photo viewer for product images, with arrows, thumbnails and zoom.

vue
<script setup lang="ts">
import { ref } from 'vue';
import { Lightbox } from '@eldrajs/ui';

const photos = [
  {
    src: '/images/sweater-oatmeal.jpg',
    alt: 'Wool sweater in oatmeal, front',
    caption: 'Oatmeal',
    width: 1200,
    height: 1500,
  },
  {
    src: '/images/sweater-blue.jpg',
    alt: 'Wool sweater in fjord blue, front',
    caption: 'Fjord blue',
    width: 1200,
    height: 1500,
  },
  {
    src: '/images/sweater-moss.jpg',
    alt: 'Wool sweater in moss green, front',
    caption: 'Moss',
    width: 1200,
    height: 1500,
  },
];
const lightboxOpen = ref(false);
const lightboxIndex = ref(0);
function openPhoto(i: number) {
  lightboxIndex.value = i;
  lightboxOpen.value = true;
}
</script>

<template>
  <button
    v-for="(photo, i) in photos"
    :key="photo.src"
    type="button"
    style="padding: 0; border: 0; background: none; cursor: zoom-in;"
    @click="openPhoto(i)"
  >
    <img
      :src="photo.src"
      :alt="photo.alt"
      width="96"
      height="120"
      style="display: block; border-radius: 0.25rem;"
    />
  </button>
  <Lightbox
    v-model="lightboxOpen"
    v-model:index="lightboxIndex"
    :images="photos"
    aria-label="Wool sweater, images"
    thumbnails
    zoom
  />
</template>
PropDefaultWhat it does
imagesrequiredThe photos, each with src, alt, width, height and an optional caption.
aria-labelrequiredA name for the viewer, such as "Wool sweater, images".
v-modelfalseOpens and closes the viewer.
v-model:index0Which photo shows. Set it to the photo the shopper clicked.
thumbnailsfalseShows a strip of small pictures to jump between.
zoomfalseLets the shopper click to see the photo at full size.

TIP

Give each image its real width and height in pixels. The viewer uses them to keep each photo's shape.

Layout helpers ​

Four small building blocks for page layout and accessibility.

Container and Section ​

Section is one band of the page with a background and vertical spacing. Container keeps the content inside at a readable width.

Every sweater is knitted in Iceland from local wool.

Get 10% off your first order.

vue
<script setup lang="ts">
import { Container, Section } from '@eldrajs/ui';
</script>

<template>
  <Section background="surface" spacing="sm" aria-label="Our wool">
    <Container width="narrow">
      <p>Every sweater is knitted in Iceland from local wool.</p>
    </Container>
  </Section>
  <Section background="primary" spacing="sm" aria-label="Newsletter">
    <Container width="narrow">
      <p>Get 10% off your first order.</p>
    </Container>
  </Section>
</template>
PropDefaultWhat it does
Section background"none""none", "surface", "surface-strong", "primary" or "accent".
Section spacing"md"Space above and below: "none", "sm", "md" or "lg".
Section labelled-by / aria-labelnoneNames the section for screen readers. Use labelled-by with the id of its visible heading.
Container width"content""narrow" for text, "content" for most blocks, "wide" for product grids, "full" for edge-to-edge images.

TIP

Never put a Section inside another Section. Nest Containers instead.

VisuallyHidden ​

Text that screen readers read but the page does not show. Use it for skip links and for extra context next to an icon.

Skip to content3.490 kr. , was 4.990 kr.
vue
<script setup lang="ts">
import { VisuallyHidden } from '@eldrajs/ui';
</script>

<template>
  <VisuallyHidden as="a" href="#layout-helpers" focusable>Skip to content</VisuallyHidden>
  <span>3.490 kr. <VisuallyHidden>, was 4.990 kr.</VisuallyHidden></span>
</template>

Press Tab in the example above to see the skip link appear.

PropDefaultWhat it does
as"span"The element to render, such as "a" for a skip link.
focusablefalseShows the content while it has focus. Use it for skip links.

EditorPlaceholder ​

A dashed box that shows in the page editor where a block has no content yet. Render it only while editing, so shoppers never see it.

Add products

Pick a collection or up to 12 products to show in this grid.

Add a heading

vue
<script setup lang="ts">
import { EditorPlaceholder } from '@eldrajs/ui';
</script>

<template>
  <EditorPlaceholder
    label="Add products"
    help="Pick a collection or up to 12 products to show in this grid."
  />
  <EditorPlaceholder label="Add a heading" inline />
</template>
PropDefaultWhat it does
labelrequiredThe action, such as "Add products".
helpnoneOne line of guidance under the label.
inlinefalseSmaller padding, for an empty heading or text field.
iconnoneAn icon component shown above the label.

Eldra