Chip - Customizable Badge Component

A customizable chip/badge component with various border styles, colors, and shapes. Features circle and square variants, directional borders, and full color customization. Perfect for tags, labels, and category indicators.

Installation

npx shadcn@latest add "https://ui-struct.vercel.app/r/chip"

Usage

import Chip from "@/components/ui/chip";
<Chip chipData={{ label: "Featured", id: "featured" }} />

Preview

'use client';
import { useState } from 'react';
interface IChip {
label: string;
id: string;
border?: string;
borderColor?: string;
textColor?: string;
bgColor?: string;
isRounded?: boolean;
}
const getBorderClass = (border: string | undefined) => {
switch (border) {
case 'left':
return 'border-l-4';
case 'right':
return 'border-r-4';
case 'top':
return 'border-t-4';
case 'bottom':
return 'border-b-4';
default:
return '';
}
}
export default function Chip({
chipData = { label: 'Sample Chip', id: 'sample-chip' },
border,
borderColor,
textColor,
bgColor,
isRounded = true,
}: {
chipData?: IChip;
border?: string;
borderColor?: string;
textColor?: string;
bgColor?: string;
isRounded?: boolean;
}) {
return (
<>
<span className="text-gray-400 inline-flex items-center leading-none text-sm pr-0 py-1 mr-2 cursor-pointer">
<span
className={`bg-white dark:bg-gray-800 tracking-wide text-gray-800 dark:text-white font-bold shadow-md py-1 px-4 inline-flex items-center border-slate-600 border ${getBorderClass(border)} ${isRounded ? 'rounded-full' : 'rounded'}`}
style={{
borderColor: borderColor,
backgroundColor: bgColor ? bgColor : '#FFFFFF',
color: textColor ? textColor : '#2D3748',
}}
>
<span className="mx-auto flex items-center">
{/* <img className="mr-2" src="/images/num_heart.gif" alt="calender-icon" width="18" /> */}
{chipData.label}
</span>
</span>
</span>
</>
);
}

Circle Chips

Next.jsReactAstroNode.jsAngular

Square Chips

Next.jsReactAstroNode.jsAngular

Left Border Chips

Next.jsReactAstroNode.jsAngular

Right Border Chips

Next.jsReactAstroNode.jsAngular

Bottom Border Chips

Next.jsReactAstroNode.jsAngular

Top Border Chips

Next.jsReactAstroNode.jsAngular

Different Color Variants Chips

Next.jsReactAstroNode.jsAngular

All type of Chips

Next.jsReactAstroNode.jsAngular