Skip to main content

Badge

Badge is a compact label that marks an item with a status or count, such as a shipped order or unread messages.

Import

import { Badge } from '@vortexlabs/vortex-native';
import type { BadgeProps } from '@vortexlabs/vortex-native';

Other links

import { Badge } from "@vortexlabs/vortex-native";

<Badge
  size="md"
  tone="success"
  variant="subtle"
  rounded={false}
>
  Shipped
</Badge>

Features

  • Displays a label, count, icon, or status dot.
  • Supports three visual styles, seven tones, and four responsive sizes.
  • Positions a badge on the corner of another element.
  • Can hide a badge while preserving its space in the layout.

Variants

Choose subtle for a quiet label, solid for stronger emphasis, or outline for a bordered label.

<Stack direction="row" gap={2} align="center" wrap>
  <Badge tone="primary" variant="subtle">Review</Badge>
  <Badge tone="primary" variant="solid">Review</Badge>
  <Badge tone="primary" variant="outline">Review</Badge>
</Stack>

Tone

Use the label to name the status and the tone to reinforce it. For example, an overdue payment can use the critical tone.

<Stack direction="row" gap={2} align="center" wrap>
  <Badge tone="neutral">Draft</Badge>
  <Badge tone="primary">Featured</Badge>
  <Badge tone="secondary">Partner</Badge>
  <Badge tone="info">In review</Badge>
  <Badge tone="success">Paid</Badge>
  <Badge tone="warning">Due soon</Badge>
  <Badge tone="critical">Overdue</Badge>
</Stack>

Sizes and shape

Use xs for a short count and sm through lg for labels with icons. The default is md. Set rounded for pill-shaped corners.

<Stack direction="row" gap={2} align="center" wrap>
  <Badge size="xs" rounded>3</Badge>
  <Badge size="sm">Draft</Badge>
  <Badge size="md">Draft</Badge>
  <Badge size="lg">Draft</Badge>
</Stack>

Icons

Place one icon before or after a label. For an icon alone, pass onlyIcon and supply its meaning with ariaLabel.

import { ArrowRight, Check } from "@vortexlabs/vortex-icons";

<Stack direction="row" gap={2} align="center" wrap>
  <Badge startIcon={Check} tone="success">Paid</Badge>
  <Badge endIcon={ArrowRight}>Next</Badge>
  <Badge onlyIcon={Check} ariaLabel="Paid" tone="success" />
</Stack>

Status dot

Omit the content to show a dot. Pair it with a visible label so the status is clear without color.

<Stack direction="row" align="center" gap={2}>
  <Badge tone="success" />
  <Text>Available</Text>
</Stack>

Badge.Frame

Place the badge after the content it labels. By default it sits at the top end. Use bottom-end for the lower corner and overlap to bring the badge inward on round content.

<Badge.Frame position="bottom-end" overlap>
  <Avatar initials="AL" rounded size="xl" />
  <Badge size="xs" tone="primary" rounded>3</Badge>
</Badge.Frame>

Visibility

Set hidden to fade out the badge while keeping its space. Mark the message read to see the button stay in place.

import { Badge, Button, Stack } from "@vortexlabs/vortex-native";
import { useState } from "react";

export const MessageStatus = () => {
  const [unread, setUnread] = useState(true);
  return (
    <Stack direction="row" align="center" gap={2}>
      <Badge hidden={!unread} tone="info">Unread</Badge>
      <Button variant="secondary" onPress={() => setUnread(!unread)}>
        {unread ? "Mark read" : "Mark unread"}
      </Button>
    </Stack>
  );
};

Accessibility

Description
Use visible text to convey a status or count. An icon-only badge uses ariaLabel as its accessible name.
A hidden badge keeps its layout space and is hidden from screen readers.