Skip to content

Pill ​

The small label in a header, a sidebar row or a settings line: a count, a branch, a status. With onClick it is a button, and with pressed a toggle.

tsx
import { Pill } from '@adecore/ui';
tsx
import { Icon, Pill } from '@adecore/ui';
import { CircleAlert, GitBranch } from 'lucide-react';
import { useState } from 'react';

export default function PillDemo() {
    const [staged, setStaged] = useState(false);

    return (
        <div className="flex flex-col items-center gap-3">
            <div className="flex flex-wrap items-center gap-2">
                <Pill>12 files</Pill>
                <Pill tone="raised">Draft</Pill>
                <Pill tone="idle">Idle</Pill>
                <Pill tone="needsYou" icon={<Icon icon={CircleAlert} size={12} />}>
                    Needs you
                </Pill>
                <Pill tone="error">Failed</Pill>
                <Pill tone="accent">New</Pill>
            </div>
            <div className="flex flex-wrap items-center gap-2">
                <Pill size="sm">12 files</Pill>
                <Pill size="sm" tone="accent">
                    New
                </Pill>
                <Pill size="sm" shape="tag" tone="accent">
                    Beta
                </Pill>
            </div>
            <div className="flex flex-wrap items-center gap-2">
                <Pill mono icon={<Icon icon={GitBranch} size={12} />}>
                    feature/export
                </Pill>
                <Pill shape="tag" tone="accent">
                    Beta
                </Pill>
                <Pill pressed={staged} onClick={() => setStaged(!staged)}>
                    Staged only
                </Pill>
            </div>
        </div>
    );
}

muted is the default tone. raised lifts a label off a sunken header so it reads as a control. idle, needsYou and error use the status colors, accent the app's accent. A tag is tighter and heavier than a pill, for the end of a line of prose. size="sm" trims the padding for dense rows. mono suits a branch name.

The ground is an alpha of the tone, so a pill reads on any surface. A pill never wraps inside itself.

Props ​

PropTypeDefault
childrenReactNodeRequired.
iconReactNodeDrawn before the text; use a 12 pixel Icon.
tone'muted' | 'raised' | 'idle' | 'needsYou' | 'error' | 'accent''muted'
shape'pill' | 'tag''pill'
size'md' | 'sm''md''sm' is 20 pixels tall instead of 24.
monobooleanfalse
onClick() => voidMakes the pill a button.
pressedbooleanMakes the button a toggle (aria-pressed).
disabledbooleanOnly with onClick.
classNamestring
refRef<HTMLElement>A <span>, or a <button> with onClick.

PillProps is an exported type.

Licenses and third-party notices are listed in each package.