Skip to content
Unkey Design Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Control pill

A removable chip for one active filter, read as field, operator and value.

import { ControlPill } from "@unkey/ui";
import { useState } from "react";

const FILTERS = [
  { id: "region", field: "Region", operator: "is" as const, value: "Frankfurt" },
  { id: "status", field: "Status", operator: "is" as const, value: "Running" },
];

export default function ControlPillVariants() {
  const [filters, setFilters] = useState(FILTERS);
  const remove = (id: string) => setFilters(filters.filter((f) => f.id !== id));

  return (
    <div className="flex flex-col items-start gap-4 text-xs">
      {(["solid", "outline"] as const).map((variant) => (
        <div key={variant} className="flex flex-wrap items-center gap-2">
          {filters.map((filter, index) => (
            <ControlPill
              key={filter.id}
              variant={variant}
              index={index}
              filter={filter}
              formatFieldName={(field) => field}
              formatValue={(value) => String(value)}
              onRemove={remove}
            />
          ))}
        </div>
      ))}
    </div>
  );
}

Anatomy

  • ControlPill renders the field, the operator, the value and a remove button. variant picks solid (the default) or outline.

Best practices

Variant

Use solid in the logs control cloud. Use outline on a card or a table toolbar, where a filled chip is too heavy.

Copy

Pass the field label and the display value through formatFieldName and formatValue. The remove button reads them out, so keep both human.

Removal

Remove the filter in onRemove. Backspace and Delete on a focused pill call it too.