# CheckBox

> *Note*: You can check the Avalonia docs for the [CheckBox](https://docs.avaloniaui.net/docs/controls/checkbox) and [CheckBox API](http://reference.avaloniaui.net/api/Avalonia.Controls/CheckBox/) if you need more information.
>
> For Avalonia.FuncUI's DSL properties you can check [CheckBox.fs](https://github.com/fsprojects/Avalonia.FuncUI/blob/master/src/Avalonia.FuncUI/DSL/Buttons/CheckBox.fs)

The checkbox is a control that allows a user to represent boolean values or the absense of a value

### Usage

**Set Label**

```fsharp
CheckBox.create [
  CheckBox.content "I Accept the terms and conditions."
]
```

**Set Is Checked**

```fsharp
CheckBox.create [
  // can be either true or false
  CheckBox.isChecked state.booleanValue
]
```

**Set Indeterminate**

```fsharp
CheckBox.create [
  // can be either true or false
  CheckBox.isThreeState state.indeterminate
  // this value is required to be either a nullable boolean
  // or a boolean option
  CheckBox.isChecked None
]
```

> To be able to set the indeterminate state, the `isThreeState` value must be true and the `isChecked` value must be None or Nullable boolean set to null

**Set Dynamic State Checkbox**

You can mix and match the three states of a checkbox. In this example if the count value is greater than 0 the box will be checked, if the value is 0 then it will be indeterminate, lastly if the value is less than 0 it will be unchecked

```fsharp
let isChecked =
  if state.count = 0 then
    None
  else if state.count > 0 then
    Some true
  else
    Some false

CheckBox.create [
  CheckBox.content "Dynamic CheckBox"
  // this is not required
  CheckBox.isEnabled false
  CheckBox.isThreeState (state.count = 0)
  CheckBox.isChecked isChecked
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://funcui.avaloniaui.net/controls/checkbox.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
