Highlight information like status, category, or count.
import { Badge } from '@fluxui-dev/react';<Badge color="lime">New</Badge>
Choose between three different sizes for your badges with the size prop.
<Badge size="sm">Small</Badge><Badge>Default</Badge><Badge size="lg">Large</Badge>
Add icons to badges with the icon and iconTrailing props, passed as components.
import { DocumentTextIcon, UserCircleIcon, VideoCameraIcon } from '@fluxui-dev/react/icons';<Badge icon={UserCircleIcon}>Users</Badge><Badge icon={DocumentTextIcon}>Files</Badge><Badge iconTrailing={VideoCameraIcon}>Videos</Badge>
Display badges with a fully rounded border radius using the rounded prop.
import { UserIcon } from '@fluxui-dev/react/icons';<Badge rounded icon={UserIcon}>Users</Badge>
Make the entire badge clickable by wrapping it in a button element.
import { PlusIcon } from '@fluxui-dev/react/icons';<Badge render={<button type="button" />} rounded icon={PlusIcon} size="lg">Amount</Badge>
Make a badge removable by appending a close button.
<Badge> Admin <Badge.Close aria-label="Remove" /></Badge>
Choose from an array of colors to differentiate between badges and convey emotion.
<Badge color="zinc">Zinc</Badge><Badge color="red">Red</Badge><Badge color="orange">Orange</Badge><Badge color="amber">Amber</Badge><Badge color="yellow">Yellow</Badge><Badge color="lime">Lime</Badge><Badge color="green">Green</Badge><Badge color="emerald">Emerald</Badge><Badge color="teal">Teal</Badge><Badge color="cyan">Cyan</Badge><Badge color="sky">Sky</Badge><Badge color="blue">Blue</Badge><Badge color="indigo">Indigo</Badge><Badge color="violet">Violet</Badge><Badge color="purple">Purple</Badge><Badge color="fuchsia">Fuchsia</Badge><Badge color="pink">Pink</Badge><Badge color="rose">Rose</Badge>
Bold, high-contrast badges for more important status indicators or alerts.
<Badge variant="solid" color="zinc">Zinc</Badge><Badge variant="solid" color="red">Red</Badge><Badge variant="solid" color="orange">Orange</Badge><Badge variant="solid" color="amber">Amber</Badge><Badge variant="solid" color="yellow">Yellow</Badge><Badge variant="solid" color="lime">Lime</Badge><Badge variant="solid" color="green">Green</Badge><Badge variant="solid" color="emerald">Emerald</Badge><Badge variant="solid" color="teal">Teal</Badge><Badge variant="solid" color="cyan">Cyan</Badge><Badge variant="solid" color="sky">Sky</Badge><Badge variant="solid" color="blue">Blue</Badge><Badge variant="solid" color="indigo">Indigo</Badge><Badge variant="solid" color="violet">Violet</Badge><Badge variant="solid" color="purple">Purple</Badge><Badge variant="solid" color="fuchsia">Fuchsia</Badge><Badge variant="solid" color="pink">Pink</Badge><Badge variant="solid" color="rose">Rose</Badge>
If you're using badges alongside inline text, you might run into spacing issues because of the extra padding around the badge. Use the inset prop to add negative margins to the top and bottom of the badge to avoid this.
import { Heading, Text } from '@fluxui-dev/react';<Heading> Page builder <Badge color="lime" inset="top bottom">New</Badge></Heading><Text className="mt-2">Easily author new pages without leaving your browser.</Text>
|
Prop
|
Description
|
|---|---|
| color |
Badge color: zinc, gray (the same as zinc), or one of the 17 chromatic Tailwind colors (e.g., red, blue). Default: zinc.
|
| size |
Badge size. Options: sm, base (default), lg.
|
| rounded |
If true, makes the badge fully rounded instead of slightly rounded corners.
|
| variant |
Badge style variant. Options: default, solid. Default: default.
|
| icon |
Icon to display before the badge text: a component, such as UserIcon from @fluxui-dev/react/icons, or an element, such as <img />, rendered as is.
|
| iconTrailing |
Icon to display after the badge text: a component or an element.
|
| iconVariant |
Icon variant. Options: outline, solid, mini, micro. Default: micro.
|
| label |
The badge's content, used when it has no children.
|
| render |
Element to render instead of the span, such as <button type="button" />, with the badge's props merged in. Also accepts a function that receives the props and returns an element.
|
| inset |
Add negative margins to all or specific sides. Options: true (all sides), top, bottom, left, right, or a space-separated combination such as "top bottom".
|
|
CSS
|
Description
|
|---|---|
| className |
Additional CSS classes applied to the badge.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-badge |
Applied to the root element for styling and identification.
|
|
Prop
|
Description
|
|---|---|
| icon |
Icon to display, a component or an element. Default: an x-mark icon.
|
| iconVariant |
Icon variant. Options: outline, solid, mini, micro. Default: micro.
|
| aria-label |
Accessible name for the button, such as Remove. The button has none by default.
|
| onClick |
Callback fired when the button is clicked; removing the badge is up to your app.
|
| render |
Element to render instead of the button, with the close button's props merged in. Also accepts a function that receives the props and returns an element.
|
|
Attribute
|
Description
|
|---|---|
| data-flux-badge-close |
Applied to the button for styling and identification.
|