|
| 1 | +# Badge |
| 2 | + |
| 3 | +Adapt UI provides five themes for `Badge` with three styles. Use this component |
| 4 | +to show the status of an activity. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | + |
| 10 | +#### Simple Usage |
| 11 | + |
| 12 | +``` |
| 13 | +import { Badge } from "@adaptui/react-native-tailwind" |
| 14 | +export default function App() { |
| 15 | + return ( |
| 16 | + <Badge>Beta</Badge> |
| 17 | + ) |
| 18 | +} |
| 19 | +``` |
| 20 | + |
| 21 | +## Table of Contents |
| 22 | + |
| 23 | +- [Themes](#themes) |
| 24 | +- [Variant](#variant) |
| 25 | +- [Size](#size) |
| 26 | +- [Prefix](#prefix) |
| 27 | +- [Props](#props) |
| 28 | + |
| 29 | +## Themes |
| 30 | + |
| 31 | +Adapt UI provides five themes for badges: `base`, `primary`, `secondary`, |
| 32 | +`success`, and `danger`. |
| 33 | + |
| 34 | +You can use this themed badge based on your specific scenarios. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +<details> |
| 39 | + |
| 40 | +<summary> |
| 41 | + <h3>Usage</h3> |
| 42 | +</summary> |
| 43 | + |
| 44 | +``` |
| 45 | +import { Badge, useTheme } from "@adaptui/react-native-tailwind" |
| 46 | +
|
| 47 | +export default function App() { |
| 48 | + const tailwind = useTheme(); |
| 49 | + return ( |
| 50 | + <> |
| 51 | + <Badge>Completed</Badge> |
| 52 | + <Badge themeColor="primary">Processing</Badge> |
| 53 | + <Badge themeColor="secondary">Waiting</Badge> |
| 54 | + <Badge themeColor="success">Success</Badge> |
| 55 | + <Badge themeColor="danger">Cancelled</Badge> |
| 56 | + </> |
| 57 | + ) |
| 58 | +} |
| 59 | +``` |
| 60 | +</details> |
| 61 | + |
| 62 | +## Variant |
| 63 | + |
| 64 | +Adapt UI provides three different styles for badges, namely `solid`, `subtle`, |
| 65 | +and `outline`. You can use these various styled badge components to give a |
| 66 | +better visual hierarchy. |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +<details> |
| 72 | +<summary> |
| 73 | + <h3>Usage</h3> |
| 74 | +</summary> |
| 75 | + |
| 76 | +``` |
| 77 | +import { Badge, useTheme } from "@adaptui/react-native-tailwind" |
| 78 | +
|
| 79 | +export default function App() { |
| 80 | + const tailwind = useTheme(); |
| 81 | + return ( |
| 82 | + <> |
| 83 | + <Badge>Solid</Badge> |
| 84 | + <Badge variant="subtle">Subtle</Badge> |
| 85 | + <Badge variant="outline">Outline</Badge> |
| 86 | + </> |
| 87 | + ) |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +</details> |
| 92 | + |
| 93 | +## Size |
| 94 | + |
| 95 | +Adapt UI provides three different sizes for badges, namely `sm`, `md`, and `lg`. |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +<details> |
| 100 | +<summary> |
| 101 | + <h3>Usage</h3> |
| 102 | +</summary> |
| 103 | + |
| 104 | +``` |
| 105 | +import { Badge, useTheme } from "@adaptui/react-native-tailwind" |
| 106 | +
|
| 107 | +export default function App() { |
| 108 | + const tailwind = useTheme(); |
| 109 | + return ( |
| 110 | + <> |
| 111 | + <Badge size="sm">Small</Badge> |
| 112 | + <Badge>Medium</Badge> |
| 113 | + <Badge size="lg">Large</Badge> |
| 114 | + </> |
| 115 | + ) |
| 116 | +} |
| 117 | +
|
| 118 | +``` |
| 119 | + |
| 120 | +</details> |
| 121 | + |
| 122 | +## Prefix |
| 123 | + |
| 124 | +The prefix is a slot at the beginning or prefix position of a component. Here in |
| 125 | +the badge, the prefix slot can be used to bring an icon, spinner, or, if we need |
| 126 | +to think wild, maybe even an avatar. Prefix itself doesn’t have any unique |
| 127 | +property. It’s a frame that hugs the component inside it. |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | +<details> |
| 133 | +<summary> |
| 134 | + <h3>Usage</h3> |
| 135 | +</summary> |
| 136 | + |
| 137 | +``` |
| 138 | +import { Badge, useTheme, Icon, Check } from "@adaptui/react-native-tailwind" |
| 139 | +
|
| 140 | +export default function App() { |
| 141 | + const tailwind = useTheme(); |
| 142 | + return ( |
| 143 | + <> |
| 144 | + <Badge prefix={<Icon icon={<Check />} />} themeColor="success"> |
| 145 | + Completed |
| 146 | + </Badge> |
| 147 | + </> |
| 148 | + ) |
| 149 | +} |
| 150 | +
|
| 151 | +``` |
| 152 | + |
| 153 | +</details> |
| 154 | + |
| 155 | +[](https://snack.expo.dev/@timelessco/badge-component--adaptui) |
| 156 | + |
| 157 | +## Props |
| 158 | + |
| 159 | +> Badge implements Box accepting all `ViewProps` |
| 160 | +
|
| 161 | +| Name | Description | Type | Default | |
| 162 | +| ---------- | ---------------------------------------------------------- | ----------------------------------------------- | ------- | |
| 163 | +| size | How large should badge be? Defaults to 'md' | `sm` `md` `lg` | `md` | |
| 164 | +| variant | How the badge should look? | `outline` `subtle` `solid` | `solid` | |
| 165 | +| themeColor | How the badge should be themed? | `base` `primary` `secondary` `success` `danger` | `base` | |
| 166 | +| prefix | If added, the tag will show an icon before the tag's text. | JSX.Element | | |
| 167 | +| textProps | Props for the underlying Text Component | `TextProps` from React Native | {} | |
0 commit comments