Pills should be used when representing an input, as a way to filter content, or to represent an attribute.
<Pill>Item 1</Pill>
<Pill clickable>Item 2</Pill>
<Pills><Pill>Item 1</Pill></Pills>
<TogglePill>On</TogglePill>
- Shape:
circular
, rounded
- Size:
smaller
, small
, medium
- Appearance:
Filled Grey (filled)
, Filled White (inverted)
, Outline
export interface PillGroupProps extends UIComponentProps, ChildrenComponentProps, ContentComponentProps {
/**
* Accessibility behavior if overridden by the user.
*/
accessibility?: Accessibility<PillGroupBehaviorProps>;
}
export interface PillProps extends UIComponentProps, ContentComponentProps<ShorthandValue<BoxProps>> {
/**
* Accessibility behavior if overridden by the user.
*/
accessibility?: Accessibility<PillBehaviorProps>;
/**
* A Pill can be sized.
*/
size?: Extract<SizeValue, 'smaller' | 'small' | 'medium'>;
/**
* A Pill can be rectangular
*/
rectangular?: boolean;
/**
* A Pill can be filled, inverted or outline
*/
appearance?: 'filled' | 'inverted' | 'outline';
/**
* A Pill can be disbled
*/
disabled?: boolean;
/**
* A Pill can be actionable
*/
actionable?: boolean;
/**
* A PillAction shorthand for the action slot.
*/
action?: ShorthandValue<PillActionProps>;
/**
* A PillAction shorthand for the action slot.
*/
icon?: ShorthandValue<PillIconProps>;
/**
* A PillImage shorthand for the image slot.
*/
image?: ShorthandValue<PillImageProps>;
/**
* Called after user will dismiss the Pill.
* @param event - React's original SyntheticEvent.
* @param data - All props.
*/
onDismiss?: ComponentEventHandler<PillProps>;
/**
* A Pill can be selectable
*/
selectable?: boolean;
/**
* A Pill state for selection
*/
selected?: boolean;
/**
* A Pill can be selected by default
*/
defaultSelected?: boolean;
/**
* A Pill can have custom selected indicator
*/
selectedIndicator?: ShorthandValue<PillIconProps>;
/**
* Called after user change selected state
* @param event - React's original SyntheticEvent.
* @param data - All props.
*/
onSelectionChange?: ComponentEventHandler<PillProps>;
}
<Pill />
<Pill actionable />
<Pills>
<Pill />
</Pills>
<span> ... </span>
<span role="button"> ... </span>
<div role="listbox">
<span role="option"> ... </span>
</div>
- Tab key to set focus on the Pill
- Arrow keys navigates between
Pill
- Esc key dismiss the
Pill
key |
state |
title |
left/right/up/down |
OnFocus |
Role “button” or "option", aria-describedby=”Press enter or delete to remove” |
Delete/Backspace |
OnDelete |
The pill is removed since there is only one primary action |
Backspace/Ctrl + X |
OnDelete |
Backspace/Ctrl + X |
Pill with popup
- Popup opens after Xms of mouse hover state
- Clicking in the Pill open popup and clicking outside should dimiss it
key |
state |
title |
left/right/up/down |
OnFocus |
Role "button" or "option", aria-label=”Press enter or delete to remove” |
Esc |
OnFocus |
Dismis popup |
Enter/Space |
OnFocus |
Open Popup |
Backspace/Ctrl + X |
OnDelete |
Backspace/Ctrl + X |
Pill with right click (invoking context menu)
- Right click anywhere on pill surface invokes content menu. Context menu appears close to cursor location on pill
- Clicking or tapping anywhere outside of menu to dismiss
key |
state |
title |
Esc |
OnFocus |
Dismis context menu |
Shift+F10 |
OnFocus |
Open context menu |
- Click toggles Pill's selected state
key |
state |
title |
Enter/Space |
OnFocus |
Toggle selected state |