Skip to content

Commit 82d9cee

Browse files
Further explanations to Indeterminate state in CheckBox (#65)
* chore(docs): Updates on Indeterminate article * docs(checkbox): clarify indeterminate state behavior and purpose Co-authored-by: Marin Bratanov <[email protected]>
1 parent d2356a8 commit 82d9cee

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

components/checkbox/indeterminate-state.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,34 @@ To put the checkbox in the indeterminate state, set its `Indeterminate` paramete
1717

1818
The `Indeterminate` parameter maps to the `indeterminate` attribute of the standard HTML `<input type="checkbox" />`.
1919

20-
Every time the Checkbox state is changed (checked or unchecked) the `Indeterminate` parameter is set to `false`.
20+
The Indeterminate state is something that the application logic should set to show information to the user. A user interaction with the component will clear that state and will set a `true` or `false` value to it and the `Indeterminate` parameter will be set to `false`..
2121

22+
For example, if you bind the checkbox to a nullable field and its value is `null`, you may want to show the checkbox as indeterminate.
23+
24+
>caption Basic setup - show Indeterminate checkbox when its Value is not defined (null)
25+
26+
````CSHTML
27+
@*
28+
This example shows how to make a checkbox indeterminate when its Value is unknown (e.g., null)
29+
It also shows that when the user changes the state of the CheckBox, the Indeterminate status is set to false
30+
*@
31+
32+
Indeterminate: @( !TheValue.HasValue )
33+
<br />
34+
35+
Checked: @TheValue
36+
<br />
37+
38+
<TelerikButton Primary="true" OnClick="@( _ => TheValue = null )">Make indeterminate</TelerikButton>
39+
<br />
40+
41+
<TelerikCheckBox Id="DemoCheckbox" @bind-Value="@TheValue" Indeterminate="@( !TheValue.HasValue )" />
42+
<label for="DemoCheckbox">Checkbox</label>
43+
44+
@code{
45+
bool? TheValue { get; set; } // defaults to null so the checkbox will be indeterminate initially
46+
}
47+
````
2248

2349
>caption Observe the behavior of the Indeterminate state
2450

0 commit comments

Comments
 (0)