Skip to content
v0.9.1
Forms

Tag input

Type a word, press Enter or a comma, and it becomes a chip. For skills, labels, recipients and filters. Add data-momo-tags to a normal text field: it stays in the form and sends the tags joined by commas.

Basic

Pasting a, b, c (or several lines) adds them all. Typing the same tag twice shakes the one already there.

Press Enter or a comma after each one.

<div class="form-field">
  <label class="form-label" for="tg-skills">Skills</label>
  <input class="form-control" id="tg-skills" name="skills" value="Design, CSS" placeholder="Add a skill" data-momo-tags>
  <p class="form-hint">Press Enter or a comma after each one.</p>
</div>

Keyboard

KeyDoes
Enter or ,Adds what you typed
Backspace in an empty fieldMarks the last chip; press again to remove it
← in an empty fieldMoves onto the chips; ← → walk them, Delete removes one
↓ ↑Walk the suggestions
EscCloses the suggestions

Leaving the field keeps what you typed as a tag. Every add and remove is read out to screen readers.

Suggestions

Point list at a <datalist>. Matches show as you type (or press ↓), and you can still add your own. data-color on an option colors its chip.

<div class="form-field">
  <label class="form-label" for="tg-labels">Labels</label>
  <input class="form-control" id="tg-labels" name="labels" value="bug" placeholder="Add labels" list="tg-label-list" data-momo-tags>
  <datalist id="tg-label-list">
    <option value="bug" data-color="red">Bug</option>
    <option value="feature" data-color="green">Feature</option>
    <option value="design" data-color="violet">Design</option>
    <option value="docs" data-color="cyan">Docs</option>
    <option value="urgent" data-color="orange">Urgent</option>
    <option value="question" data-color="yellow">Question</option>
  </datalist>
</div>

Only from the list

data-strict accepts suggestions only. data-max sets a limit: the field stops taking more once it is full.

Up to 3 people.

<div class="form-field">
  <label class="form-label" for="tg-team">Assign to</label>
  <input class="form-control" id="tg-team" name="team" placeholder="Pick up to 3 people" list="tg-people" data-strict data-max="3" data-color="yellow" data-momo-tags>
  <datalist id="tg-people">
    <option value="sallie">Sallie Wade</option>
    <option value="eula">Eula Horton</option>
    <option value="lucy">Lucy Fox</option>
    <option value="ina">Ina Hogan</option>
    <option value="victoria">Victoria Perez</option>
  </datalist>
  <p class="form-hint">Up to 3 people.</p>
</div>

Sizes and states

.form-control-sm / -lg carry over. So do .is-invalid, .is-valid, disabled and required (needs at least one tag).

<div class="form-grid">
  <input class="form-control form-control-sm" value="small, tags" aria-label="Small" data-momo-tags>
  <input class="form-control is-invalid" value="too long a tag name here" aria-label="Invalid" data-momo-tags>
  <input class="form-control" value="locked, tags" aria-label="Disabled" disabled data-momo-tags>
</div>

Chips on their own

.tag is the chip by itself, for showing tags on cards and rows. .tag-<color> and .tag-ink color it, a .tag-remove button makes it removable (you handle the click), and .tag-list lines them up.

  • Design
  • Done
  • Q4
  • Owner: me
  • Due this week
<ul class="tag-list" aria-label="Filters">
  <li class="tag">Design</li>
  <li class="tag tag-green"><i class="mi mi-check" aria-hidden="true"></i> Done</li>
  <li class="tag tag-violet">Q4</li>
  <li class="tag tag-ink">Owner: me</li>
  <li class="tag tag-yellow"><span class="tag-text">Due this week</span><button class="tag-remove" type="button" aria-label="Remove Due this week"><i class="mi mi-x" aria-hidden="true"></i></button></li>
</ul>

JavaScript

The real field fires input and change, plus momo:tags with detail.tags, detail.added and detail.removed. Form resets put the starting tags back.

const skills = document.querySelector('[name=skills]');
skills.addEventListener('momo:tags', (e) => console.log(e.detail.tags));

Momo.tags.get(skills);              // ['Design', 'CSS']
Momo.tags.add(skills, 'Figma');
Momo.tags.remove(skills, 'CSS');
Momo.tags.clear(skills);

Use data-separator for a different separator (for example ;).

Variables

VariableDefault
--tag-bgbrand soft
--tag-colorink
--field-border / --field-shadowline / brand (focus ring)

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