Command palette

@yasinsensoy/native

React Native · Components

Badge

Small badge showing a status, label or count (same colors and sizes as web's Badge).

3 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

New

Code

import { Badge } from "@yasinsensoy/native";

<Badge>New</Badge>

Events

  1. Events appear here when you interact with the preview.

Press effects (click or Space/Enter)

Corner shape

Style × color

neutralprimarydangersuccesswarning
neutralprimarydangersuccesswarning
neutralprimarydangersuccesswarning

Import

import { Badge } from "@yasinsensoy/native";

Badge

component

Small badge showing a status, label or count (same colors and sizes as web's Badge).

Badge({ ref, children, tone: toneProp, variant: variantProp, effect, tooltip, icon, dot, size: sizeProp, accessibilityLabel, style, }: BadgeProps): ReactNode

Examples

<Badge>Draft</Badge>
<Badge tone="success" icon="check">Paid</Badge>
<Badge tone="danger" variant="solid">3</Badge>
<Badge tone="success" dot>Online</Badge>

Badge style (same as web).

type BadgeVariant = "solid" | "soft" | "outline"

BadgeProps

interface

Props of Badge.

NameTypeDefaultDescription
ref?Ref<ViewRef>Ref of the underlying native element.
children?ReactNodeText or number.
tone?Tone"neutral"` (or `appearance.defaults.badge.tone`)Color.
variant?BadgeVariant | (string & {})"soft"Variant: one of the built-in variants or a name added via appearance.variants.badge (the style's color field is the text color).
effect?EffectPropEffect or effects ("shine", "pulse"…). Defaults to appearance.defaults.badge.effect. See BuiltinEffect.
tooltip?TooltipPropTooltip shown on press and hold. See TooltipProp.
icon?IconPropIcon at the start of the text.
dot?booleanPuts a colored status dot before the text (e.g. "Online").
size?"sm" | "md""md"` (or `appearance.defaults.badge.size`)Size.
accessibilityLabel?stringScreen reader label (if the content is not text).
style?StyleProp<ViewStyle>Container style.