Display tooltip on hover over tabs

1 Answer 54 Views
TabStrip Tooltip
Abhishek
Top achievements
Rank 2
Iron
Iron
Iron
Abhishek asked on 01 Jul 2024, 04:48 PM
I have 2 tabs in my page. Based on some Boolean condition i have to show the tabs with custom title on each tab on hover. Kindly help

1 Answer, 1 is accepted

Sort by
0
Yanko
Telerik team
answered on 03 Jul 2024, 11:32 AM

Hello, Abhishek,

You can achieve this by programatically setting the `title` property to the required element.

In the below example, in `React.useEffect`, I am mapping over the items with className `k-item k-tabstrip-item`, and I am setting the title to `123` to the element with `outerText` equal to `Paris`. You can set any custom title you want:

I hope this example suits you and please let me know if you have any further questions.

Regards,
Yanko
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Abhishek
Top achievements
Rank 2
Iron
Iron
Iron
commented on 03 Jul 2024, 02:33 PM

I want the tooltip to look similar to Kendoreact tooltip 
Konstantin Dikov
Telerik team
commented on 03 Jul 2024, 02:59 PM

You can wrap the TabStrip within a Tooltip component in order to display the "title" attributes with the KendoReact Tooltip.

As a side note, the "title" property of the TabStripTab accepts React Node, which means that you can add an element with a "title" attribute directly in the title. Additionally, if you want to use a state variable within the tooltip, you can set the updateInterval of the Tooltip component, so it can get the updated value every n seconds. 

For your convenience, following is an example demonstrating the above approach with a dynamic state variable, React Node as a title and a KendoReact Tooltip:

Abhishek
Top achievements
Rank 2
Iron
Iron
Iron
commented on 16 Jul 2024, 08:44 AM | edited

The tab might be disabled based on some condition & i want to show tooltip only on the disabled tab. I am using disabled property in the tooltip
Konstantin Dikov
Telerik team
commented on 17 Jul 2024, 06:44 PM

When a Tab is disabled, it will have "pointer-events: none" from the theme styles, which will prevent the display of a tooltip. If you want to allow the tooltips for disabled elements you can use the following override for the styles:

            <style>
                .k-tabstrip .k-disabled{
                    pointer-events: all;
                } 

Abhishek
Top achievements
Rank 2
Iron
Iron
Iron
commented on 18 Jul 2024, 06:46 AM

Thank you. It worked. But 1 thing. I have to display the Tab title based on some conditions. So i have added some span tags to display the title. The above solution worked only when i removed the span tags. Is it a valid or is there any other solutions?
Konstantin Dikov
Telerik team
commented on 19 Jul 2024, 08:18 PM

Hi Abhishek,

I am not sure that I understand the exact scenario that you have, but you can try setting the "parentTitle" property of the Tooltip to "true" and see if that will resolve the issue.

    <Tooltip
      position={'right'}
      anchorElement={'target'}
      updateInterval={1000}
      parentTitle={true}
    >

If further assistance is needed, please modify the example to better demonstrate your scenario, so we can test it locally.

Tags
TabStrip Tooltip
Asked by
Abhishek
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Yanko
Telerik team
Share this question
or