Badges allow the highlighting of an item’s status. This provides quick recognition.
function Example() {
return <Badge shadow={2}>NEW FEATURE</Badge>;
}
import { Badge } from 'native-base';
function Example() {
return <Box alignItems="center">
<Badge>NEW FEATURE</Badge>
</Box>;
}
function Example() {
return <HStack space={{
base: 2,
sm: 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 <Box alignItems="center">
<HStack space={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="error" alignSelf="center" variant={key}>
ERROR
</Badge>
<Badge colorScheme="info" alignSelf="center" variant={key}>
INFO
</Badge>
<Badge colorScheme="warning" alignSelf="center" variant={key}>
WARNING
</Badge>
</VStack>)}
</HStack>
</Box>;
}
function Example() {
return <Box alignItems="center">
<VStack>
<Badge
colorScheme="danger" rounded="full" 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>
</Box>;
}
Badge implements
,
,
,
,
,
,
,
,
,
The style variant of the badge.
Type: ResponsiveValue<"subtle" | "solid" | "outline" | (string & {})>
The color scheme to use for the badge. Must be a key in theme.colors.
The right icon element to use in the button.
Type: Element | Element[]
The left icon element to use in the button.
Type: Element | Element[]
The start icon element to use in the button.
Type: Element | Element[]
The end icon element to use in the button.
Type: Element | Element[]
Props to style the child text
Type: InterfaceTextProps<ITextProps> & VariantSizeColorScheme<"Text">
Props to be passed to the Icon used inside of Button.
Type: InterfaceIconProps & Partial<{}> & VariantSizeColorScheme<"Icon">
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 .