Skip to main content

Chips

Small interactive elements for people, places, tags or values, and a chip input for multi-value fields like skills, categories or email recipients.

Bootstrap’s chips docs describe the markup and CSS.

Chips

Use bsChip for standalone chips. Add .chip-icon for a leading icon, .chip-img for an image like an avatar, and a bsChipDismiss button to make it removable. Name the chip in the button’s aria-label.

Basic chip With icon Dismissible
<div class="d-flex flex-wrap gap-2">
  <span bsChip>Basic chip</span>
  <span bsChip>
    <span class="chip-icon">
      <svg width="16" height="16" fill="currentColor" viewBox="0 0 16 16" aria-hidden="true">
        <path d="M3 14s-1 0-1-1 1-4 6-4 6 3 6 4-1 1-1 1zm5-6a3 3 0 1 0 0-6 3 3 0 0 0 0 6" />
      </svg>
    </span>
    With icon
  </span>
  @if (!dismissed()) {
    <span bsChip>
      Dismissible
      <button
        type="button"
        bsChipDismiss
        aria-label="Remove Dismissible"
        (click)="dismissed.set(true)"></button>
    </span>
  }
</div>

Themed chips

Set theme to color a chip. Chips are subtle by default, which leaves room for a clear active state.

DefaultPrimaryAccentSuccessDangerWarningInfoSecondary
HTML
<div class="d-flex flex-wrap gap-2">
  <span bsChip>Default</span>
  <span bsChip theme="primary">Primary</span>
  <span bsChip theme="accent">Accent</span>
  <span bsChip theme="success">Success</span>
  <span bsChip theme="danger">Danger</span>
  <span bsChip theme="warning">Warning</span>
  <span bsChip theme="info">Info</span>
  <span bsChip theme="secondary">Secondary</span>
</div>

Active state

Set active for the solid appearance, for example for toggle-style chip filters. Use buttons with aria-pressed for chips people can toggle.

<div class="d-flex flex-wrap gap-2">
  @for (filter of filters(); track filter.name) {
    <button
      type="button"
      bsChip
      theme="primary"
      [active]="filter.active"
      [attr.aria-pressed]="filter.active"
      (click)="toggle(filter.name)">
      {{ filter.name }}
    </button>
  }
</div>

Chip input

bsChipInput is a field of chips with a ghost input for adding more. Its value is a string[], bound with [formControl], [(ngModel)], [formField] or [(value)]. Type and press Enter or , to add a chip, and Backspace to remove one. See Keyboard behavior.

JavaScript TypeScript
Press Enter or comma to add a skill.

Value: JavaScript, TypeScript

<div bsFormField>
  <label bsFormLabel>Skills</label>
  <div bsChipInput theme="primary" placeholder="Add more…" [formControl]="skills"></div>
  <small bsFormText>Press Enter or comma to add a skill.</small>
</div>
<p class="mt-3 mb-0 fg-3">Value: {{ skills.value.join(', ') }}</p>

Theme variants

Set theme on the chip input to color every chip in it. Give an input without a visible label an aria-label.

Approved Verified
Bug Critical
<div class="vstack gap-3">
  <div
    bsChipInput
    theme="primary"
    placeholder="Add status…"
    aria-label="Statuses"
    [(value)]="statuses"></div>
  <div
    bsChipInput
    theme="danger"
    placeholder="Add issue…"
    aria-label="Issues"
    [(value)]="issues"></div>
</div>

Empty state and limits

Start with no chips, and cap them with maxChips: the input is disabled once the limit is reached. Set separator to change the character that adds a chip, or to null to add chips with Enter only.

Up to 3 recipients, separated with a semicolon.
<div bsFormField>
  <label bsFormLabel>Recipients</label>
  <div
    bsChipInput
    theme="primary"
    placeholder="Type and press Enter"
    separator=";"
    maxChips="3"
    [(value)]="recipients"></div>
  <small bsFormText>Up to 3 recipients, separated with a semicolon.</small>
</div>

Disabled

Disable the chip input with the disabled input or the form control. Chips can’t be added or removed.

Read only Locked
<div bsChipInput theme="primary" aria-label="Tags" [formControl]="tags"></div>

Validation

The chip input follows its form control’s validation state inside a bsFormField.

Add at least two topics.
<div bsFormField>
  <label bsFormLabel>Topics</label>
  <div bsChipInput theme="primary" placeholder="Add topic…" [formControl]="topics"></div>
  <div bsInvalidFeedback>Add at least two topics.</div>
</div>

Keyboard behavior

In the input: Enter or the separator adds a chip, Backspace in an empty input selects the last chip, ← at the start moves to the chips, and Escape clears the text. On a chip: ← → Home End move between chips (with Shift to extend the selection), Ctrl/⌘+A selects all, and Backspace or Delete removes the selected chips. Additions and removals are announced to screen readers. Pasting a, b, c adds three chips.

Apple Banana Cherry Date
<div
  bsChipInput
  theme="accent"
  placeholder="Add fruit…"
  aria-label="Fruits"
  [(value)]="fruits"></div>

API

BsChip

Selector: [bsChip] · Exported as: bsChip

Inputs

NameTypeDefaultDescription
themeBsTheme | nullnullTheme color of the chip.
activebooleanfalseSolid appearance, for example for a selected chip.

BsChipDismiss

Selector: button[bsChipDismiss]

Inputs

NameTypeDefaultDescription
aria-labelstring'Remove'Accessible name of the button. Name the chip in it.

BsChipInput

Selector: div[bsChipInput] · Exported as: bsChipInput

Inputs

NameTypeDefaultDescription
valuestring[][]The chips. Supports two-way binding with [(value)].
themeBsTheme | nullnullTheme color of the chips.
separatorstring | null','Character that adds a chip when typed. Enter always adds one.
allowDuplicatesbooleanfalseAllows the same value more than once.
maxChipsnumber | nullnullMaximum number of chips.
placeholderstring''Placeholder of the input.
dismissiblebooleantrueShows a remove button on each chip.
createOnBlurbooleantrueAdds the typed text as a chip when focus leaves the input.
removeLabelstring'Remove'Start of the remove buttons’ accessible names, followed by the chip.
aria-labelstring | nullnullAccessible name of the input, when it has no visible label.
validation'auto' | 'valid' | 'invalid' | 'none''auto'Validation styles of the input.
disabledbooleanfalseDisables the control. Forms also disable it through the form control.

Outputs

NameTypeDescription
valueChangestring[]Emits the chips when the user adds or removes one.

Methods

NameTypeDescription
add(value)booleanAdds a chip. Returns false for an empty value, a duplicate or when full.
remove(value)booleanRemoves the first chip with the value.
clear()voidRemoves every chip.
focus()voidFocuses the input.
selectedSignal<ReadonlySet<number>>Indexes of the selected chips.