Components

Floating Badges

Elegant, customizable badges with gradient backgrounds and dot indicators. Perfect for highlighting important information with a modern, eye-catching appearance.

Floating Badge Component

Basic Examples

Senior
New
Featured
Pro
Premium

Size Variations

Small
Default
Large

Dot Variations

No Dot
White Dot
Green Dot
Red Dot
Pulsing Dot

Component Documentation

PropTypeDefault ValueDescription
labelstring"Badge"Text to display in the badge
showDotstringtrueWhether to show the dot indicator
dotSizestring"h-1.5 w-1.5 sm:h-2 sm:w-2"Size of the dot indicator
dotColorstring"bg-white"Color of the dot indicator
dotClassNamestring""Additional classes for the dot
fontSizestring"text-[9px] sm:text-[10px]"Font size for the text
fontWeightstring"font-medium"Font weight for the text
textTransformstring"uppercase"Text transformation (uppercase, lowercase, etc.)
letterSpacingstring"tracking-widest"Letter spacing for the text
textColorstring"text-white dark:text-white"Text color for the badge
paddingstring"px-3 py-1 sm:px-4 sm:py-1.5"Padding for the badge
gradientstring"from-indigo-600/95 via-primary-500/95 to-purple-600/95"Gradient for light mode
darkGradientstring"dark:from-indigo-500/95 dark:via-primary-400/95 dark:to-purple-500/95"Gradient for dark mode
borderstring"border border-white/30 dark:border-white/10"Border style for the badge
hoverBorderstring"hover:border-white/40"Border style on hover
roundedstring"rounded-full"Border radius style
shadowstring"shadow-lg shadow-indigo-500/20 dark:shadow-indigo-500/30"Shadow style
hoverShadowstring"hover:shadow-xl"Shadow style on hover
hoverScalestring"hover:scale-105"Scale effect on hover
transitionstring"transition-all duration-300"Transition effect for animations
backdropBlurstring"backdrop-blur-md"Backdrop blur effect
classNamestring""Additional CSS classes
onClickstringnullClick event handler

Usage Example

Usage Example

jsx
import React from "react";
import FloatingBadge from "@/tailwind/foraui/components/badges/FloatingBadge";

export default function BadgeShowcase() {
  // Badge configurations to showcase different styles
  const badgeConfigs = [
    {
      label: "Senior",
      gradient: "from-indigo-600/95 via-primary-500/95 to-purple-600/95",
      darkGradient: "dark:from-indigo-500/95 dark:via-primary-400/95 dark:to-purple-500/95",
      shadow: "shadow-lg shadow-indigo-500/20 dark:shadow-indigo-500/30",
    },
    {
      label: "New",
      gradient: "from-green-600/95 via-emerald-500/95 to-teal-600/95",
      darkGradient: "dark:from-green-500/95 dark:via-emerald-400/95 dark:to-teal-500/95",
      shadow: "shadow-lg shadow-green-500/20 dark:shadow-green-500/30",
    },
    {
      label: "Featured",
      gradient: "from-amber-600/95 via-orange-500/95 to-red-600/95",
      darkGradient: "dark:from-amber-500/95 dark:via-orange-400/95 dark:to-red-500/95",
      shadow: "shadow-lg shadow-amber-500/20 dark:shadow-amber-500/30",
    },
  ];

  return (
    <div className="w-full p-6 bg-white dark:bg-gray-900 rounded-xl">
      <h2 className="text-xl font-bold mb-6 text-gray-900 dark:text-white">
        Badge Examples
      </h2>

      {/* Basic badges */}
      <div className="mb-8">
        <h3 className="text-lg font-semibold mb-4 text-gray-800 dark:text-gray-200">
          Basic Examples
        </h3>
        <div className="flex flex-wrap gap-4">
          {badgeConfigs.map((config, index) => (
            <FloatingBadge
              key={index}
              label={config.label}
              gradient={config.gradient}
              darkGradient={config.darkGradient}
              shadow={config.shadow}
            />
          ))}
        </div>
      </div>

      {/* Size variations */}
      <div className="mb-8">
        <h3 className="text-lg font-semibold mb-4 text-gray-800 dark:text-gray-200">
          Size Variations
        </h3>
        <div className="flex flex-wrap items-center gap-4">
          <FloatingBadge
            label="Small"
            padding="px-2 py-0.5 sm:px-3 sm:py-1"
            fontSize="text-[8px] sm:text-[9px]"
            dotSize="h-1 w-1 sm:h-1.5 sm:w-1.5"
          />
          <FloatingBadge label="Default" />
          <FloatingBadge
            label="Large"
            padding="px-4 py-1.5 sm:px-5 sm:py-2"
            fontSize="text-[10px] sm:text-xs"
            dotSize="h-2 w-2 sm:h-2.5 sm:w-2.5"
          />
        </div>
      </div>

      {/* Dot variations */}
      <div>
        <h3 className="text-lg font-semibold mb-4 text-gray-800 dark:text-gray-200">
          Dot Variations
        </h3>
        <div className="flex flex-wrap gap-4">
          <FloatingBadge label="No Dot" showDot={false} />
          <FloatingBadge label="White Dot" dotColor="bg-white" />
          <FloatingBadge label="Green Dot" dotColor="bg-green-400" />
          <FloatingBadge label="Red Dot" dotColor="bg-red-400" />
          <FloatingBadge label="Pulsing Dot" dotClassName="animate-pulse" />
        </div>
      </div>
    </div>
  );
}