Badges are used to highlight an item's status for quick recognition.
import { Badge } from 'native-base';
function Example() {
return <Badge>NEW FEATURE</Badge>;
}
function Example() {
return <HStack space={{
base: 2,
md: 4
}} mx={{
base: "auto",
md: 0
}}>
<Badge colorScheme="success">SUCCESS</Badge>
<Badge colorScheme="danger">DANGER</Badge>
<Badge colorScheme="info">INFO</Badge>
<Badge colorScheme="coolGray">DARK</Badge>
</HStack>;
}
function Example() {
return <>
<HStack space={{
base: "2",
md: "4"
}} mx={{
base: "auto",
md: "0"
}}>
{["solid", "outline", "subtle"].map(key => <VStack key={key} space={4}>
<Badge variant={key} alignSelf="center">
DEFAULT
</Badge>
<Badge colorScheme="success" alignSelf="center" variant={key}>
SUCCESS
</Badge>
<Badge colorScheme="danger" alignSelf="center" variant={key}>
DANGER
</Badge>
<Badge colorScheme="info" alignSelf="center" variant={key}>
INFO
</Badge>
</VStack>)}
</HStack>
</>;
}
function Example() {
return <VStack>
<Badge
colorScheme="danger" rounded="999px" mb={-4} mr={-4} zIndex={1} variant="solid" alignSelf="flex-end" _text={{
fontSize: 12
}}>
2
</Badge>
<Button mx={{
base: "auto",
md: 0
}} p="2" bg="cyan.500" _text={{
fontSize: 14
}}>
Notifications
</Button>
</VStack>;
}
Badge implements
,
,
,
,
,
,
,
,
,
,
The style variant of the badge.
Type: ResponsiveValue<"outline" | "subtle" | "solid" | (string & {})>
The color scheme to use for the badge. Must be a key in theme.colors.
NativeBase ships with a default theme for each component. Check out the default theme of the badge
.
Info:
We can easily extend the badge component theme using extendTheme function as described in the documentation .