OTTODesign System

Components

Snackbar

The snackbar is a temporary message that appears at the bottom of a page to provide feedback triggered by a user's action. I should not be used for critical information.

Configurator

LiveSnackbar: message, action, auto-dismiss and background. Press the button to show it at the bottom of the window.
Snackbar zeigen Rückgängig machen
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-cfg">Snackbar zeigen</oc-button-v1>
<oc-snackbar-v1 id="snackbar-cfg" message="Der Artikel wurde von deinem Merkzettel entfernt." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Rückgängig machen</oc-link-v2></oc-snackbar-v1>

Usage

Anatomy

Anatomy

Variants

The background color of the snackbar can be adjusted. Therefore you should use semantic design tokens with the prefix "$oc-semantic-color-background-strong-". If you want to use other colors please check with the design system team before doing so.

Press a button: the snackbar appears at the bottom of the window

Standard Grün (success) Rot (error)
Ansehen Ansehen Ansehen
LiveColored background
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-bg-default">Standard</oc-button-v1>
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-bg-success">Grün (success)</oc-button-v1>
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-bg-error">Rot (error)</oc-button-v1>
<oc-snackbar-v1 id="snackbar-bg-default" message="Deine Änderungen wurden gespeichert." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Ansehen</oc-link-v2></oc-snackbar-v1>
<oc-snackbar-v1 id="snackbar-bg-success" message="Deine Änderungen wurden gespeichert." auto-dismiss="false" style="--background-color: var(--oc-semantic-color-background-strong-success)"><oc-link-v2 variant="inverted" as-button slot="actions">Ansehen</oc-link-v2></oc-snackbar-v1>
<oc-snackbar-v1 id="snackbar-bg-error" message="Deine Änderungen wurden gespeichert." auto-dismiss="false" style="--background-color: var(--oc-semantic-color-background-strong-error)"><oc-link-v2 variant="inverted" as-button slot="actions">Ansehen</oc-link-v2></oc-snackbar-v1>

Behavior

States

The snackbar has no own states. It uses the states of link and icon button.

Open it, then hover, press and tab through the action and the close button

Snackbar zeigen
Rückgängig machen
LiveStates
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-states">Snackbar zeigen</oc-button-v1></div>
<oc-snackbar-v1 id="snackbar-states" message="Der Artikel wurde entfernt." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Rückgängig machen</oc-link-v2></oc-snackbar-v1>

Interaction

The snackbar is triggered by a user's action on other components. Once triggered, it appears at the bottom of the viewport and automatically disappears after five seconds. However, there is an auto-dismiss restriction:

The snackbar will not disappear as long as the mouse hovers over it, the focus is on it, or it is held by touch.

Make sure the snackbar does not disappear automatically when you place actions inside it to ensure users do not become stressed trying to access them. The snackbar can then be closed manually using the close button.

1. Click the button to trigger the snackbar

In den Warenkorb

2. Close it with the close button, click anywhere else, or wait five seconds

LiveInteraction
HTML
<oc-button-v1 variant="secondary" data-live-open="#snackbar-interaction">In den Warenkorb</oc-button-v1>
<oc-snackbar-v1 id="snackbar-interaction" message="Der Artikel liegt jetzt in deinem Warenkorb."></oc-snackbar-v1>

Animation

When the snackbar enters, it moves up and increases its opacity simultaneously. When the snackbar exits, it moves down outside the viewport and decreases its opacity simultaneously. In the case of "prefers-reduced-motion", only the opacity animates.

Enter: moves up and fades in

Snackbar einblenden
Ansehen
LiveEnter animation
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-enter">Snackbar einblenden</oc-button-v1></div>
<oc-snackbar-v1 id="snackbar-enter" message="Deine Adresse wurde gespeichert." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Ansehen</oc-link-v2></oc-snackbar-v1>

Exit: moves down and fades out

