Skip to content
v0.9.1
Components

Cookie banner

Asks once whether the site may use cookies, remembers the answer, and lets the reader change their mind later. Scripts like analytics can wait until they say yes. The banner sits in a corner (or along the bottom) and never covers the page.

Cookie banner

Here the banners are shown in place (.cookie-banner-inline); on a real site they float in the bottom corner. See the real one on the landing example.

<div class="cookie-banner cookie-banner-inline" role="region" aria-label="Cookies">
  <p class="cookie-title"><i class="mi mi-cookie" aria-hidden="true"></i> Cookies</p>
  <p class="cookie-text">We use one cookie to keep you signed in, and others to see which pages people read. <a href="#">Privacy</a></p>
  <div class="cookie-actions">
    <button class="btn btn-sm btn-ghost" type="button" data-momo-consent="reject">Reject</button>
    <button class="btn btn-sm" type="button" data-momo-dialog="cookie-settings">Settings</button>
    <button class="btn btn-sm btn-brand" type="button" data-momo-consent="accept">Accept all</button>
  </div>
</div>

As a bar

.cookie-banner-bar: across the bottom, text on one side and buttons on the other.

<div class="cookie-banner cookie-banner-bar cookie-banner-inline" role="region" aria-label="Cookies (bar)">
  <p class="cookie-text">We use cookies to understand how the site is used. You choose which ones. <a href="#">Privacy</a></p>
  <div class="cookie-actions">
    <button class="btn btn-sm btn-ghost" type="button" data-momo-consent="reject">Reject</button>
    <button class="btn btn-sm" type="button" data-momo-dialog="cookie-settings">Settings</button>
    <button class="btn btn-sm btn-brand" type="button" data-momo-consent="accept">Accept all</button>
  </div>
</div>

Settings

A normal dialog with one switch per kind of cookie, named consent with the kind as its value. A switch that is checked and disabled is always on (the ones the site needs to work).

<button class="btn" type="button" data-momo-dialog="cookie-settings"><i class="mi mi-settings" aria-hidden="true"></i> Cookie settings</button>
<button class="btn btn-ghost" type="button" onclick="Momo.consent.reset(); Momo.toast('Choice forgotten')">Forget my choice</button>
<dialog class="dialog dialog-sm" id="cookie-settings" aria-labelledby="cookie-settings-title">
  <div class="dialog-header">
    <h2 class="dialog-title" id="cookie-settings-title">Cookie settings</h2>
    <button class="btn btn-icon btn-sm btn-ghost" type="button" data-momo-close aria-label="Close"><i class="mi mi-x" aria-hidden="true"></i></button>
  </div>
  <div class="dialog-body">
    <ul class="consent-list">
      <li class="consent-item"><b>Needed</b><p>Signing in and remembering this choice. Always on.</p><label class="switch"><input type="checkbox" name="consent" value="needed" checked disabled><span class="visually-hidden">Needed cookies</span></label></li>
      <li class="consent-item"><b>Analytics</b><p>Counting visits so we know which pages help.</p><label class="switch"><input type="checkbox" name="consent" value="analytics"><span class="visually-hidden">Analytics cookies</span></label></li>
      <li class="consent-item"><b>Marketing</b><p>Showing you our ads on other sites.</p><label class="switch"><input type="checkbox" name="consent" value="marketing"><span class="visually-hidden">Marketing cookies</span></label></li>
    </ul>
  </div>
  <div class="dialog-footer">
    <button class="btn btn-ghost" type="button" data-momo-consent="reject">Reject all</button>
    <button class="btn btn-brand" type="button" data-momo-consent="save">Save choices</button>
  </div>
</dialog>

Wait for a yes

Put a script that sets cookies inside a <template data-momo-consent-for="analytics">. It stays switched off, and Momo adds it to the page the moment the reader allows that kind (and on every later visit).

<template data-momo-consent-for="analytics">
  <script src="https://analytics.example.com/script.js" defer></script>
</template>

From your own script: Momo.consent.get('analytics') is true or false, and the momo:consent event fires on document whenever the choice changes.

On a page

<div class="cookie-banner" data-momo-consent-banner role="region" aria-label="Cookies">…</div>
<dialog class="dialog dialog-sm" id="cookie-settings">…</dialog>
…
<footer>… <button data-momo-consent-open="cookie-settings">Cookie settings</button> …</footer>

