Skip to content
v0.9.1
Components

Keyboard shortcuts

Give any button a key with data-momo-shortcut, show keys that match the person's computer (⌘ on a Mac, Ctrl elsewhere), and let people press ? for the list of everything they can press.

Keys

Write <kbd data-momo-keys="mod+k"></kbd> and Momo draws the right keys. mod means ⌘ on a Mac and Ctrl everywhere else. Steps with a space are a sequence: g d means press G, then D. A single key is just <kbd>Esc</kbd>.

Search · Save · Redo · Go to calendar · Move up · Help ?

small · plain

<p>Search <kbd data-momo-keys="mod+k"></kbd> · Save <kbd data-momo-keys="mod+s"></kbd> · Redo <kbd data-momo-keys="mod+shift+z"></kbd> · Go to calendar <kbd data-momo-keys="g c"></kbd> · Move up <kbd data-momo-keys="alt+up"></kbd> · Help <kbd>?</kbd></p>
<p><kbd class="kbd-sm" data-momo-keys="mod+enter"></kbd> small · <kbd class="kbd-plain" data-momo-keys="mod+enter"></kbd> plain</p>

Buttons with shortcuts

Pressing the key clicks the button (on a field, it puts the cursor in it). The button flashes so people see what happened. Try N, , / and on this page.

<div class="form-field">
  <label class="form-label" for="sc-search">Filter tasks</label>
  <input class="form-control" id="sc-search" type="search" placeholder="Press / to jump here" data-momo-shortcut="/" data-momo-shortcut-desc="Filter tasks" data-momo-shortcut-group="Tasks">
</div>
<div class="btn-row" data-momo-shortcut-group="Tasks">
  <button class="btn btn-brand" type="button" data-momo-shortcut="n" data-momo-tooltip="New task" data-momo-toast="New task" data-momo-toast-text="Opened with N">
    <i class="mi mi-plus" aria-hidden="true"></i> New task
  </button>
  <button class="btn" type="button" data-momo-shortcut="mod+s" data-momo-shortcut-desc="Save changes" data-momo-toast="Saved" data-momo-toast-color="green">
    Save <kbd data-momo-keys="mod+s"></kbd>
  </button>
  <button class="btn btn-ghost" type="button" data-momo-shortcut="g c" data-momo-shortcut-group="Go to" data-momo-shortcut-desc="Go to calendar" data-momo-toast="Calendar" data-momo-toast-text="Opened with G then C">
    <i class="mi mi-calendar" aria-hidden="true"></i> Calendar
  </button>
</div>

A shortcut without a modifier (N, /, g c) does nothing while someone is typing in a field. Shortcuts with or Ctrl still work there. While a dialog is open, only the shortcuts inside it (and ?) work. A tooltip on the button shows its keys, and aria-keyshortcuts is added for screen readers.

Shortcut list

Put an empty <dialog data-momo-shortcuts-help> on the page: pressing ? opens it with every shortcut, grouped (by data-momo-shortcut-group) and searchable. Press ? now, or use the button.

Keyboard shortcuts

<button class="btn" type="button" data-momo-dialog="sc-help"><i class="mi mi-keyboard" aria-hidden="true"></i> Keyboard shortcuts <kbd class="kbd-plain">?</kbd></button>
<dialog class="dialog dialog-lg" id="sc-help" data-momo-shortcuts-help aria-labelledby="sc-help-title">
  <div class="dialog-header">
    <h2 class="dialog-title" id="sc-help-title">Keyboard shortcuts</h2>
    <button class="btn btn-icon btn-sm btn-ghost" type="button" data-momo-close aria-label="Close"><i class="mi mi-x"></i></button>
  </div>
  <div class="dialog-body">
    <div class="shortcuts-search form-icon"><i class="mi mi-search" aria-hidden="true"></i><input class="form-control" type="search" placeholder="Search shortcuts" aria-label="Search shortcuts"></div>
  </div>
</dialog>

A written cheat sheet

For a help page, write the list yourself with the same classes: .shortcuts holds .shortcuts-groups, each a title and a dl.shortcuts-list of .shortcut rows.

Editing

Bold
Add a link
Send

Go to

Inbox
Projects
Next item
<div class="shortcuts">
  <section class="shortcuts-group">
    <h3 class="shortcuts-title">Editing</h3>
    <dl class="shortcuts-list">
      <div class="shortcut"><dt>Bold</dt><dd><kbd data-momo-keys="mod+b"></kbd></dd></div>
      <div class="shortcut"><dt>Add a link</dt><dd><kbd data-momo-keys="mod+k"></kbd></dd></div>
      <div class="shortcut"><dt>Send</dt><dd><kbd data-momo-keys="mod+enter"></kbd></dd></div>
    </dl>
  </section>
  <section class="shortcuts-group">
    <h3 class="shortcuts-title">Go to</h3>
    <dl class="shortcuts-list">
      <div class="shortcut"><dt>Inbox</dt><dd><kbd data-momo-keys="g i"></kbd></dd></div>
      <div class="shortcut"><dt>Projects</dt><dd><kbd data-momo-keys="g p"></kbd></dd></div>
      <div class="shortcut"><dt>Next item</dt><dd><kbd data-momo-keys="j"></kbd></dd></div>
    </dl>
  </section>
</div>

In menus

A combo at the end of a menu item is shown small and quiet.

<button class="btn" type="button" data-momo-menu="sc-menu">Edit <i class="mi mi-chevron-down" aria-hidden="true"></i></button>
<div class="menu" id="sc-menu">
  <button class="menu-item" type="button">Undo <kbd data-momo-keys="mod+z"></kbd></button>
  <button class="menu-item" type="button">Redo <kbd data-momo-keys="mod+shift+z"></kbd></button>
  <div class="menu-divider"></div>
  <button class="menu-item" type="button">Duplicate <kbd data-momo-keys="mod+d"></kbd></button>
</div>

JavaScript

Add shortcuts from code. Leave out the function to only list a key that something else already handles. Every shortcut fires a cancelable momo:shortcut event first.

const stop = Momo.shortcuts.add('mod+enter', () => form.requestSubmit(), { desc: 'Send', group: 'Editor' });
stop();                                    // remove it again

Momo.shortcuts.add('mod+k', null, { desc: 'Search', group: 'General' });   // listed only
Momo.shortcuts.label('mod+shift+z');       // '⌘⇧Z' on a Mac, 'Ctrl+Shift+Z' elsewhere
Momo.shortcuts.list();                     // everything, for your own help page

Good to know

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