EinblendenAusblenden
Ansehen
LiveExit animation
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-exit">Einblenden</oc-button-v1><oc-button-v1 variant="secondary" fit-content data-live-close="#snackbar-exit">Ausblenden</oc-button-v1></div>
<oc-snackbar-v1 id="snackbar-exit" message="Deine Adresse wurde gespeichert." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Ansehen</oc-link-v2></oc-snackbar-v1>

Fitting

For breakpoint S the snackbar uses fill-parent with 24px outer spacing on each side. As soon as there is not enough space for the action on the right side it is positioned below the label.

Mobile: width fills the window minus 24 px each side, height fits the content (narrow the window)

Kurzes LabelLanges Label
Action Action
LiveSnackbar with on line and multiple lines on mobile
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-fit-m-short">Kurzes Label</oc-button-v1><oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-fit-m-long">Langes Label</oc-button-v1></div>
<oc-snackbar-v1 id="snackbar-fit-m-short" message="Label" auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Action</oc-link-v2></oc-snackbar-v1>
<oc-snackbar-v1 id="snackbar-fit-m-long" message="Ein außergewöhnlich langes Label" auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Action</oc-link-v2></oc-snackbar-v1>

For breakpoint M to XL the snackbar uses fit-content. As soon as there is not enough space inside the viewport it switches to fill-parent with 24px outer spacing on each side.

Desktop: fit-content up to the window width minus 24 px each side; long labels move the action below

KurzLangSehr lang
Action Action Action
LiveSnackbar with on line and multiple lines on desktop
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-fit-d-short">Kurz</oc-button-v1><oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-fit-d-long">Lang</oc-button-v1><oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-fit-d-longer">Sehr lang</oc-button-v1></div>
<oc-snackbar-v1 id="snackbar-fit-d-short" message="Label" auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Action</oc-link-v2></oc-snackbar-v1>
<oc-snackbar-v1 id="snackbar-fit-d-long" message="Ein wirklich extrem außergewöhnlich langes Label, das super viel Platz weg nimmt." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Action</oc-link-v2></oc-snackbar-v1>
<oc-snackbar-v1 id="snackbar-fit-d-longer" message="Ein wirklich extrem außergewöhnlich langes Label, das super mega viel Platz weg nimmt." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Action</oc-link-v2></oc-snackbar-v1>

Placement

The snackbar appears centered at the bottom of the viewport. It is positioned 16px from the bottom and 24px from the left and right sides. The snackbar is placed sticky (level 3) on top.

Centred at the bottom of the window: 16 px from the bottom, at least 24 px from the sides, elevation level 3

Snackbar zeigen
Ansehen
LiveMobile placement of the snackbar
HTML
<oc-button-v1 variant="secondary" fit-content data-live-open="#snackbar-placement">Snackbar zeigen</oc-button-v1></div>
<oc-snackbar-v1 id="snackbar-placement" message="Zum Merkzettel hinzugefügt." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Ansehen</oc-link-v2></oc-snackbar-v1>

Best practices

Snackbar zeigen
Ansehen
DoShow only one snackbar at a time. Replace the current snackbar when a new one appears.
Snackbar 1Snackbar 2
Action Action
Don'tAllow multiple snackbars to appear at once or stack snackbars above each other.

1. Aktion: remove the item, 2. Aktion: press “Rückgängig machen” in the snackbar

Artikel entfernen
Rückgängig machen
DoIf a "Rückgänig" or "Wiederholen" action is triggered another snackbar should follow to confirm the action.
CautionIf you already use a sticky component in your view be aware that the snackbar might overlap with it.

Content guidelines

DoKeep the label to one line, if possible.
Don'tUse stylized text or inline links.
DoUse a label that provides feedback on a user's action.
Don'tUse a label that has advertising purposes e.g. sale or discounts.
Don'tUse an action with the label "Verwerfen" or "Schließen", as the snackbar features it own close affordance.
Don'tUse a label that contains critical system messages.

