{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "chip",
  "type": "registry:ui",
  "title": "Chip",
  "description": "A small pill for one short value: a filter that is on and can be removed, a suggestion to press, or one of a set of choices that can be switched on and off.",
  "categories": [
    "ui"
  ],
  "dependencies": [
    "class-variance-authority",
    "lucide-react",
    "radix-ui"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn"
  ],
  "files": [
    {
      "path": "registry/ui/chip.tsx",
      "type": "registry:ui",
      "target": "components/ui/chip.tsx",
      "content": "\"use client\";\n/**\n * @name chip\n * @category ui\n * @description A small pill for one short value: a filter that is on and can be removed, a suggestion to press, or one of a set of choices that can be switched on and off.\n * @when Filters in effect above a list (Chip with ChipRemove), suggested replies or refinements under a message or a search (ChipButton), and choosing one or several short options such as moods, tags or times of day (ChipGroup). For a status that cannot be pressed use badge; for two to five views of the same thing use segmented-control; for long labels use checkboxes or radio-group.\n * @example\n * // Filters in effect\n * <Chip>Under 50 <ChipRemove aria-label=\"Remove the filter: under 50\" onClick={clearPrice} /></Chip>\n *\n * // Suggestions\n * <ChipButton onClick={() => ask(\"Only this weekend\")}>Only this weekend</ChipButton>\n *\n * // A set of choices: several can be on (type=\"multiple\") or one (type=\"single\")\n * <ChipGroup type=\"multiple\" defaultValue={[\"calm\"]} aria-label=\"Mood\">\n *   <ChipGroupItem value=\"calm\">Calm</ChipGroupItem>\n *   <ChipGroupItem value=\"lively\">Lively</ChipGroupItem>\n * </ChipGroup>\n */\nimport { Slot, ToggleGroup as ToggleGroupPrimitive } from \"radix-ui\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { Check, X } from \"lucide-react\";\nimport type { ComponentProps } from \"react\";\nimport { cn } from \"@/lib/cn\";\n\nexport const chipVariants = cva(\n  \"inline-flex h-control-sm max-w-full shrink-0 items-center gap-1.5 rounded-control border px-3 text-sm font-medium whitespace-nowrap text-foreground select-none [&_svg]:size-3.5 [&_svg]:shrink-0\",\n  {\n    variants: {\n      variant: {\n        outline: \"border-border-strong bg-background\",\n        soft: \"border-transparent bg-highlight-soft\",\n        muted: \"border-transparent bg-muted\",\n      },\n      /** A chip that can be pressed: a hover ground, a press, and a taller target on touch screens. */\n      interactive: {\n        true: \"cursor-pointer transition-[background-color,border-color,color,opacity,scale] duration-instant ease-out hover:bg-accent active:scale-[0.98] disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none motion-reduce:active:scale-100 pointer-coarse:h-control\",\n        false: \"\",\n      },\n    },\n    defaultVariants: { variant: \"outline\", interactive: false },\n  },\n);\n\nexport type ChipProps = ComponentProps<\"span\"> &\n  Pick<VariantProps<typeof chipVariants>, \"variant\"> & {\n    /** Render the child element (a link, for example) with the chip's look. */\n    asChild?: boolean;\n  };\n\n/** A chip that only shows a value. Put a ChipRemove inside to make it removable. */\nexport function Chip({ className, variant, asChild = false, ...props }: ChipProps) {\n  const Comp = asChild ? Slot.Root : \"span\";\n  return <Comp data-slot=\"chip\" className={cn(chipVariants({ variant }), \"has-data-[slot=chip-remove]:pe-1\", className)} {...props} />;\n}\n\nexport type ChipRemoveProps = Omit<ComponentProps<\"button\">, \"type\">;\n\n/**\n * The cross that removes a chip. Give it an `aria-label` that says what it removes (\"Remove the filter:\n * under 50\"): the default is only \"Remove\". After removing, move focus to the next chip's cross or to the\n * control that added it, so that keyboard focus is not lost with the chip.\n */\nexport function ChipRemove({ className, children, \"aria-label\": ariaLabel = \"Remove\", ...props }: ChipRemoveProps) {\n  return (\n    <button\n      type=\"button\"\n      data-slot=\"chip-remove\"\n      aria-label={ariaLabel}\n      className={cn(\n        \"relative inline-flex size-6 shrink-0 items-center justify-center rounded-control text-muted-foreground transition-[background-color,color] duration-instant ease-out after:absolute after:-inset-2 hover:bg-accent hover:text-foreground disabled:pointer-events-none disabled:opacity-50 motion-reduce:transition-none\",\n        className,\n      )}\n      {...props}\n    >\n      {children ?? <X aria-hidden=\"true\" strokeWidth={1.5} />}\n    </button>\n  );\n}\n\nexport type ChipButtonProps = ComponentProps<\"button\"> & Pick<VariantProps<typeof chipVariants>, \"variant\">;\n\n/** A chip that does something when pressed: a suggestion, a quick reply, \"show more\". */\nexport function ChipButton({ className, variant, type = \"button\", ...props }: ChipButtonProps) {\n  return <button type={type} data-slot=\"chip-button\" className={cn(chipVariants({ variant, interactive: true }), className)} {...props} />;\n}\n\nexport type ChipGroupProps = ComponentProps<typeof ToggleGroupPrimitive.Root>;\n\n/**\n * A set of chips to choose from. `type=\"multiple\"` lets several be on (each is a toggle button);\n * `type=\"single\"` lets one be on (each is a radio). Arrow keys move between chips, Space or Enter switches\n * one. The chips wrap onto more lines; name the group with `aria-label` or `aria-labelledby`. `value`,\n * `defaultValue` and `onValueChange` control it: a string for \"single\", an array for \"multiple\".\n */\nexport function ChipGroup({ className, ...props }: ChipGroupProps) {\n  // Radix calls a set of toggles a toolbar; a set of choices is a plain group.\n  const role = props.role ?? (props.type === \"multiple\" ? \"group\" : \"radiogroup\");\n  return <ToggleGroupPrimitive.Root data-slot=\"chip-group\" className={cn(\"flex max-w-full flex-wrap gap-2\", className)} {...props} role={role} />;\n}\n\nexport type ChipGroupItemProps = ComponentProps<typeof ToggleGroupPrimitive.Item>;\n\n/** One choice. When on it takes the soft highlight and shows a tick, so that the state is not carried by colour alone. */\nexport function ChipGroupItem({ className, children, ...props }: ChipGroupItemProps) {\n  return (\n    <ToggleGroupPrimitive.Item\n      data-slot=\"chip-group-item\"\n      className={cn(\n        chipVariants({ variant: \"outline\", interactive: true }),\n        \"group/chip data-[state=on]:border-primary data-[state=on]:bg-highlight-soft data-[state=on]:hover:bg-highlight-soft\",\n        className,\n      )}\n      {...props}\n    >\n      <Check aria-hidden=\"true\" strokeWidth={2} className=\"hidden group-data-[state=on]/chip:block\" />\n      {children}\n    </ToggleGroupPrimitive.Item>\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "ui",
    "when": "Filters in effect above a list (Chip with ChipRemove), suggested replies or refinements under a message or a search (ChipButton), and choosing one or several short options such as moods, tags or times of day (ChipGroup). For a status that cannot be pressed use badge; for two to five views of the same thing use segmented-control; for long labels use checkboxes or radio-group.",
    "example": "// Filters in effect\n<Chip>Under 50 <ChipRemove aria-label=\"Remove the filter: under 50\" onClick={clearPrice} /></Chip>\n\n// Suggestions\n<ChipButton onClick={() => ask(\"Only this weekend\")}>Only this weekend</ChipButton>\n\n// A set of choices: several can be on (type=\"multiple\") or one (type=\"single\")\n<ChipGroup type=\"multiple\" defaultValue={[\"calm\"]} aria-label=\"Mood\">\n  <ChipGroupItem value=\"calm\">Calm</ChipGroupItem>\n  <ChipGroupItem value=\"lively\">Lively</ChipGroupItem>\n</ChipGroup>",
    "client": true
  }
}
