Command Palette

Search for a command to run...

Docs
Badge Removable

Badge Removable

A badge component with a remove button for dismissible tags and filters.

Installation

Usage

import { useState } from "react";
import BadgeRemovable from "@/components/ruixen/badge-removable";
 
export default function MyTags() {
  const [tags, setTags] = useState(["React", "TypeScript", "Tailwind"]);
 
  const handleRemove = (tag: string) => {
    setTags((prev) => prev.filter((t) => t !== tag));
  };
 
  return (
    <div className="flex gap-2">
      {tags.map((tag) => (
        <BadgeRemovable key={tag} onRemove={() => handleRemove(tag)}>
          {tag}
        </BadgeRemovable>
      ))}
    </div>
  );
}

Props

PropTypeDefaultDescription
childrenReact.ReactNode"Badge"The badge text content
variant"default" | "secondary" | "destructive" | "outline""secondary"The badge variant style
onRemove() => void-Callback when remove is clicked
classNamestring-Additional CSS classes