data-momo-consent-banner is what makes it hide once answered and stay hidden on later visits. A button with data-momo-consent-open opens the settings again (give it the dialog's id), or brings the banner back if left empty.

Classes and attributes

Class / attributeDoes
.cookie-bannerA card in the bottom corner (the start side; full width on a phone)
.cookie-banner-barA bar across the bottom instead
.cookie-title / .cookie-text / .cookie-actionsThe parts
.consent-list / .consent-itemThe rows in the settings, each with a switch
data-momo-consent="accept | reject | save"On a button: allow all / only the needed ones / what the switches say
data-momo-consent-bannerHide this once answered
data-momo-consent-open="id"Open the settings again
template[data-momo-consent-for="kind"]Added to the page only when that kind is allowed

The choice is kept in the reader's browser (local storage), not in a cookie. Momo only remembers the answer; what you need to ask, and how, depends on your country's rules.

Start

OverviewStart Getting startedStart CustomizeStart

Guides

AccessibilityGuides BreakpointsGuides ChangelogGuides Customize componentsGuides JavaScriptGuides MotionGuides OptimizeGuides PhonesGuides RebootGuides Right-to-left (RTL)Guides Stacking orderGuides Using Momo with AIGuides

Foundations

ColorsFoundations TypographyFoundations ProseFoundations Images & figuresFoundations CodeFoundations Lines & shadowsFoundations Dark modeFoundations

Forms

Checkbox & switchForms ComboboxForms Date pickerForms Date rangeForms Fields & labelsForms File uploadForms Floating labelsForms Number stepperForms PasswordForms PIN codeForms RatingForms SelectForms SliderForms Tag inputForms Time pickerForms ValidationForms

Components

AccordionComponents Alert & bannerComponents AvatarComponents BadgeComponents BreadcrumbComponents ButtonComponents Button groupComponents CalendarComponents CardComponents CarouselComponents ChartsComponents ChipsComponents CollapseComponents Command paletteComponents CommentsComponents Confirm dialogsComponents Cookie bannerComponents Data tableComponents Description listComponents Dialog & toastComponents DividerComponents DrawerComponents Dropdown menuComponents Empty stateComponents File managerComponents Filter & sortComponents Gallery & lightboxComponents Inbox & chatComponents Infinite scrollComponents KanbanComponents Keyboard shortcutsComponents List groupComponents MarqueeComponents Media objectComponents Nav overflowComponents Notification centerComponents PaginationComponents ProgressComponents Pull to refreshComponents SkeletonComponents SortableComponents SpinnerComponents Split viewComponents Stat cardComponents Steps & wizardComponents Swipe actionsComponents TableComponents TabsComponents TimelineComponents TogglerComponents Tooltip & popoverComponents TourComponents Tree viewComponents VideoComponents WhiteboardComponents

Layout

Announcement barLayout App shellLayout Back to topLayout Container & sectionLayout ExamplesLayout FooterLayout HeroLayout JumbotronLayout Mega menuLayout NavbarLayout Site sidebarLayout

Sections

Bento gridSections Blog cardsSections Call to actionSections Contact & newsletterSections FAQSections FeaturesSections Logo cloudSections PricingSections TeamSections TestimonialsSections

Utilities

OverviewUtilities State variantsUtilities Display & flexUtilities Grid & gapUtilities SpacingUtilities SizingUtilities TextUtilities Links & color strengthUtilities Position & overflowUtilities BackgroundsUtilities Borders & effectsUtilities Transforms & filtersUtilities InteractionsUtilities

Helpers

Fixed, sticky & frostedHelpers Hover & focusHelpers Hover revealHelpers Icon linkHelpers PrintHelpers Relative timeHelpers Screen reader textHelpers Scroll inHelpers ScrollspyHelpers Share buttonHelpers Skip linkHelpers StacksHelpers Stretched linkHelpers Theme toggleHelpers Truncated textHelpers

Page patterns

404 pagePage patterns Coming soonPage patterns Login & registerPage patterns SettingsPage patterns ProfilePage patterns CRM contactsPage patterns ProjectsPage patterns File manager pagePage patterns Billing & plansPage patterns Help centerPage patterns Mobile app screensPage patterns
↑ ↓ moveEnter openEsc close