Pill Group
A row of pill buttons for choosing one filter.
import { useState } from "react"
import { PillGroup } from "@dapplelight/signet-ui/components/pill-group"
const statuses = [
{ value: "", label: "All" },
{ value: "paid", label: "Paid" },
{ value: "pending", label: "Pending" },
{ value: "overdue", label: "Overdue" },
]
export function Demo() {
const [status, setStatus] = useState("")
return <PillGroup options={statuses} value={status} onChange={setStatus} />
}Installation
npm i @dapplelight/signet-uiUsage
import { useState } from "react"
import { PillGroup } from "@dapplelight/signet-ui/components/pill-group"
const statuses = [
{ value: "", label: "All" },
{ value: "paid", label: "Paid" },
]
const [status, setStatus] = useState("")
<PillGroup options={statuses} value={status} onChange={setStatus} />Examples
Coloured states
import { useState } from "react"
import { PillGroup } from "@dapplelight/signet-ui/components/pill-group"
const [status, setStatus] = useState("paid")
<PillGroup
value={status}
onChange={setStatus}
options={[
{ value: "paid", label: "Paid", activeClassName: "border-green-500/40 bg-green-500/15 text-text-primary" },
{ value: "pending", label: "Pending", activeClassName: "border-amber-500/40 bg-amber-500/15 text-text-primary" },
{ value: "overdue", label: "Overdue", activeClassName: "border-red-500/40 bg-red-500/15 text-text-primary" },
]}
/>Date range
Showing revenue for the last 30 days.
import { useState } from "react"
import { PillGroup } from "@dapplelight/signet-ui/components/pill-group"
const [range, setRange] = useState("30d")
<PillGroup
value={range}
onChange={setRange}
options={[
{ value: "7d", label: "7 days" },
{ value: "30d", label: "30 days" },
{ value: "90d", label: "90 days" },
]}
/>API Reference
PillGroup
| Prop | Type | Default | Description |
|---|---|---|---|
| options | PillOption[] | - | The pills, in order. |
| value | string | - | The selected option's value. Use "" for an All pill. |
| onChange | (value: string) => void | - | Called with the clicked pill's value. |
| className | string | - | Class on the wrapper. |
PillOption
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Value passed to onChange. |
| label | string | - | Text shown in the pill. |
| activeClassName | string | primary tint | Replaces the selected style, e.g. a status colour. |