Badge
Badges are status descriptors used to emphasize an item's state.
Importโ
import { Badge } from '@faststore/ui'
Usageโ
- React
- CSS
Loading...
[data-store-badge] {
background-color: #be185d;
color: #fff;
display: inline-block;
padding: 0.4rem;
border-radius: 0.2rem;
font-size: 0.9rem;
}
Use casesโ
Use the Badge component to highlight:
- Promotional discounts.
- Product features (e.g.,
vegan
orcruelty-free
). - Product availability statuses (e.g.,
NEW
,ONLY 1 LEFT
andOUT OF STOCK
).
Loading...
Propsโ
Customizationโ
data-store-badge
Best practicesโ
โ Do'sโ
- Place the badge next to or on top of its related item.
- Be cautious about the badge's positioning, writing, shape, and color to avoid any confusion with components similar in appearance.
โ Don'tsโ
- Don't use long texts in badges. A reasonable character limit is 15.
- Don't label badges with active verbs.
- Don't use color alone to convey information. If color is needed to convey meaning, ensure there is a text alternative for that meaning as well.
- Don't place badges next to buttons. Although badges and buttons are similar in appearance, badges are not interactive and may confuse users if not used in the proper context.
Accessibilityโ
id
attribute value must be unique.- Text elements must have sufficient color contrast against the background.