Accessibility

For information on accessibility, refer to thetechnical documentation.

Implementation

Live demo

Neu für dich

Sneaker aus Glattleder, Weiß
-20 %

OTTO products

Sneaker aus Glattleder, Weiß

99,99 € 79,99 €

Sessel „Ilvy“ aus Bouclé, Eiche natur
Neu

andas

Sessel „Ilvy“ aus Bouclé, Eiche natur

399,99 €

Over-Ear-Kopfhörer mit Noise Cancelling

Hanseatic

Over-Ear-Kopfhörer mit Noise Cancelling

59,99 €

Tap a heart: the snackbar confirms the action at the bottom of the window

Merkzettel ansehen
LiveReal OTTO components, rendered by the OTTO component runtime
HTML
<p class="demo-title" style="font-size:1.25rem">Neu für dich</p>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(9.5rem,1fr));gap:24px 16px"><article style="display:flex;flex-direction:column;gap:2px;min-width:0"><div style="position:relative;border-radius:16px;overflow:hidden;background:#f3f3f3"><img src="/previews/imagery/samples/otto-product-still/product-sneaker.webp" alt="Sneaker aus Glattleder, Weiß" width="600" height="600" loading="lazy" style="display:block;width:100%;height:auto;margin:0;mix-blend-mode:multiply"><div style="position:absolute;left:12px;bottom:12px;display:flex;gap:4px;flex-wrap:wrap"><oc-tag-v1 variant="sale" size="50">-20 %</oc-tag-v1></div><div style="position:absolute;right:8px;top:8px"><oc-icon-button-v3 variant="secondary" size="50" elevation-level="above" icon="wishlist" oc-aria-label="Auf den Merkzettel" data-live-open="#snackbar-demo"></oc-icon-button-v3></div></div><p class="demo-copy" style="margin-top:10px;color:var(--oc-semantic-color-text-secondary, #6d6d6d);text-transform:uppercase;font-size:0.75rem;letter-spacing:0.02em">OTTO products</p><p class="demo-copy">Sneaker aus Glattleder, Weiß</p><p class="demo-copy" style="margin-top:6px"><s style="color:var(--oc-semantic-color-text-secondary, #6d6d6d)">99,99 €</s> <strong style="color:var(--oc-semantic-color-text-sale, #e20020);font-size:1rem">79,99 €</strong></p></article><article style="display:flex;flex-direction:column;gap:2px;min-width:0"><div style="position:relative;border-radius:16px;overflow:hidden;background:#f3f3f3"><img src="/previews/imagery/samples/otto-product-still/product-armchair.webp" alt="Sessel „Ilvy“ aus Bouclé, Eiche natur" width="600" height="600" loading="lazy" style="display:block;width:100%;height:auto;margin:0;mix-blend-mode:multiply"><div style="position:absolute;left:12px;bottom:12px;display:flex;gap:4px;flex-wrap:wrap"><oc-tag-v1 variant="info-primary" size="50">Neu</oc-tag-v1></div><div style="position:absolute;right:8px;top:8px"><oc-icon-button-v3 variant="secondary" size="50" elevation-level="above" icon="wishlist" oc-aria-label="Auf den Merkzettel" data-live-open="#snackbar-demo"></oc-icon-button-v3></div></div><p class="demo-copy" style="margin-top:10px;color:var(--oc-semantic-color-text-secondary, #6d6d6d);text-transform:uppercase;font-size:0.75rem;letter-spacing:0.02em">andas</p><p class="demo-copy">Sessel „Ilvy“ aus Bouclé, Eiche natur</p><p class="demo-copy" style="margin-top:6px"><strong style="font-size:1rem">399,99 €</strong></p></article><article style="display:flex;flex-direction:column;gap:2px;min-width:0"><div style="position:relative;border-radius:16px;overflow:hidden;background:#f3f3f3"><img src="/previews/imagery/samples/otto-product-still/product-headphones.webp" alt="Over-Ear-Kopfhörer mit Noise Cancelling" width="600" height="600" loading="lazy" style="display:block;width:100%;height:auto;margin:0;mix-blend-mode:multiply"><div style="position:absolute;right:8px;top:8px"><oc-icon-button-v3 variant="secondary" size="50" elevation-level="above" icon="wishlist" oc-aria-label="Auf den Merkzettel" data-live-open="#snackbar-demo"></oc-icon-button-v3></div></div><p class="demo-copy" style="margin-top:10px;color:var(--oc-semantic-color-text-secondary, #6d6d6d);text-transform:uppercase;font-size:0.75rem;letter-spacing:0.02em">Hanseatic</p><p class="demo-copy">Over-Ear-Kopfhörer mit Noise Cancelling</p><p class="demo-copy" style="margin-top:6px"><strong style="font-size:1rem">59,99 €</strong></p></article></div>
<oc-snackbar-v1 id="snackbar-demo" message="Der Artikel liegt jetzt auf deinem Merkzettel." auto-dismiss="false"><oc-link-v2 variant="inverted" as-button slot="actions">Merkzettel ansehen</oc-link-v2></oc-snackbar-v1>

