
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@metadiv-studio/badge
Advanced tools
A flexible and customizable badge component built with React, TypeScript, and Tailwind CSS. Perfect for displaying status indicators, labels, and small pieces of information in your React applications.
A flexible and customizable badge component built with React, TypeScript, and Tailwind CSS. Perfect for displaying status indicators, labels, and small pieces of information in your React applications.
npm i @metadiv-studio/badge
The @metadiv-studio/badge package provides a lightweight, accessible badge component that follows modern design principles. Built with:
import { Badge } from '@metadiv-studio/badge';
function App() {
return (
<Badge>Default Badge</Badge>
);
}
The badge component comes with three built-in variants:
import { Badge } from '@metadiv-studio/badge';
function App() {
return (
<div className="space-x-2">
<Badge variant="default">Default</Badge>
<Badge variant="destructive">Error</Badge>
<Badge variant="outline">Outline</Badge>
</div>
);
}
You can customize the badge appearance by passing additional CSS classes:
import { Badge } from '@metadiv-studio/badge';
function App() {
return (
<div className="space-y-2">
<Badge className="bg-blue-500 text-white">Custom Blue</Badge>
<Badge className="bg-green-500 text-white px-4 py-1">Large Green</Badge>
<Badge className="bg-purple-500 text-white rounded-full">Rounded</Badge>
</div>
);
}
Combine with icon libraries for enhanced visual appeal:
import { Badge } from '@metadiv-studio/badge';
import { CheckCircle, AlertCircle, Info } from 'lucide-react';
function App() {
return (
<div className="space-x-2">
<Badge className="bg-green-100 text-green-800">
<CheckCircle className="w-3 h-3 mr-1" />
Success
</Badge>
<Badge variant="destructive">
<AlertCircle className="w-3 h-3 mr-1" />
Warning
</Badge>
<Badge variant="outline">
<Info className="w-3 h-3 mr-1" />
Info
</Badge>
</div>
);
}
Make badges interactive by adding click handlers:
import { Badge } from '@metadiv-studio/badge';
import { useState } from 'react';
function App() {
const [selectedTags, setSelectedTags] = useState<string[]>([]);
const tags = ['React', 'TypeScript', 'Tailwind', 'Next.js'];
const toggleTag = (tag: string) => {
setSelectedTags(prev =>
prev.includes(tag)
? prev.filter(t => t !== tag)
: [...prev, tag]
);
};
return (
<div className="space-x-2">
{tags.map(tag => (
<Badge
key={tag}
className={`cursor-pointer transition-all ${
selectedTags.includes(tag)
? 'bg-blue-500 text-white'
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
}`}
onClick={() => toggleTag(tag)}
>
{tag}
</Badge>
))}
</div>
);
}
| Variant | Description | Default Styles |
|---|---|---|
default | Primary badge style | Primary colors with subtle background |
destructive | Error/warning style | Red colors for alerts |
outline | Minimal outline style | Transparent with border |
The Badge component extends standard HTML div attributes and includes:
interface BadgeProps {
variant?: 'default' | 'destructive' | 'outline';
className?: string;
// ... all standard HTML div attributes
}
This package uses Tailwind CSS for styling. To ensure proper styling in your project, make sure your tailwind.config.js includes:
module.exports = {
content: [
// ... your content paths
"./node_modules/@metadiv-studio/**/*.{js,ts,jsx,tsx}",
],
// ... rest of your config
}
The badge component is fully responsive and works across all device sizes. The default sizing (h-6 text-xs) provides good readability on both desktop and mobile devices.
UNLICENSED - See package.json for details.
This package is part of the @metadiv-studio ecosystem. For issues, feature requests, or contributions, please refer to the main repository.
FAQs
A flexible and customizable badge component built with React, TypeScript, and Tailwind CSS. Perfect for displaying status indicators, labels, and small pieces of information in your React applications.
We found that @metadiv-studio/badge demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.