Pill
A small tinted label for a status or a category.
Overview
A short word that says what state or kind something is: paid, draft, flaky.
Status
Do
PaidDueOverdueDraft
import { Cluster, Pill } from "@hackcove/ui";
<Cluster>
<Pill tone="emerald" dot>
Paid
</Pill>
<Pill tone="amber" dot>
Due
</Pill>
<Pill tone="red" dot>
Overdue
</Pill>
<Pill dot>Draft</Pill>
</Cluster>Don't
PaidDueOverdue
import { Cluster, Pill } from "@hackcove/ui";
<Cluster>
<Pill tone="violet" dot>
Paid
</Pill>
<Pill tone="violet" dot>
Due
</Pill>
<Pill tone="violet" dot>
Overdue
</Pill>
</Cluster>Link
Do
import { Pill } from "@hackcove/ui";
<Pill href="#flakes" tone="amber" round>
3 flaky
</Pill>href: it dims on hover and carries the focus ring.Don't
import { Pill, TextLink } from "@hackcove/ui";
<TextLink href="#flakes">
<Pill tone="amber" round>
3 flaky
</Pill>
</TextLink>TextLink is two parts doing one job, and the Pill's own hover dim and focus ring go unused. Give the Pill the href.Usage
- Choose
toneby meaning:emeraldfor done or good,amberfor waiting or at risk,redfor failed,slatefor neutral or draft;blue,skyandvioletfor kinds and categories. dotadds a leading dot in the Pill's colour;roundswaps the rounded-square corners for a full pill shape. Use one look across a view.- A Pill that goes somewhere takes
href(orrenderfor your router'sLink,externalfor a new tab); one that does something takesonClick. - A Pill beside a card's title is the Card's
status, not a hand-built row. - A message to read is a
Callout, and an action is aButton.
Accessibility
- A plain Pill is a
<span>; the dot isaria-hidden. The tone is colour only, so the text must say the status itself. - With
hrefit is a link and withonClicka<button type="button">; both dim on hover and show the focus ring. externaladdstarget="_blank"andrel="noreferrer".
API
Pill
A small tinted label; dot adds a leading dot in the pill's own text colour, round swaps the rounded-md corners for a full pill shape. href makes it a link (a plain <a>, or with render the app's own router <Link>: render={(p) => <Link to="/flakes" {...p} />}; external opens a new tab) and onClick makes it a button, each with a hover dim and the focus ring.
dot- Type
boolean- Default
false
externalOpens in a new tab: adds target="_blank" and rel="noreferrer".
- Type
boolean- Default
false
href- Type
string
onClickA Pill that is a button: runs onClick. Defaults to type="button".
- Type
MouseEventHandler<HTMLButtonElement>
render- Type
LinkRender
round- Type
boolean- Default
false
tone- Type
"slate" | "amber" | "emerald" | "blue" | "red" | "violet" | "sky"- Default
slate