Skip to content

Commit 8c81a98

Browse files
dimodijivanova
authored andcommitted
docs(tooltip): Add custom styling KB
1 parent d2439dd commit 8c81a98

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

components/tooltip/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The <a href="https://www.telerik.com/blazor-ui/tooltip" target="_blank">Blazor T
4848

4949
>caption The Tooltip provides the following features:
5050
51-
* `Class` - the CSS class of the **tooltip container**. You can use it to customize the tooltip appearance (such as color, font, elements in your template, and so on). To apply custom styles to the tooltip element itself, use a [descendant combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator), for example:
51+
* `Class` - the CSS class of the **tooltip container**. You can use it to [customize the tooltip appearance]({%slug tooltip-kb-custom-styles%}) (such as color, font, elements in your template, and so on). To apply custom styles to the tooltip element itself, use a [descendant combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator), for example:
5252

5353
<TelerikTooltip Class="my-class" />
5454

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Custom ToolTip Styles and Colors
3+
description: How to apply custom ToolTip CSS styles like text color and background color.
4+
type: how-to
5+
page_title: Custom ToolTip Styles and Colors
6+
slug: tooltip-kb-custom-styles
7+
position:
8+
tags: tooltip, styling
9+
ticketid: 1563191
10+
res_type: kb
11+
---
12+
13+
## Environment
14+
15+
<table>
16+
<tbody>
17+
<tr>
18+
<td>Product</td>
19+
<td>ToolTip for Blazor</td>
20+
</tr>
21+
</tbody>
22+
</table>
23+
24+
## Description
25+
26+
How to customize the Blazor ToolTip styling? I want to set different text color and background color.
27+
28+
## Solution
29+
30+
1. Review the [fundamentals of custom styling and CSS overrides]({%slug themes-override%}).
31+
1. Set a `Class` to the TelerikToolTip component.
32+
1. Each tooltip is a `div.k-tooltip`. Note that the custom CSS class renders on the tooltip's **container**, not the `.k-tooltip` element itself. So use a [descendant CSS combinator](https://developer.mozilla.org/en-US/docs/Web/CSS/Descendant_combinator).
33+
1. If using a custom **background** color for `.k-tooltip`, then use the same **text** color for `.k-tooltip .k-callout`.
34+
35+
>caption Blazor ToolTip with custom background and text color
36+
37+
````CSHTML
38+
<div class="target" title="ToolTip Text">Blue background, yelow color</div>
39+
40+
<TelerikTooltip TargetSelector=".target" Class="blue-yellow" />
41+
42+
<style>
43+
/* the ToolTip Class renders on the tooltip's container */
44+
.blue-yellow .k-tooltip {
45+
background: blue;
46+
color: yellow;
47+
}
48+
49+
.blue-yellow .k-tooltip .k-callout {
50+
/* same as tooltip background */
51+
color: blue;
52+
}
53+
54+
.target {
55+
position: absolute;
56+
top: 25vh;
57+
left: 25vw;
58+
width: 15vw;
59+
height: 10vh;
60+
border: 1px solid;
61+
padding: 1em;
62+
}
63+
</style>
64+
````

0 commit comments

Comments
 (0)