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>

Properties

info

TagProps props extends TextProps from react-native

NameTypeRequiredDefault ValueDescription
textstringtrueundefinedText to display on badged.
textColorColorValuefalseundefinedText Color.
backgroundColorColorValuefalseundefinedBadge background 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.
sizeBadgeSizefalse'default'Badge Size variable.
typeBadgeTypefalse'default'Badge type.
radiusBadgeRadiusfalse'full'Badge border radius.
colorBadgeColorfalsetheme.color.defaultColor by theme or a custom color according react-native ColorValue.

BorderWidth

One of 'none' | 'hairline' | 'thin' | 'base' | 'thick' | number

NameTypeValue
nonenumber0
hairlineStyleSheet.hairlineWidthThis is defined as the width of a thin line on the platform. It can be used as the thickness of a border or division between two elements.
thinnumber1
basenumber2
thicknumber3
numberAny number value

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

BadgeSize

One of 'small' | 'medium' | 'large' | number

NameTypeValue
smallnumber12
defaultnumber16
mediumnumber20
largenumber24

BadgeType

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

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

BadgeRadius

One of 'none' | 'small' | 'medium' | 'large' | 'full' | number

NameTypeValue
nonenumber0
smallnumber2
mediumnumber4
largenumber6
fullnumber99999
numberAny number value.

BadgeColor

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

Name Type ValuePreview
LightDark
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
ColorValueAny ColorValue chosen by developer.

Usecase Examples

The following example demonstrates the FlexNative Badges in action.

Background Color

10
10
10
10

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...