Badge
Add status indicators to your interface for clear, attention-grabbing usability cues, conveying crucial information swiftly.
Installation
API Reference
This is an illustration of Badge component.
size
variant
action
<Badge size="md" variant="solid" action="muted"><BadgeText>Verified</BadgeText><BadgeIcon as={GlobeIcon} className="ml-2" /></Badge>
Installation
CLI
Manual
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.
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.
Badge
Name | Value | Default |
---|---|---|
action | error | warning | success | info | muted | success |
variant | solid | outline | solid |
size | sm | md | lg | md |
Important Note
Note: These props are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these props may not be available.
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><AvatarImagesource={{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" className="ml-1"><BadgeText>Verified</BadgeText><BadgeIcon as={BadgeCheckIcon} className="ml-1" /></Badge></HStack><Text size="sm">Nursing Assistant</Text></VStack></HStack></VStack>
Badge Composition
An example of the Badge component being used with the Composition component, allowing for the display of badges within a composition of other UI elements.
<Box className="items-center"><VStack><BadgeclassName="z-10 self-end h-[22px] w-[22px] bg-red-600 rounded-full -mb-3.5 -mr-3.5"variant="solid"><BadgeText className="text-white">2</BadgeText></Badge><Button><ButtonText>Notifications</ButtonText></Button></VStack></Box>