Skip to content

Commit f39633b

Browse files
authored
feat(Tooltip): be able to change max width (#2643)
1 parent aae8f21 commit f39633b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/core/src/components/Tooltip/Tooltip.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ interface TooltipBaseProps extends VibeComponentProps {
128128
* The icon of the tooltip next to the title
129129
*/
130130
icon?: SubIcon;
131+
/**
132+
* Sets the max width of the Tooltip, defaults to 240px
133+
*/
134+
maxWidth?: number;
131135
}
132136
// When last tooltip was shown in the last 1.5 second - the next tooltip will be shown immediately
133137
const IMMEDIATE_SHOW_THRESHOLD_MS = 1500;
@@ -174,7 +178,7 @@ export default class Tooltip extends PureComponent<TooltipProps> {
174178
}
175179

176180
renderTooltipContent() {
177-
const { theme, content, className, style, title, image, icon } = this.props;
181+
const { theme, content, className, style, maxWidth, title, image, icon } = this.props;
178182
if (!content) {
179183
// don't render empty tooltip
180184
return null;
@@ -196,7 +200,10 @@ export default class Tooltip extends PureComponent<TooltipProps> {
196200
}
197201

198202
return (
199-
<div style={style} className={cx(styles.tooltip, getStyle(styles, camelCase(theme)), className)}>
203+
<div
204+
style={maxWidth ? ({ ...style, "--tooltip-max-width": `${maxWidth}px` } as CSSProperties) : style}
205+
className={cx(styles.tooltip, getStyle(styles, camelCase(theme)), className)}
206+
>
200207
{image && <img className={styles.image} src={image} alt="" />}
201208
<div className={cx(styles.content)}>
202209
{title && (

0 commit comments

Comments
 (0)