Skip to content

Commit c7c4182

Browse files
committed
feat(tooltip): Add message property for plain text tooltip content
1 parent c3d45f0 commit c7c4182

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/components/tooltip/tooltip.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
190190
return this._hideDelay;
191191
}
192192

193+
/**
194+
* Specifies a plain text as tooltip content.
195+
*
196+
* @attr
197+
*/
198+
@property({ type: String })
199+
public message = '';
200+
193201
constructor() {
194202
super();
195203

@@ -348,7 +356,7 @@ export default class IgcTooltipComponent extends EventEmitterMixin<
348356
shift
349357
>
350358
<div ${ref(this._containerRef)} part="base">
351-
<slot></slot>
359+
${this.message ? html`${this.message}` : html`<slot></slot>`}
352360
${this.disableArrow ? nothing : html`<div id="arrow"></div>`}
353361
</div>
354362
</igc-popover>

stories/tooltip.stories.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,20 @@ const metadata: Meta<IgcTooltipComponent> = {
107107
'Specifies the number of milliseconds that should pass before hiding the tooltip.',
108108
control: 'number',
109109
},
110+
message: {
111+
type: 'string',
112+
description: 'Specifies a plain text as tooltip content.',
113+
control: 'text',
114+
table: { defaultValue: { summary: '' } },
115+
},
110116
},
111117
args: {
112118
open: false,
113119
disableArrow: false,
114120
inline: false,
115121
offset: 4,
116122
placement: 'top',
123+
message: '',
117124
},
118125
};
119126

@@ -158,6 +165,8 @@ interface IgcTooltipArgs {
158165
showDelay: number;
159166
/** Specifies the number of milliseconds that should pass before hiding the tooltip. */
160167
hideDelay: number;
168+
/** Specifies a plain text as tooltip content. */
169+
message: string;
161170
}
162171
type Story = StoryObj<IgcTooltipArgs>;
163172

@@ -303,6 +312,7 @@ export const Toggle: Story = {
303312
placement="bottom"
304313
show-delay="500"
305314
hide-delay="500"
315+
message="Simple tooltip content"
306316
>
307317
This tooltip toggles on button click!
308318
</igc-tooltip>

0 commit comments

Comments
 (0)