Skip to content

Latest commit

 

History

History
executable file
·
118 lines (104 loc) · 4.02 KB

Badge.md

File metadata and controls

executable file
·
118 lines (104 loc) · 4.02 KB

Customize Badge

Steps to customize theme for Badge attributes:

Property Description
badgeColor Badge text color
badgeBg Badge background color

With Badge theme

With this theme of Badge component you can modify any style rules applied to the default Badge component.

Syntax

import React, { Component } from 'react-native';
import { Container, Content, Badge, StyleProvider } from 'native-base';
import badgeTheme from './Themes/badgeTheme';
​// badgeTheme is the customized theme of Badge Component

export default class ThemeBadgeExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <StyleProvider style={badgeTheme()}>
                        <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>
                    </StyleProvider>
                </Content>
            </Container>
        );
    }
}

With Variables

With the variable.js file you can modify the variable values passed to the theme of the Badge component.
Say color of badgeColor of the Text in Badge.

Syntax

import React, { Component } from 'react-native';
import { Container, Content, Badge, Text, StyleProvider, getTheme } from 'native-base';
import customVariables from './Themes/variable';
​// getTheme is default theme of NativeBase Components
// customVariables is customized variables used in the components theme

export default class ThemeBadgeExample extends Component {
    render() {
        return (
            <Container>
                <Content>
                    <StyleProvider style={getTheme(customVariables)}>
                        <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>
                    </StyleProvider>
                </Content>
            </Container>
        );
    }
}