All of us must have seen notification badges somewhere, such as on smart phones or facebook. NativeBase is here to include this into your collection of readymade components. Badges are numerical indicators of how many items are associated with an element. Badges can notify you that there are new or unread messages or notifications. These can be very effective in alerting the user to new things on your app.
Syntax
{% codetabs name="React Native", type="js" -%} import React, { Component } from 'react'; import { Container, Header, Content, Badge, Text, Icon } from 'native-base'; export default class BadgeExample extends Component { render() { return (
2 2 2 2 2 2 {% raw %}<Icon name="star" style={{ fontSize: 15, color: "#fff", lineHeight: 20 }}/>{% endraw %} {% raw %}<Badge style={{ backgroundColor: 'black' }}>{% endraw %} {% raw %}<Text style={{ color: 'white' }}>1866{% endraw %} ); } } {%- language name="Vue Native", type="vue" -%} 2 2 2 5 2 2 1866 <style> .icon-star { font-size: 15; color: #fff; line-height: 20; } .badge-custom-bg { background-color: black; } </style>{%- endcodetabs %}
- NativeBase spectrum of colors are compatible with Badge.
- Replacing Component: React Native View
Configuration
| Property | Default | Option | Description |
|---|---|---|---|
| primary | - | boolean | Add a blue background color to your component |
| success | - | boolean | Add a green background color to your component |
| info | - | boolean | Add a light blue background color to your component as shown |
| warning | - | boolean | Add a yellow warning background color to your component |
| danger | - | boolean | Add a red background color to your component |

