Skip to content

Latest commit

 

History

History
159 lines (120 loc) · 4.61 KB

badge.md

File metadata and controls

159 lines (120 loc) · 4.61 KB

Badge

Adapt UI provides five themes for Badge with three styles. Use this component to show the status of an activity.

simulator_screenshot_371B4CAB-C08A-4EE3-85DE-EF990FC831B1

Simple Usage

import { Badge } from "@adaptui/react-native-tailwind";
export default function App() {
  return <Badge>Beta</Badge>;
}

Table of Contents

Themes

Adapt UI provides five themes for badges: base, primary, secondary, success, and danger.

You can use this themed badge based on your specific scenarios.

simulator_screenshot_23A30580-3C27-435B-9A6C-F2D15534AEB3

Usage

import { Badge, useTheme } from "@adaptui/react-native-tailwind"

export default function App() { 
  const tailwind = useTheme(); 
  return (
    <>
      <Badge>Completed</Badge> 
      <Badge themeColor="primary">Processing</Badge>
      <Badge themeColor="secondary">Waiting</Badge>
      <Badge themeColor="success">Success</Badge>
      <Badge themeColor="danger">Cancelled</Badge> 
    </> 
  ) 
}

Variant

Adapt UI provides three different styles for badges, namely solid, subtle, and outline. You can use these various styled badge components to give a better visual hierarchy.

Simulator Screen Shot - iPhone 12 - 2022-06-23 at 13 00 29

Usage

import { Badge, useTheme } from "@adaptui/react-native-tailwind"

export default function App() {
  const tailwind = useTheme();
  return (
    <>
      <Badge>Solid</Badge> 
      <Badge variant="subtle">Subtle</Badge>
      <Badge variant="outline">Outline</Badge>
    </>
  )
}

Size

Adapt UI provides three different sizes for badges, namely sm, md, and lg.

Simulator Screen Shot - iPhone 12 - 2022-06-23 at 13 05 56

Usage

import { Badge, useTheme } from "@adaptui/react-native-tailwind";

export default function App() {
  const tailwind = useTheme();
  return (
    <>
      <Badge size="sm">Small</Badge> 
      <Badge>Medium</Badge>
      <Badge size="lg">Large</Badge>
    </>
  );
}

Prefix

The prefix is a slot at the beginning or prefix position of a component. Here in the badge, the prefix slot can be used to bring an icon, spinner, or, if we need to think wild, maybe even an avatar. Prefix itself doesn’t have any unique property. It’s a frame that hugs the component inside it.

simulator_screenshot_13BEF27A-9C5C-4404-84D0-65DE9A9C1387

Usage

import { Badge, useTheme, Icon, Check } from "@adaptui/react-native-tailwind";

export default function App() {
  const tailwind = useTheme();
  return (
    <>
      <Badge prefix={<Icon icon={<Check />} />} themeColor="success">
        Completed
      </Badge>
    </>
  );
}

Edit CodeSandbox

Props

Badge implements Box accepting all ViewProps

Name Description Type Default
size How large should badge be? Defaults to 'md' sm md lg md
variant How the badge should look? outline subtle solid solid
themeColor How the badge should be themed? base primary secondary success danger base
prefix If added, the tag will show an icon before the tag's text. JSX.Element
textProps Props for the underlying Text Component TextProps from React Native {}