|
| 1 | +--- |
| 2 | +product: dd360-ds |
| 3 | +title: React Badge component |
| 4 | +components: Badge |
| 5 | +--- |
| 6 | + |
| 7 | +<br /> |
| 8 | +<br /> |
| 9 | + |
| 10 | +<Label>Components</Label> |
| 11 | + |
| 12 | +# <HeaderDocCustom title="Badge" pathUrl="images-avatar--with-image" /> |
| 13 | + |
| 14 | +The Badge component in React provides a convenient way to display a small piece of information, such as a status, in a visually appealing and attention-grabbing manner. |
| 15 | + |
| 16 | +<br /> |
| 17 | + |
| 18 | +##### <span name="floating-nav">Imports</span> |
| 19 | + |
| 20 | +<WindowEditor codeString="import { Badge } from 'dd360-ds'" /> |
| 21 | + |
| 22 | +##### <span name="floating-nav">Usage</span> |
| 23 | + |
| 24 | +To use the Badge component, you could start by adding the properties text, classNameIcon and className. |
| 25 | + |
| 26 | +Use the Badge component as shown below: |
| 27 | + |
| 28 | +<Playground> |
| 29 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1' /> |
| 30 | +</Playground> |
| 31 | + |
| 32 | +The code snippet below shows how to use the Badge component: |
| 33 | + |
| 34 | +<WindowEditor |
| 35 | + codeString={`import { Badge } from 'dd360-ds' |
| 36 | +
|
| 37 | + <Badge text="Hello world"/> |
| 38 | +`}/> |
| 39 | + |
| 40 | +<br /> |
| 41 | + |
| 42 | +##### <span name="floating-nav">Variant</span> |
| 43 | + |
| 44 | +With the prop variant you can customize the appearance of the Badge component. Available options are: warning, infoPrimary, infoSecondary, success, primary, secondary, and error. Default uses: "infoPrimary". |
| 45 | + |
| 46 | +<Playground className="flex flex-col gap-y-2"> |
| 47 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="warning"/> |
| 48 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="infoPrimary"/> |
| 49 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="infoSecondary"/> |
| 50 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="success"/> |
| 51 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="primary"/> |
| 52 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="secondary"/> |
| 53 | + <Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="error"/> |
| 54 | +</Playground> |
| 55 | + |
| 56 | +The code snippet below shows how to set a Badge component variant: |
| 57 | + |
| 58 | +<WindowEditor |
| 59 | + codeString={`import { Badge } from 'dd360-ds' |
| 60 | +
|
| 61 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="warning"/> |
| 62 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="infoPrimary"/> |
| 63 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="infoSecondary"/> |
| 64 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="success"/> |
| 65 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="primary"/> |
| 66 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="secondary"/> |
| 67 | +<Badge text="Hello world" classNameIcon='w-4' className='p-1 text-gray-500' variant="error"/> |
| 68 | +`}/> |
| 69 | + |
| 70 | +<br /> |
| 71 | + |
| 72 | +##### <span name="floating-nav">Icon</span> |
| 73 | + |
| 74 | +With the prop icon you can customize the icon of the Badge component. Available options are: tag, clock, warning, check, success, exclamation, clipboard-copy, HomeIcon, RefreshIcon, and none. Default uses: "HomeIcon". |
| 75 | + |
| 76 | +<Playground className="flex flex-col gap-y-2"> |
| 77 | + <Badge text="tag" classNameIcon='w-4' className='p-1 text-gray-500' icon="tag"/> |
| 78 | + <Badge text="clock" classNameIcon='w-4' className='p-1 text-gray-500' icon="clock"/> |
| 79 | + <Badge text="warning" classNameIcon='w-4' className='p-1 text-gray-500' icon="warning"/> |
| 80 | + <Badge text="check" classNameIcon='w-4' className='p-1 text-gray-500' icon="check"/> |
| 81 | + <Badge text="success" classNameIcon='w-4' className='p-1 text-gray-500' icon="success"/> |
| 82 | + <Badge text="exclamation" classNameIcon='w-4' className='p-1 text-gray-500' icon="exclamation"/> |
| 83 | + <Badge text="clipboard-copy" classNameIcon='w-4' className='p-1 text-gray-500' icon="clipboard-copy"/> |
| 84 | + <Badge text="HomeIcon" classNameIcon='w-4' className='p-1 text-gray-500' icon="HomeIcon"/> |
| 85 | + <Badge text="RefreshIcon" classNameIcon='w-4' className='p-1 text-gray-500' icon="RefreshIcon"/> |
| 86 | + <Badge text="none" classNameIcon='w-4' className='p-1 text-gray-500' icon="none"/> |
| 87 | +</Playground> |
| 88 | + |
| 89 | +The code snippet below shows how to set a Badge component icon: |
| 90 | + |
| 91 | +<WindowEditor |
| 92 | + codeString={`import { Badge } from 'dd360-ds' |
| 93 | +
|
| 94 | +<Badge text="tag" classNameIcon='w-4' className='p-1 text-gray-500' icon="tag"/> |
| 95 | +<Badge text="clock" classNameIcon='w-4' className='p-1 text-gray-500' icon="clock"/> |
| 96 | +<Badge text="warning" classNameIcon='w-4' className='p-1 text-gray-500' icon="warning"/> |
| 97 | +<Badge text="check" classNameIcon='w-4' className='p-1 text-gray-500' icon="check"/> |
| 98 | +<Badge text="success" classNameIcon='w-4' className='p-1 text-gray-500' icon="success"/> |
| 99 | +<Badge text="exclamation" classNameIcon='w-4' className='p-1 text-gray-500' icon="exclamation"/> |
| 100 | +<Badge text="clipboard-copy" classNameIcon='w-4' className='p-1 text-gray-500' icon="clipboard-copy"/> |
| 101 | +<Badge text="HomeIcon" classNameIcon='w-4' className='p-1 text-gray-500' icon="HomeIcon"/> |
| 102 | +<Badge text="RefreshIcon" classNameIcon='w-4' className='p-1 text-gray-500' icon="RefreshIcon"/> |
| 103 | +<Badge text="none" classNameIcon='w-4' className='p-1 text-gray-500' icon="none"/> |
| 104 | +`}/> |
| 105 | + |
| 106 | +<br /> |
| 107 | +<br /> |
| 108 | + |
| 109 | +##### <span name="floating-nav">API Reference</span> |
| 110 | + |
| 111 | +<CustomTableDocs |
| 112 | + dataTable={[ |
| 113 | + { title: 'variant', default: 'infoPrimary', types: ['warning', 'infoPrimary', 'infoSecondary', 'success', 'primary', 'secondary', 'error'] }, |
| 114 | + { title: 'icon', default: 'HomeIcon', types: ['tag', 'clock', 'warning', 'check', 'success', 'exclamation', 'clipboard-copy', 'HomeIcon', 'RefreshIcon', 'none'] }, |
| 115 | + { title: 'text', default: 'Home Badge', types: ['string'] }, |
| 116 | + { title: 'classNameIcon', default: null, types: ['string'] }, |
| 117 | + { title: 'classNameText', default: null, types: ['string'] }, |
| 118 | + { title: 'className', default: null, types: ['string'] } |
| 119 | + ]} |
| 120 | +/> |
| 121 | + |
| 122 | +Note: This documentation assumes that the audience has basic knowledge of React |
| 123 | +and how to use components in React applications. |
| 124 | + |
| 125 | +<BackAndForwardController /> |
0 commit comments