Badge
A small status indicator component typically used to show counts or status.
Installation
npm install @cleartrip/ct-design-badge
# or
pnpm add @cleartrip/ct-design-badge
Peer dependencies
# Required for all targets
npm install react
# Web only
npm install react-dom
# React Native only
npm install react-native
Usage
Basic
import { Badge } from '@cleartrip/ct-design-badge';
function Example() {
return <Badge>{/* Basic usage */}</Badge>;
}
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
variant | BadgeVariant | — | No | The variant of the badge. Defaults to 'solid'. |
size | BadgeSize | — | No | The size of the badge. Defaults to 'standard'. |
prefixIconNode | ReactNode | — | No | The node representing the prefix icon of the badge. |
text | ReactNode | — | ✅ Yes | The main content of the badge. |
colorScheme | BadgeColor | — | No | The color scheme of the badge. Default value is 'default'. |
styleConfig | IBadgeStyleConfig | — | No | Style configuration for different parts of the badge. |
BadgeVariants
SOLID— solidSUBTLE— subtle
BadgeSizes
STANDARD— standardMICRO— microNANO— nano
BadgeColors
CURACAO— curacaoCURACAO_900— curacao900BLUE— blueDEFAULT— defaultGREEN— greenGREEN_500— green500MARGARITA_250— margarita250MARGARITA_100— margarita100ORANGE_100— orange100ORANGE_250— orange250ORANGE_500— orange500PINA_COLADA— pinaColadaNEUTRAL_700— neutral700RED— redRED_500— red500YELLOW— yellowALERT_500— alert500LINK— linkLINK_TEXT— linkTextBLUE100— blue100BLUE_500— blue500BLUE_900— blue900WHITE— whitePINA_COLADA750— pinaColada750PINA_COLADA100— pinaColada100BROWN— brownBLACK— blackGRAY800— gray800
BadgeGradientColors
GREEN_500— green500GREEN_600— green600PURPLE_100— purple100PURPLE_250— purple250GRAY_100— gray100GRAY_250— gray250AQUA_100— aqua100AQUA_250— aqua250BLACK— blackPINA_COLADA100— pinaColada100
BadgeGradient
BLACKCURRENT— blackcurrentPINOT_NOIR— pinotnoirASPHALT— asphaltBLACK— black
Accessibility
- The component follows accessibility best practices
- Ensure proper ARIA attributes are provided where needed
- Test with screen readers to ensure usability
Migration
If migrating from a previous version:
- import { Badge } from 'yagami/core/components';
+ import { Badge } from '@cleartrip/ct-design-badge';