Skip to content

Latest commit

 

History

History
executable file
·
95 lines (88 loc) · 2.91 KB

Badge.md

File metadata and controls

executable file
·
95 lines (88 loc) · 2.91 KB

Badge

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.

Preview ios Badge Preview android Badge

Syntax

import React, { Component } from 'react';
import { Container, Content, Badge, Text, Icon } from 'native-base';
export default class BadgeExample extends Component {
  render() {
    return (
      <Container>
        <Content>
          <Badge>
            <Text>2</Text>
          </Badge>
          <Badge primary>
            <Text>2</Text>
          </Badge>
          <Badge success>
            <Text>2</Text>
          </Badge>
          <Badge info>
            <Text>2</Text>
          </Badge>
          <Badge warning>
            <Text>2</Text>
          </Badge>
          <Badge danger>
            <Text>2</Text>
          </Badge>
          <Badge primary>
            <Icon name="star" />
          </Badge>
          <Badge style={{ backgroundColor: 'black' }}>
            <Text style={{ color: 'white' }}>1866</Text>
          </Badge>
        </Content>
      </Container>
    );
  }
}

  • 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