# Badge Use badges to highlight contextual information, like a label or a status, about an object. An object can be anything that has a status or label attributed to it, like an order or subscription. ### Basic Badge ```tsx import { reactExtension, Badge, } from '@shopify/ui-extensions-react/checkout'; export default reactExtension( 'purchase.checkout.block.render', () => <Extension />, ); function Extension() { return <Badge>Available</Badge>; } ``` ```js import {extension, Badge} from '@shopify/ui-extensions/checkout'; export default extension('purchase.checkout.block.render', (root) => { const badge = root.createComponent(Badge, undefined, 'Available'); root.appendChild(badge); }); ``` ## BadgeProps ### BadgeProps ### accessibilityLabel A label that describes the purpose or contents of the element. When set, it will be passed as `aria-label` to underlying element and announced to buyers using assistive technologies. ### accessibilityVisibility Changes the visibility of the element to assistive technologies. `hidden` hides the component from assistive technology (for example, a screen reader) but remains visually visible. ### icon The name of the icon to be displayed in the badge. ### iconPosition The position of the icon in relation to the text. ### size The size of the badge being rendered. ### tone The tone of the badge being rendered. Indicates its level of importance, where subdued provides the least emphasis, while critical indicates the highest level of urgency. ### visibility Changes the visibility of the element. `hidden` visually hides the component while keeping it accessible to assistive technology, such as screen readers. Hidden elements don't take any visual space contrary to CSS visibility: hidden; ### AccessibilityVisibility 'hidden' ### IconSource 'arrowLeft' | 'arrowRight' | 'arrowUp' | 'arrowUpRight' | 'arrowDown' | 'bag' | 'bullet' | 'calendar' | 'camera' | 'caretDown' | 'cart' | 'cashDollar' | 'categories' | 'checkmark' | 'chevronLeft' | 'chevronRight' | 'chevronUp' | 'chevronDown' | 'clock' | 'close' | 'creditCard' | 'critical' | 'delete' | 'delivered' | 'delivery' | 'disabled' | 'discount' | 'email' | 'error' | 'errorFill' | 'external' | 'filter' | 'geolocation' | 'gift' | 'giftFill' | 'grid' | 'hamburger' | 'hollowCircle' | 'horizontalDots' | 'image' | 'info' | 'infoFill' | 'list' | 'lock' | 'magnify' | 'map' | 'marker' | 'minus' | 'mobile' | 'note' | 'orderBox' | 'pen' | 'plus' | 'profile' | 'question' | 'questionFill' | 'reorder' | 'return' | 'savings' | 'settings' | 'star' | 'starFill' | 'starHalf' | 'store' | 'success' | 'truck' | 'upload' | 'verticalDots' | 'warning' | 'warningFill' ### Size 'extraSmall' | 'small' | 'base' | 'large' | 'extraLarge' | 'fill' ### Tone 'default' | 'critical' | 'subdued' ### Visibility 'hidden' ## Examples Use badges to highlight contextual information, like a label or a status, about an object. An object can be anything that has a status or label attributed to it, like an order or subscription. ### ### Using the Badge component as a status indicator ```tsx import { reactExtension, Badge, BlockStack, Text, } from '@shopify/ui-extensions-react/checkout'; export default reactExtension( 'purchase.checkout.block.render', () => <Extension />, ); function Extension() { return ( <BlockStack border="base" padding="large200" spacing="base" borderRadius="large" > <BlockStack spacing="none"> <Text size="large" emphasis="bold"> Subscription </Text> <Text>Mini garden seeds</Text> </BlockStack> <BlockStack spacing="none" inlineAlignment="start" > <Text emphasis="bold"> $35.00 monthly </Text> <Badge tone="subdued">Paused</Badge> </BlockStack> </BlockStack> ); } ``` ```js import { extension, Badge, BlockStack, Text, } from '@shopify/ui-extensions/checkout'; export default extension('purchase.checkout.block.render', (root) => { const container = root.createComponent( BlockStack, { border: 'base', padding: 'large200', spacing: 'base', borderRadius: 'large', }, [ root.createComponent(BlockStack, {spacing: 'none'}, [ root.createComponent( Text, {size: 'large', emphasis: 'bold'}, 'Subscription', ), root.createComponent(Text, undefined, 'Mini garden seeds'), ]), root.createComponent( BlockStack, {spacing: 'none', inlineAlignment: 'start'}, [ root.createComponent(Text, {emphasis: 'bold'}, '$35.00 monthly'), root.createComponent(Badge, {tone: 'subdued'}, 'Paused'), ], ), ], ); root.appendChild(container); }); ```