Chip

View as Markdown

Small rounded filters, links and tags, each removable with its own ×.

Applied
  • Status: Open
  • Assignee: Ada Okafor
  • Label: Billing
  • Priority: Urgent or High
Quick filters

Filters on: 5

When to use

Small rounded filters, links and tags, each removable with its own ×. Use Tag Input instead when people type the tags themselves.

Usage

import { Chip, ChipList } from "./ui/uicontext/components/Chip.ts"
const Message = UiSchema.TaggedEnum({ ClearedStatus: {}, ToggledRemote: {} })export const Filters = (h: Html.H<typeof Message.Type>, remote: boolean) =>	ChipList(h, { label: "Filters" }, [		Chip(h, { label: "Status: Open", onRemove: Message.ClearedStatus() }),		Chip(h, { label: "Remote", selected: remote, onPress: Message.ToggledRemote() }),	])

Examples

With href a chip is a link; with nothing to do it's a plain tag.

API reference

ChipView function

Options

Chip options
NameTypeDescription
labelrequiredstring—
iconView.ContentA small icon or a ColorDot before the label.
onPressMessageMakes the chip a button; with selected, a toggle that says whether it's on.
selectedboolean—
hrefstringMakes the chip a link.
onRemoveMessageAdds a × button that removes it, named "Remove <label>".
removeLabelstringWhat the × says, when "Remove <label>" isn't right: "Clear the status filter".
styleStyle—

ChipListView function

Options

ChipList options
NameTypeDescription
labelrequiredstringWhat the chips are: "Active filters", "Collections".
styleStyle—

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/chip

Source