Badge

The badge component lets you quickly and easily add status indicators to your interface for improved usability. They are designed to be attention-grabbing and quickly convey important information.
Installation
API Reference
This is an illustration of Badge component.
size
variant
action
<Badge size="md" variant="solid" action="success">
<BadgeText>New feature</BadgeText>
<BadgeIcon as={GlobeIcon} ml="$2" />
</Badge>

Installation

Run the following command:

npx gluestack-ui add badge

API Reference

To use this component in your project, include the following import statement in your file.
import { Badge } from "@/components/ui/badge"
export default () => (
<Badge>
<BadgeText />
<BadgeIcon />
</Badge>
)

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Badge

It inherits all the properties of React Native's View component.
Descendants Styling Props Props to style child components.
Sx Prop
Description
_text
Prop to style BadgeText Component
_icon
Prop to style BadgeIcon Component

BadgeText

It inherits all the properties of React Native's Text component.

BadgeIcon

Contains all Icon related layout style props and actions. It inherits all the properties of gluestack Style's AsForwarder component.

Props

Badge component is created using View component from react-native. It extends all the props supported by React Native View, utility props and the props mentioned below.

Badge

Name
Value
Default
action
error | warning | success | info | muted
success
variant
solid | outline
solid
size
sm | md | lg
md

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Badge with Avatar

An example of the Badge component being used with the Avatar component to display badges alongside user avatars for enhanced visual representation or identification.
<VStack space="2xl">
<HStack space="md">
<Avatar>
<AvatarFallbackText>SS</AvatarFallbackText>
<AvatarImage
source={{
uri: "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8dXNlcnxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=800&q=60",
}}
/>
</Avatar>
<VStack>
<HStack>
<Heading size="sm">Ronald Richards</Heading>
<Badge size="sm" variant="solid" action="success" ml="$1">
<BadgeText>Verified</BadgeText>
<BadgeIcon as={BadgeCheckIcon} ml="$1" />
</Badge>
</HStack>
<Text size="sm">Nursing Assistant</Text>
</VStack>
</HStack>
</VStack>

Badge in Menu

A Badge component used with a menu adds a visual indicator, such as a badge, to highlight specific items or provide additional information within the menu, enhancing user interaction and improving the visibility of important elements.
<Menu
placement={"top"}
trigger={({ ...triggerProps }) => {
return (
<Button {...triggerProps}>
<ButtonText>Menu</ButtonText>
</Button>
)
}}
>
<MenuItem key="Community" textValue="Community">
<HStack space="sm" alignItems="center">
<Icon as={GlobeIcon} size="sm" />
<Text fontSize="$sm" lineHeight="$md">
Community
</Text>
</HStack>
</MenuItem>
<MenuItem key="Plugins" textValue="Plugins">
<HStack space="sm" alignItems="center">
<Icon as={PuzzleIcon} size="sm" />
<Text fontSize="$sm" lineHeight="$md">
Plugins
</Text>
</HStack>
</MenuItem>
<MenuItem key="Theme" textValue="Theme">
<HStack space="sm" alignItems="center">
<Icon as={PaintBucket} size="sm" />
<Text fontSize="$sm" lineHeight="$md">
Theme
</Text>
<Badge bg="$backgroundLight600">
<BadgeText color="$textLight50">New</BadgeText>
</Badge>
</HStack>
</MenuItem>
<MenuItem key="Settings" textValue="Settings">
<HStack space="sm" alignItems="center">
<Icon as={SettingsIcon} size="sm" />
<Text fontSize="$sm" lineHeight="$md