Setting dimension in React Tooltip component
14 Aug 20236 minutes to read
Height and width
The Tooltip can either be assigned auto height and width values or specific pixel values. The width
and height
properties are used to set the outer dimension of the Tooltip element. The default value for both the properties is auto
. It also accepts string and number values in pixels.
The following sample explains how to set dimensions for the Tooltip.
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { TooltipComponent } from '@syncfusion/ej2-react-popups';
function App() {
return (<TooltipComponent width="180px" height="40px" content="This tooltip has 180px width and 40px height">
<div id='target'>Show Tooltip</div>
</TooltipComponent>);
}
export default App;
ReactDom.render(<App />, document.getElementById('sample'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { TooltipComponent } from '@syncfusion/ej2-react-popups';
function App() {
return (
<TooltipComponent width="180px" height="40px" content="This tooltip has 180px width and 40px height">
<div id='target'>Show Tooltip</div>
</TooltipComponent>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('sample'));
Scroll mode
When height
is specified with a certain pixel value and the Tooltip content overflows, the scrolling mode gets enabled.
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { TooltipComponent } from '@syncfusion/ej2-react-popups';
function App() {
function content() {
return (<span id='tooltipContent'>
<p><strong>Environmentally friendly</strong> or <strong>environment-friendly</strong>, <i>(also referred to as eco-friendly, nature-friendly, and green)</i> are marketing and sustainability terms referring to goods and services, laws, guidelines and policies that inflict reduced, minimal, or no harm upon ecosystems or the environment.</p></span>);
}
let style = {
display: 'inline-block',
padding: '5px'
};
return (<p>A green home is a type of house designed to be
<TooltipComponent width="300px" height="60px" isSticky={true} content={content} style={style}>
<a><u>environmentally friendly</u></a>
</TooltipComponent> and sustainable. And also focuses on the efficient use of "energy, water, and building materials." As green homes
have become more prevalent we have also seen the emergence of green affordable housing.
</p>);
}
export default App;
ReactDom.render(<App />, document.getElementById('sample'));
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { TooltipComponent } from '@syncfusion/ej2-react-popups';
function App() {
function content() {
return(
<span id='tooltipContent'>
<p><strong>Environmentally friendly</strong> or <strong>environment-friendly</strong>, <i>(also referred to as eco-friendly, nature-friendly, and green)</i> are marketing and sustainability terms referring to goods and services, laws, guidelines and policies that inflict reduced, minimal, or no harm upon ecosystems or the environment.</p></span>
)
}
let style: object = {
display: 'inline-block',
padding : '5px'
};
return (
<TooltipComponent width="300px" height="60px" isSticky={true} content={content} style={style}>
<p>A green home is a type of house designed to be
<a><u>environmentally friendly</u></a>
and sustainable. And also focuses on the efficient use of "energy, water, and building materials." As green homes
have become more prevalent we have also seen the emergence of green affordable housing.</p>
</TooltipComponent>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('sample'));
The scrolling mode can best be seen when the sticky mode of the Tooltip is enabled. To enable sticky mode, set the
isSticky
property to true.