Skip to content

Commit 99453f7

Browse files
authored
Ravamp KB article for Checkbox icon change (#2336)
* docs(Checkbox): ravamp kb article * docs(Checkbox): apply suggested changes
1 parent ff1949f commit 99453f7

File tree

3 files changed

+50
-50
lines changed

3 files changed

+50
-50
lines changed

.k-cell-inner

Whitespace-only changes.

.k-link

Whitespace-only changes.
Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Change Checkbox Icon
3-
description: How to change the CheckBox icon to a custom one.
2+
title: How to Change Checkbox Icons
3+
description: Learn how to change the Checkbox icon, modify the default check mark and indeterminate icons, and integrate third-party icons.
44
type: how-to
5-
page_title: Custom Checkbox Icon
5+
page_title: How to Change Checkbox Icons
66
slug: checkbox-kb-custom-icon
77
position:
88
tags:
@@ -22,69 +22,69 @@ res_type: kb
2222

2323
## Description
2424

25-
How do I change the checkbox icon? I want to use another icon, not the default checkmark.
25+
This knowledge base article answers the following questions:
26+
27+
* How do I change the Checkbox icon?
28+
* How to change the default check mark icon?
29+
* How to change the icon of the indeterminate state?
30+
* How to integrate custom icons from a third-party library into a Telerik Checkbox component?
2631

2732
## Solution
33+
1. Set a custom CSS class to the Tooltip through the `Class` parameter. This configuration will allow you to target specific Checkbox instances.
34+
2. Use the defiend class to [override the theme styles]({%slug themes-override%}) with the following CSS approach.
2835

29-
Add a `Class` to the CheckBox component. [Override the theme styles]({%slug themes-override%}) and change the default font icon glyphs.
36+
>caption How to change the Checkbox icons
3037
31-
You can replace the icons with different glyphs, even from a different font. You can also change the icon size and color.
38+
````CSHTML
39+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" />
3240
33-
The `k-icon` CSS class applies the custom font, which contains all [built-in Telerik font icons]({%slug common-features-icons%}). If you will use a different font, remove `k-icon`.
41+
<p>
42+
<label>
43+
<TelerikCheckBox @bind-Value="@CheckBoxValue"
44+
Size="@ThemeConstants.CheckBox.Size.Large"
45+
Indeterminate="@( !CheckBoxValue.HasValue )"
46+
Class="custom-icons" />
47+
Custom CheckBox
48+
</label>
3449
35-
>caption How to change the checkbox icon
36-
37-
````CSHTML
38-
<TelerikCheckBox Value="true" Class="k-icon heart-icon" />
39-
<TelerikCheckBox Value="false" Class="k-icon heart-icon" />
40-
<TelerikCheckBox Value="false" Indeterminate="true" Class="k-icon heart-icon" />
50+
<TelerikButton OnClick="@( () => CheckBoxValue = null )">Make Indeterminate</TelerikButton>
51+
</p>
4152
4253
<style>
43-
/* remove some built-in styles */
44-
.heart-icon.k-checkbox,
45-
.heart-icon.k-checkbox:focus,
46-
.heart-icon.k-checkbox:checked,
47-
.heart-icon.k-checkbox:checked:focus {
48-
border: none;
49-
background: none;
50-
box-shadow: none;
54+
/* Set the Font Awesome family and weight for custom checkbox icons */
55+
.custom-icons.k-checkbox:before {
56+
font-family: "Font Awesome 6 Free";
57+
font-weight: 900;
5158
}
5259
53-
.heart-icon.k-checkbox::before,
54-
.heart-icon.k-checkbox:checked::before,
55-
.heart-icon.k-checkbox:indeterminate::before {
56-
transform: none;
57-
top: 0;
58-
left: 0;
59-
width: auto;
60-
height: auto;
61-
font-size: 30px; /* used for dimensions, see the next section */
62-
}
63-
64-
/* set desired dimensions */
65-
.heart-icon.k-checkbox {
66-
width: 30px;
67-
height: 30px;
60+
/* Remove the default background image for checked state */
61+
.custom-icons.k-checkbox:checked {
62+
background-image: none;
6863
}
6964
70-
/* change the font icon glyph to a different one - in this case - a heart icon from the Telerik font
71-
we also change the colors here to denote states, you can alter this further - like using your own fonts or colors
72-
*/
73-
.heart-icon.k-checkbox:checked::before {
74-
content: "\e301";
75-
color: #ff6358;
65+
/* Set the Font Awesome check mark icon for the checked state */
66+
.custom-icons.k-checkbox:checked:before {
67+
content: "\f058"; /* Check Circle icon */
7668
}
7769
78-
.heart-icon.k-checkbox:indeterminate::before {
79-
content: "\e300";
80-
color: #ff6358;
81-
background: none;
82-
}
70+
/* Remove the default background image for indeterminate state */
71+
.custom-icons.k-checkbox:indeterminate {
72+
background-image: none;
73+
}
8374
84-
.heart-icon.k-checkbox::before {
85-
content: "\e300";
86-
color: #656565;
75+
/* Set the Font Awesome question icon for the indeterminate state */
76+
.custom-icons.k-checkbox:indeterminate:before {
77+
content: "\3f"; /* Question icon */
78+
margin-left: 3px;
8779
}
8880
</style>
81+
82+
@code {
83+
private bool? CheckBoxValue { get; set; }
84+
}
8985
````
9086

87+
## See Also
88+
* [Built-in Font and SVG Icons]({%slug common-features-icons%})
89+
* [Checkbox Indeterminate State]({%slug checkbox-indeterminate-state%})
90+

0 commit comments

Comments
 (0)