Component Blueprints

Pills

information

You are currently viewing a sandbox preview version of Summer ’25 | Go back to Spring ’25

A pill represents an object that can be viewed with or without an icon.
Pill Label

About Pills#

To create a pill, apply the .slds-pill class on a <span>.

Depending on your context, you will either need a base pill (linked or unlinked), or a pill option inside of a listbox. Note that a linked pill should not be used as a pill option inside of a listbox.

For linked pills, a modifier class of slds-pill_link needs to be added to the existing <span> with the class name of slds-pill. You need an <a> inside of the span with the slds-pill_link class. The <a> will get the class name of slds-pill__action. This will treat the interactions differently from an unlinked pill option inside of a listbox.

For both linked and unlinked pills, a <span> with the class name of slds-pill__label should contain the string of text describing the pill object.

Additionally, a pill can have an icon or image that sits to the left-hand side of the .slds-pill__label. That icon or image should receive the class .slds-pill__icon_container.

You may also want the functionality to remove the pill as a selection. An "X" icon is normally used and will sit to the right-hand side of the .slds-pill__label. That icon should receive the class .slds-pill__remove.

A .slds-pill_container can be used as a visual container for multiple pill(s).

Mobile#

On mobile devices, such as phones and other devices that have touch as the primary method of interaction, pills will have an increased size to accommodate tapping with a finger instead of the more precise mouse cursor.

Below is a live example of what to expect in that context. No code changes are needed in the Salesforce platform context as this change occurs automatically in Salesforce native mobile applications. For those users not on the Salesforce platform, these modifications will occur automatically when the secondary touch stylesheet is loaded and the device has touch as the primary method of interaction.

Base#

<span class="slds-pill slds-pill_link">
  <a href="#" class="slds-pill__action" title="Full pill label verbiage mirrored here">
    <span class="slds-pill__label">Pill Label</span>
  </a>

Examples#

With Icon#

Pill Label
<span class="slds-pill slds-pill_link">
  <span class="slds-pill__icon_container">
    <span class="slds-icon_container slds-icon-standard-account" title="Account">
      <svg class="slds-icon" aria-hidden="true">

With Avatar#

<span class="slds-pill slds-pill_link">
  <span class="slds-pill__icon_container">
    <span class="slds-avatar slds-avatar_circle" title="User avatar">
      <img alt="Person name" src="/assets/images/avatar2.jpg" title="User avatar" />

Pill with Container#

<div class="slds-pill_container">
  <span class="slds-pill slds-pill_link">
    <a href="#" class="slds-pill__action" title="Full pill label verbiage mirrored here">
      <span class="slds-pill__label">Pill Label</span>

States#

Error#

WarningPill Label
<span class="slds-pill slds-pill_link slds-has-error">
  <span class="slds-pill__icon_container">
    <span class="slds-icon_container" title="Error">
      <svg class="slds-icon slds-icon-text-error" aria-hidden="true">

Truncated#

The pills component will respect the width of its parent and truncate if necessary.

<div class="slds-pill_container">
  <span class="slds-pill slds-pill_link">
    <a href="#" class="slds-pill__action" title="Pill label that is longer than the area that contains it">
      <span class="slds-pill__label">Pill label that is longer than the area that contains it</span>

Showing the full text of a truncated pill as a tooltip.

Pill label that is longer than the area that contains it
<span class="slds-pill" aria-selected="true">
  <div class="slds-popover slds-popover_tooltip slds-nubbin_bottom-left" role="tooltip" id="help" style="position:absolute;top:-45px;left:-2px">
    <div class="slds-popover__body">Pill label that is longer than the area that contains it</div>
  </div>

Listbox Of Pill Options#

  • Pill Label
  • Pill Label
<div class="slds-pill_container">
  <ul class="slds-listbox slds-listbox_horizontal" aria-label="Selected Options:" aria-describedby="listbox-pill-default">
    <li class="slds-listbox-item">
      <span class="slds-pill">

A Listbox of Pills is a way to display a list of selected options when performing user input, usually from a multi-select Combobox, Lookup or Picklist.

Note that we can use a linked or unlinked pill as a pill item inside of a listbox

Accessibility#

Interaction requirements

  • Only 1 focused Pill per set of Pills
  • The remove button is a focusable element and can be clickable.

Keyboard navigation

  • The first pill in the list will be take user focus initially, when tabbed to
  • Right arrow key will move focus to the next pill in the list
  • Left arrow key will move focus to the previous pill in the list
  • Left arrow key when on the first pill should cycle user focus to the last pill
  • Right arrow key when on the last pill should cycle user focus to the first pill
  • On removing of the pill, the focus should then be placed on the nearest pill
    • When on the last pill, place user focus on the previous pill
    • When on the first pill, place user focus on the next pill
    • When on the only pill, place user focus on the listbox or any input element the pill might be associated with

Examples#

With Icon#

  • Pill Label
  • CasePill Label
<div class="slds-pill_container">
  <ul class="slds-listbox slds-listbox_horizontal" aria-label="Selected Options:" aria-describedby="listbox-pill-with-icon">
    <li class="slds-listbox-item">
      <span class="slds-pill">

With Avatar#

  • Person namePill Label
  • Person namePill Label