Code

Version Tag Status API
v1 <oc-snackbar-v1> Stable SnackbarV1

API

API: <oc-snackbar-v1> (SnackbarV1)

The snackbar component allows users to display a dismissable popup message.

Attributes / properties
Attribute Type Default Required Description
id string "computed" no Sets the ID of the snackbar instance. The ID must be globally unique. If not provided, a random ID will be generated.
message string yes Sets the text that is displayed in the snackbar. Accepts plain text only.
auto-dismiss "true" | "false" true no Sets whether the snackbar should be closed automatically after a certain duration.
open boolean false no Sets the visibility state of the snackbar. Set to true to open the snackbar. Has the same effect as using the open or close method.
force-replace-existing-instance boolean false no Set to true to perform a DOM query that removes all existing snackbar instances with the same ID. Use in scenarios when a fragment update renders a snackbar instance with the same ID as an existing one, but with different content.
Slots
Slot Required Description
actions no Holds the link components that provide interactions to the user.
Example:
<oc-link-v2 variant="underlined" href="#" slot="actions">Action 1</oc-link-v2>
Events
Event Detail type Description
oc-snackbar-open CustomEvent<null> Dispatched once the snackbar instance is being opened, but before it becomes visible. If not cancelled, then the instance will become visible and start animation.
oc-snackbar-close CustomEvent<null> The event will be fired immediately after close is requested, and before any transitions or animations are completed.
oc-open CustomEvent<null> Dispatched once the snackbar instance is being opened, but before it becomes visible. If not cancelled, then the instance will become visible and start animation.
oc-close CustomEvent<null> The event will be fired immediately after close is requested, and before any transitions or animations are completed.
oc-property-change OcSnackbarV1Events["oc-property-change"] Whenever a property value changes, this event triggers. Use this event to track all property changes within the component.

Refer to the Events documentation for more information.
oc-mount { component: string; } Fired when the component is mounted to the DOM. The event is fired when the onMount hook of the component is called by the runtime.
oc-unmount { component: string; } Fired when the component is unmounted from the DOM. The event is fired when the function returned by the onMount hook of the component is called by the runtime.
Methods
  • close: () => void

    Closes the snackbar. Provides the same effect as setting the attribute open to false. This method provides the same effect as clicking the close button.

    Returns: void

    Example:

    const snackbar = document.querySelector("oc-snackbar-v1");
    snackbar.close();
    
CSS custom properties
Custom property Default Description
--background-color undefined Sets the custom background color

Examples

Listed below are the most common variations of the snackbar component as well as specific component variations for different use cases.

Default

The default configuration

HTML
<oc-snackbar-v1 id="default-snackbar" message="Label"></oc-snackbar-v1>