Skip to Content
Pill ALPHA

Pill

A pill is a visual representation of an attribute, usually representing tags or metrics.

#

Documentation

#

Usage

import { Pill } from "@optiaxiom/react/unstable"; export function App() { return <Pill>Label</Pill>; }

#

Different sizes

Use the size prop to modify the size of the button.

import { Group } from "@optiaxiom/react"; import { Pill } from "@optiaxiom/react/unstable"; export function App() { return ( <Group gap="16"> <Pill size="xs">Extra Small</Pill> <Pill>Small</Pill> </Group> ); }

#

Dismissible

Use the onDismiss prop to show a close button inside the pill.

"use client"; import { toaster } from "@optiaxiom/react"; import { Pill } from "@optiaxiom/react/unstable"; export function App() { return <Pill onDismiss={() => toaster.create("Dismissed pill")}>Label</Pill>; }

#

Disabled state

Set the disabled prop to true to disable pills and prevent any interactions.

Include visible text that explains why it’s disabled: a disabled pill leaves the tab order, so keyboard and screen reader users can’t reach a tooltip on it.

Archived articles are read only.

import { Group, Text } from "@optiaxiom/react"; import { Pill } from "@optiaxiom/react/unstable"; export function App() { return ( <Group gap="8"> <Pill disabled>Archived</Pill> <Text color="fg.secondary" fontSize="sm"> Archived articles are read only. </Text> </Group> ); }

#

Grouping pills

Use the <PillGroup /> component to group related pills together.

import { Pill, PillGroup } from "@optiaxiom/react/unstable"; export function App() { return ( <PillGroup> <Pill>Configured Commerce</Pill> <Pill>Campaign</Pill> </PillGroup> ); }

Badge

Use to emphasize a status, count, state or value.

Button

Button component is used to trigger actions.

#

Props

#

Pill

import { Pill } from "@optiaxiom/react/unstable";

Supports all Box props in addition to its own. Renders a <div> element.

Prop

asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read the Composition guide for more details.

false | true

children

ReactNode

className

string

onDismiss

Show a close button inside the pill and invoke this callback when the pill is clicked.

() => void

readOnly

When true, the pill is rendered as a non-interactive span element instead of a button. Use this for display-only pills that don’t respond to clicks.

false | true

size

Control the size of the pill.

"xs" | "sm"

Default: sm

#

PillGroup

import { PillGroup } from "@optiaxiom/react/unstable";

Supports all Box props in addition to its own. Renders a <div> element.

Prop

alignItems

Set the element’s align-items CSS property. Defaults to center when flexDirection='row', and stretch when flexDirection='column'.

ResponsiveValue<"stretch" | "center" | "end" | "start" | "normal">

asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read the Composition guide for more details.

false | true

children

ReactNode

className

string

flexDirection

Set the element’s flex-direction CSS property.

Default: ‘row’ (CSS standard)

ResponsiveValue<"column" | "column-reverse" | "row" | "row-reverse">

#

Accessibility

#

Labels

  • A disabled pill leaves the tab order. Explain why it’s disabled in visible text nearby.

#

Changelog

#

1.6.0

  • Added onDismiss prop

#

0.12.4

  • Added component
Last updated on