Skip to main content

Badges

Small numerical value or status descriptor for UI elements. Badge normally appears in proximity to notifications or user avatars with eye-catching appeal, typically displaying unread messages count.

The FlexNative Badges is part of the FlexNative Framework and is available under the @flexnative/badges NPM package.

Dependencies

Installation

You can installing FlexNative Badges packages using npm:

npm i @flexnative/badges

API

import Badge from '@flexnative/badges';

Component

Badge

Type: React.PureComponent<BadgedProps>

This component uses the ThemeContext to apply theme-based styles. Component extending React.PureComponent, which is optimized for performance by implementing a shallow prop and state comparison.

Properties

info

TagProps props extends TextProps from react-native

NameTypeRequiredDefault ValueDescription
textstringtrueundefinedText to display on badged.
textColorColorValuefalseundefinedText Color.
childrenReactNodetrueundefinedReactNode to render where to render the badge.
borderWidthBorderWidthfalse'none'Optional borders width.
positionBadgePositionfalse'top-right'Badge position.
borderColorColorValuefalseundefinedBorders color according react-native ColorValue.
sizeSizesfalse'default'Badge Size variable.
typeBadgeTypefalse'default'Badge type.
radiusBorderRadiusfalse'full'Badge border radius.
colorColorfalsetheme.color.defaultColor by theme or a custom color according react-native ColorValue.

BadgePosition

One of 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | Position

NameTypeValue
top-leftobject{ top: -10, left: -10 }
top-rightobject{ top: -10, right: -10 }
bottom-leftobject{ bottom: -10, left: -10 }
bottom-rightobject{ bottom: -10, right: -10 }
positionPositionundefined

Position

NameTypeRequired
topnumberfalse
bottomnumberfalse
leftnumberfalse
rightnumberfalse

BadgeType

One of 'default' | 'text' | 'ghost'

NameTypeDescription
defaultstringBadge filled with solid background.
textstringBadge with only text, ith transparent background.
ghoststringBadge filled with a transparent background.
warning
To have good appearance for 'ghost', with custom color you should use hex colors.

Color

One of 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error' | 'dark' | 'light' | ColorValue

Name Type ValuePreview
LightDark
whiteColorValuetheme.colors.white #FFFFFF #FFFFFF
blackColorValuetheme.colors.black #424242 #424242
backgroundColorValuetheme.colors.background #f8f8f8 #000000
defaultColorValuetheme.colors.default #f5f5f5 #404040
cardColorValuetheme.colors.card #ffffff #232323
textColorValuetheme.colors.text #424242 #ffffff
borderColorValuetheme.colors.border #42424226 #ffffff1A
placeholderColorValuetheme.colors.placeholder #0000001A #FFFFFF1A
infoColorValuetheme.colors.info #3e80ed #3e80ed
successColorValuetheme.colors.success #5ec232 #5ec232
warningColorValuetheme.colors.warning #ffc107 #ffc107
errorColorValuetheme.colors.error #d51923 #d51923
darkColorValuetheme.colors.dark #424242 #424242
secondaryColorValuetheme.colors.secondary #666666 #5C5C5C
lightColorValuetheme.colors.light #ebebeb #ebebeb
primaryColorValuetheme.colors.primary #ff6358 #ff6358
overlayColorValuetheme.colors.overlay #00000021 #FFFFFF21
ColorValueAny ColorValue chosen by developer.

Use case Examples

The following example demonstrates the FlexNative Badges in action.

Border Color

10
10
10
10

Border Width

10
10
10
10
10
10

Border Radius

10
10
10
10
10
10

Colors

10
10
10
10
10
10
10
10
10
10
10
10
10

Position

10
10
10
10
10

Size

10
10
10
10

Text Color

10
10
10
10

TextProps

10

Type

10
10
10

Playground

Live Editor
//Play with props to see live changes;

render(
  <Badge text='10' type='default' color='error'>
    <Button color='primary' text="Playground"/>
  </Badge>
);
Result
Loading...