# Tag chips whose × the keyboard never reaches

Source: https://easeweb.dev/learn/removable-chips
Topics: Custom inputs > Multi-selects and tag inputs say what is chosen, and chips can be removed by keyboard (WCAG 2.1.1, 4.1.2)
The fix: Make each chip's × a button element named after its chip, such as "Remove Design", and leave it in the Tab order. When a chip is removed, move focus to the next chip's button, the one before, or back to the field, and keep Backspace in the empty field only as a shortcut.
Test with: keyboard, screen reader, forced colors
References: https://www.w3.org/WAI/WCAG22/Understanding/keyboard.html https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

## What happens

A job board's profile form has a Skills field drawn as a tag input. One rounded box holds the skills added so far, Design, Research and Writing, as chips, each with a small × to remove it, and a text field after them reads "Add a skill". Typing a skill and pressing Enter adds a chip. With a mouse, clicking any × takes its chip away.

With a keyboard, Tab goes past all three chips straight into the text field, and no key ever stops on an ×. Pressing Backspace in the empty field removes the last chip, Writing, as many tag inputs do. That is the only way the keyboard can take a chip off. Someone who added Research by mistake can't remove it without first removing Writing and typing it again, and with a longer row, every chip after the one they meant.

## Why it fails

Success Criterion 2.1.1 asks that everything a mouse can do can be done with a keyboard. Removing any chip is something the mouse does, with one click on its ×. Each × is an `svg` with a click handler. An svg is not a control: it can't take focus, so Tab never stops on it and no key presses it. The browser lets any element take a click listener, and nothing warns when that element can't be reached any other way.

Backspace doesn't close the gap. It removes the last chip only, so it can't do what the mouse does on the second chip. Removing every chip after it and adding them again is a workaround a person has to work out, not a way to remove that chip.

## Who is affected

Tag inputs hold what a profile, a filter or a post is about: skills, interests, labels, recipients. A chip that can't be taken off goes out with the form, or the person gives up on the field.

## What automation and AI miss

To a generic scan, the field looks sound. The text field has a label, and an `svg` with no role is a picture that needs no name, so nothing a rule knows of is wrong. A scan doesn't see that the picture takes clicks. EaseWeb's audit reports a cross inside a chip that Tab never reaches when it has a pointer cursor and a class that names it a remove control, such as `chip-remove` (`ew:chip-remove-unreachable`). It doesn't report a real `button` taken out of the Tab order with `tabindex="-1"`, which fails in the same way. AI coding assistants asked for "a tag input with removable chips" can write the × as an svg or span with an onClick, or add `role="button"` to it without `tabindex` or keys, and add Backspace as the keyboard's way to remove. Only putting the mouse aside and trying to remove a chip in the middle shows whether it works.

## Before: an × that only a mouse can press

```html
<label for="skill-input">Skills</label>
<div class="tags">
  <span class="chips">
    <span class="chip">
      Design
      <svg class="chip-remove" data-index="0" viewBox="0 0 16 16">…</svg>
    </span>
    <span class="chip">
      Research
      <svg class="chip-remove" data-index="1" viewBox="0 0 16 16">…</svg>
    </span>
    <span class="chip">
      Writing
      <svg class="chip-remove" data-index="2" viewBox="0 0 16 16">…</svg>
    </span>
  </span>
  <input id="skill-input" type="text" placeholder="Add a skill">
</div>
```

```js
const CROSS = '<path d="M4 4l8 8m0-8l-8 8"/>';
const skills = ['Design', 'Research', 'Writing'];
function showChips() {
  chips.innerHTML = skills
    .map((skill, index) => `
      <span class="chip">
        ${skill}
        <svg class="chip-remove" data-index="${index}" viewBox="0 0 16 16">${CROSS}</svg>
      </span>`)
    .join('');
}
input.addEventListener('keydown', (event) => {
  if (event.key === 'Enter' && input.value.trim()) {
    event.preventDefault();
    skills.push(input.value.trim());
    input.value = '';
    showChips();
  } else if (event.key === 'Backspace' && !input.value && skills.length) {
    // The keyboard's only way back: the last chip.
    skills.pop();
    showChips();
  }
});
chips.addEventListener('click', (event) => {
  const cross = event.target.closest('.chip-remove');
  if (!cross) return;
  skills.splice(Number(cross.dataset.index), 1);
  showChips();
});
```

```css
.chip-remove {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  padding: 0.375rem;
  cursor: pointer;
}
```

The field has a label and adds chips from the keyboard. Removing them is where it fails:

- Each × is an `svg` that can't take focus, so Tab goes past it.
- No key presses an ×, so no chip in the middle of the row can be removed.
- Backspace in the empty field removes only the last chip.

## After: a button on every chip

