Alpha component
PillNext component is subject to major changes and is for experimentation purposes only. Not recommended for use in production software.
PillNext component is subject to major changes and is for experimentation purposes only. Not recommended for use in production software.
PillNext is a refreshed pill component for communicating category or metadata in a compact format. It supports four visual variants, an optional leading icon with tooltip, and an optional removable end icon.
Alpha: This component is in alpha. Props may change before promotion to stable.
import { PillNext } from '@contentful/f36-pill-next';
function PillNextVariantsExample() {return (<Stack flexDirection="row"><PillNext label="Secondary" variant="secondary" /><PillNext label="Primary" variant="primary" /><PillNext label="Warning" variant="warning" /><PillNext label="Negative" variant="negative" /></Stack>);}
function PillNextRemovableExample() {return (<Stack flexDirection="row"><PillNext label="Removable" onRemove={() => {}} /><PillNext label="Disabled remove" onRemove={() => {}} isDisabled /></Stack>);}
function PillNextWarningExample() {return (<Stack flexDirection="row"><PillNextlabel="Restricted"variant="warning"tooltipContent="This tag has restricted visibility"onRemove={() => {}}/><PillNextlabel="Deleted"variant="negative"tooltipContent="This tag was deleted"onRemove={() => {}}/></Stack>);}
Name | Type | Default |
|---|---|---|
| label required | string | |
| children | ReactNode Content rendered between label and remove button. | |
| className | string CSS class to be appended to the root element | |
| isDisabled | false true | |
| onRemove | () => void | |
| removeButtonClassName | string Additional className applied to the remove button. | |
| removeButtonLabel | string | "Remove" |
| removeIconColor | string Color of the remove icon. Defaults to currentColor (inherits from button). | |
| testId | string A [data-test-id] attribute used for testing purposes | |
| tooltipContent | string Only rendered for variants with a leading icon (warning/negative). | |
| tooltipProps | Omit<CommonProps & WithEnhancedContent & TooltipInternalProps, "content" | "children" | "withTriggerWrapper"> | |
| variant | "secondary" "primary" "warning" "negative" |
| Variant | Use case | | --------- | ---------------------------------------------------- | | secondary | Default. General-purpose category or metadata label. | | primary | Highlighted or active selection. | | warning | Restricted access or limited visibility. | | negative | Deleted or errored state. |
tooltipContent is provided, the leading icon becomes keyboard-focusable so screen reader and keyboard users can access the explanation.Tag is a metadata-oriented pill with a required badge slot. It composes the same visual base as PillNext and adds a badge qualifier between the label and end icon. Use Tag when a label needs supporting metadata; use PillNext when a single label is enough.
import { Tag } from '@contentful/f36-pill-next';
function TagBasicExample() {return (<Stack flexDirection="row"><Taglabel="Secondary"variant="secondary"badge={<Badge variant="secondary">Draft</Badge>}/><Taglabel="Primary"variant="primary"badge={<Badge variant="primary">Published</Badge>}/><Taglabel="Warning"variant="warning"badge={<Badge variant="warning">Restricted</Badge>}/><Taglabel="Negative"variant="negative"badge={<Badge variant="negative">Deleted</Badge>}/></Stack>);}
function TagWithBadgeExample() {return (<Stack flexDirection="row"><Taglabel="Blog post"variant="secondary"badge={<Badge variant="secondary">Draft</Badge>}/><Taglabel="Landing page"variant="primary"badge={<Badge variant="primary">Published</Badge>}/></Stack>);}
function TagRemovableExample() {return (<Stack flexDirection="row"><Taglabel="Category"variant="secondary"badge={<Badge variant="secondary">3 items</Badge>}onRemove={() => console.log('removed')}/><Taglabel="Restricted"variant="warning"badge={<Badge variant="warning">Limited</Badge>}tooltipContent="This tag has restricted visibility"onRemove={() => console.log('removed')}/></Stack>);}
The badge prop is required and accepts any React node. It is rendered between the label and the remove button. The spec does not prescribe a specific badge component — consumers supply the rendered element (e.g. <Badge> from @contentful/f36-badge).
The badge variant does not have to correspond with the Tag variant — for example, a secondary Tag can contain a primary or warning badge to communicate independent status information.
Tag inherits all accessibility behaviour from PillNext. The badge is rendered inline and visible to screen readers as part of the pill's content.