This is version 4 beta of Forma 36Go back to last stable version 3
Forma 36

Pill

Pills represent a set of one or multiple objects which can be entered or changed by the user. By default, pills can be removed by the user. When necessary, the order of pills can be changed by the user using drag and drop. They are used to represent complex entities in small blocks such as contact details. Contentful Pills are are used to render transition locales and tag elements.

Table of contents

How to use Pill

  • use Pill to represent data like contact details or tagging
  • it can be used for web content that needs to be labeled, categorized, or organized using keywords that describe them.

Code examples

Example of usage with draggable and close option

Example of the Pill component with dragHandle, in that case Icon.

Content recommendations:

  • Be sure the pill text is clear and concise.

Accessibility

  • Label value is passed in the component as a title in the span element, like follows title={label}.
  • The default drag component has a aria-label="Drag handler", custom drag handle components should also include an aria-label, as shown on the example

Props

NameRequiredDefaultTypeDescription
labelrequiredstringText that will be shown on the pill
dragHandleComponentReactNodeCustom component to be used as handler for the drag functionality.
onClose() => voidFunction that handles when the close icon is clicked. Close icon visibility depends on if this property is set.
onDrag() => voidFunction that handles when the pill is dragged. Drag icon visibility depends on if this property is set.
variantidle
"idle"
"active"
"deleted"
Determines style variation of Pill component
classNamestringCSS class to be appended to the root element
styleCSSPropertiesAccepts a JavaScript object with camelCased properties rather than a CSS string
testIdstringA [data-test-id] attribute used for testing purposes