<div class="slds-pill_container">
  <ul class="slds-listbox slds-listbox_horizontal" aria-label="Selected Options:" aria-describedby="listbox-pill-with-avatar">
    <li class="slds-listbox-item">
      <span class="slds-pill">

Layout#

Bare#

  • Pill Label
  • Pill Label
<div class="slds-pill_container">
  <ul class="slds-listbox slds-listbox_horizontal" aria-label="Selected Options:" aria-describedby="listbox-pills-bare">
    <li class="slds-listbox-item">
      <span class="slds-pill slds-pill_bare">

Styling Hooks Overview#

The component styling hooks in this table are compatible with SLDS 1, but they aren’t compatible with SLDS 2.

Use these CSS Custom Properties as hooks to customize this SLDS component with your own style. For more information, read the technical documentation.

CategoryStyling Hook NameValue Type(s)Fallback Value
Box Shadow
--slds-c-pill-action-shadow
String1, 0 0 3px #0176d3
--slds-c-pill-label-shadow-focus
String1, 0 0 3px #0176d3
--slds-c-pill-shadow
String
--slds-c-pill-shadow-focus
String1, 0 0 3px #0176d3
Color
--slds-c-pill-color-background
Color100, white
--slds-c-pill-color-background-hover
Color95, #f3f3f3
--slds-c-pill-color-border
Color4, #e5e5e5
--slds-c-pill-container-color-background
Color100, white
--slds-c-pill-error-color-border
Color40, #ea001e
--slds-c-pill-error-color-border-active
Color40, #ea001e
--slds-c-pill-text-color-error
Color40, #ea001e
Radius
--slds-c-pill-radius-border
Dimension0.25rem
Sizing
--slds-c-pill-sizing-border
Dimension1px
Spacing
--slds-c-pill-container-spacing-blockend
Dimension0.125rem
--slds-c-pill-container-spacing-blockstart
Dimension0.125rem
--slds-c-pill-container-spacing-inlineend
Dimension0.125rem
--slds-c-pill-container-spacing-inlinestart
Dimension0.125rem
--slds-c-pill-spacing-blockend
Dimension0.125rem
--slds-c-pill-spacing-blockstart
Dimension0.125rem
--slds-c-pill-spacing-inlineend
Dimension
--slds-c-pill-spacing-inlinestart
Dimension0.125rem
Text
--slds-c-pill-line-height
Number1.5

Overview of CSS Classes#

Selector.slds-pill
Summary

Initializes pill

Supportdev-ready
Restrictspan
VariantTrue
Selector.slds-pill_bare
Summary

Modifier that removes border and background from a pill

Restrict.slds-pill
ModifierTrue
Selector.slds-pill__label
Summary

Line of text inside a pill

Restrict.slds-pill a, .slds-pill span
Selector.slds-pill__icon_container
Summary

Initializes pill icon or avatar that sits to the left of the label

Restrict.slds-pill span
Selector.slds-pill__remove
Summary

Initializes remove icon in pill that sits to the right of the label

Restrict.slds-pill button, .slds-pill span
Selector.slds-pill_link
Summary

Creates a pill with a hyperlink

Restrict.slds-pill
Selector.slds-pill__action
Summary

Actionable element inside of pill with hyperlink

Restrict.slds-pill_link a
Selector.slds-has-error
Summary

Pill error styles

Restrict.slds-pill
ModifierTrue
Selector.slds-listbox [role="listbox"]
Summary

A listbox of Pills is a way to display a list of selected options when performing user input

Supportdev-ready
Restrict.slds-pill
VariantTrue

Pills Release Notes

2.27.0

Changed

  • Updated focus state style of all the Pill variants

2.24.0

Changed

  • Fixed tap target size of close icon in Pill to meet 24x24.

Added

  • Added new truncated state for Pill as a tooltip.
  • Updated focus style.

2.23.1

Changed

  • Added Button element for Pill remove feature. Now remove button is focusable and can be clickable.
  • Removed non applicable ARIA attributes after markup updates.

2.17.0

Added

  • Added reassignment of Styling Hooks for component states.

2.14.0

Changed

  • Fixed incorrect styling hooks on focus state, suffix is now using -focus vs -active.

2.13.0

Changed

  • The assistive text for the listbox of pills has been moved out of the individual pills to remove repetition for users with screenreaders.
  • Addressed layout inconsistencies for touch styles
  • Clarified documentation around when linked pills can be used

Added

  • Enabled styling hooks for pill. See pill's styling hooks overview table for a full listing of the currently available hooks.
  • Added example for Listbox of Pills in Group

Changed

  • Removed redundant border-radius on .slds-pill:focus

2.11.7

Added

  • Added documentation and examples for mobile/touch context

2.10.0

Changed

  • For touch devices:
    • Increase tap target height of .slds-pill to $height-tappable-small (2rem) and change horizontal padding to $spacing-small (0.75rem)
    • Update spacing between pills to $spacing-xx-small (0.25rem)
    • Set padding of pill container to $spacing-xx-small (0.25rem)
    • Set font-size of .slds-pill__label to $font-size-4 (0.875rem)
    • Update the padding of .slds-pill__action
    • Adjust the positioning of the icon inside a pill after padding updates