Skip to content

Commit ec3da7b

Browse files
committed
Pass react node to text badge
1 parent c602ef0 commit ec3da7b

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/lib/components/textbadge/TextBadge.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const StyledTextBadge = styled.span<{ variant: TextBadgeVariant }>`
2424
`}
2525
`;
2626
type Props = {
27-
text: string;
27+
text: React.ReactNode;
2828
className?: string;
2929
variant?: TextBadgeVariant;
3030
} & React.HTMLAttributes<HTMLSpanElement>;

stories/textbadge.stories.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { TextBadge } from '../src/lib/components/textbadge/TextBadge.component';
33
import { Wrapper, Title } from './common';
4+
import { IconHelp } from '../src/lib/components/iconhelper/IconHelper';
5+
import { Text } from '../src/lib/components/text/Text.component';
46
export default {
57
title: 'Components/TextBadge',
68
component: TextBadge,
@@ -21,6 +23,19 @@ export const Default = {
2123
<TextBadge text="2" variant="statusWarning" />
2224
<TextBadge text="3" variant="statusCritical" />
2325
<TextBadge text="Badge" variant="infoSecondary" />
26+
<TextBadge
27+
text={
28+
<>
29+
<Text>This is a badge with a tooltip</Text>
30+
<span style={{ marginLeft: '8px' }}>
31+
<IconHelp
32+
tooltipMessage={<div>This is a tooltip</div>}
33+
title="Info"
34+
/>
35+
</span>
36+
</>
37+
}
38+
/>
2439
</Wrapper>
2540
);
2641
},

0 commit comments

Comments
 (0)