```html
<label for="skill-input">Skills</label>
<div class="tags">
  <span class="chips">
    <span class="chip">
      Design
      <button type="button" class="chip-remove" data-index="0" aria-label="Remove Design">
        <svg viewBox="0 0 16 16" aria-hidden="true">…</svg>
      </button>
    </span>
    <span class="chip">
      Research
      <button type="button" class="chip-remove" data-index="1" aria-label="Remove Research">
        <svg viewBox="0 0 16 16" aria-hidden="true">…</svg>
      </button>
    </span>
    <span class="chip">
      Writing
      <button type="button" class="chip-remove" data-index="2" aria-label="Remove Writing">
        <svg viewBox="0 0 16 16" aria-hidden="true">…</svg>
      </button>
    </span>
  </span>
  <input id="skill-input" type="text" placeholder="Add a skill">
</div>
```

```js
const CROSS = '<path d="M4 4l8 8m0-8l-8 8"/>';
const skills = ['Design', 'Research', 'Writing'];
function showChips() {
  chips.innerHTML = skills
    .map((skill, index) => `
      <span class="chip">
        ${skill}
        <button type="button" class="chip-remove" data-index="${index}" aria-label="Remove ${skill}">
          <svg viewBox="0 0 16 16" aria-hidden="true">${CROSS}</svg>
        </button>
      </span>`)
    .join('');
}
input.addEventListener('keydown', (event) => {
  if (event.key === 'Enter' && input.value.trim()) {
    event.preventDefault();
    skills.push(input.value.trim());
    input.value = '';
    showChips();
  } else if (event.key === 'Backspace' && !input.value && skills.length) {
    // A shortcut for the last chip; every chip also has its button.
    skills.pop();
    showChips();
  }
});
chips.addEventListener('click', (event) => {
  const button = event.target.closest('.chip-remove');
  if (!button) return;
  const index = Number(button.dataset.index);
  skills.splice(index, 1);
  showChips();
  // The pressed button is gone: focus the next one, the one before, or the field.
  const left = chips.querySelectorAll('.chip-remove');
  (left[index] ?? left[index - 1] ?? input).focus();
});
```

```css
.chip-remove {
  display: grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}
.chip-remove svg {
  inline-size: 0.75rem;
  block-size: 0.75rem;
}
.chip-remove:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
```

1. Make each × a `button` holding the svg, and hide the svg with `aria-hidden="true"`. Tab now stops on it, and Enter or Space presses it.
2. Name it with `aria-label` after its chip, "Remove Research": the button holds only a picture, so without a label it would have no name, and "Remove" alone doesn't say which chip goes.
3. Give it a 24 by 24 pixel box and a focus ring of its own, so the small × is easy to hit and easy to see when Tab reaches it.
4. When a chip goes, its button goes with it, so move focus to the next chip's button, the one before when there is no next, or the field when no chip is left. Without that, the focused button is gone and focus falls back to the page itself.
5. Keep Backspace in the empty field as a shortcut for the last chip.

The chips keep their look. This fixes the Before and passes 2.1.1.

## Implementation decisions

Many component libraries leave the × out of the Tab order, so the whole field is one Tab stop. Ant Design's Select draws it as a span hidden from assistive technology, Select2 4.1 renders a real button with `tabindex="-1"`, and Tom Select and Tagify render it with `tabindex="-1"` as well (Tagify unless its `a11y.focusableTags` option is on). They fail in the same way as the svg. Check what your component renders, not its documentation, and look for an option that puts the × back in the Tab order.

Some components, such as MUI's Autocomplete, keep one Tab stop and move focus onto the chips with the Left arrow from the empty field, then remove the focused one with Backspace or Delete. That lets a keyboard reach every chip, but nothing on screen says the keys are there, and people who don't guess them are left with Backspace. If your component works this way, keep it, and put the buttons in the Tab order too.

Moving focus after a removal doesn't say that Research was removed; a screen reader reads the next button. If people need to hear it, that is a confirmation, covered in [add to cart buttons that change a badge and say nothing](/learn/action-confirmations). When the field suggests skills as people type, the suggestions follow [autocomplete fields with silent, mouse-only suggestions](/learn/combobox). When the chips stand for the chosen options of a dropdown, which options are chosen has to be in the code as well, covered in [multi-selects whose ticks are never read out](/learn/multi-select).

A row of chips cut short with a "+3" count needs that count to be a button that shows the hidden chips, or the hidden ones can't be reached at all. Draw each × as a stroke in `currentColor`, not a background image, so it stays in a Windows contrast theme, and keep it visible at rest, not only on hover.

## Verify the fix

1. Inspect the markup: each chip's × is a `button` with no `tabindex="-1"`, named after its chip, with its svg hidden.
2. Put the mouse aside and Tab through the field: every × takes focus with a visible ring before the text field does.
3. Remove the middle chip with Enter or Space, then the last one, and check that focus moves to another chip's button or the field each time, not lost to the page.
4. With a screen reader, Tab through the chips: each button is read as a button with the chip it removes, such as "Remove Research".
5. With a Windows contrast theme on, or forced colors emulated, check that each × and its focus ring still show.

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared chip or tag component changes.

## Limits

This is a starting pattern for a short row of chips typed in by the person. It doesn't cover chips that can be edited in place, reordered by dragging, or loaded from a server. Test the complete journey, with your real data, in the browsers and assistive technology you support.

---

Get this guide in your coding agent: MCP https://easeweb.dev/mcp (setup at https://easeweb.dev/services/developers)
