Skip to main content

Component | Checkbox

info

Introduced in v0.22.0 of the SDK.

Render a checkbox.

ui.checkbox("checkbox-key", { 
label: "I agree that Compose is the best thing since sliced bread",
onChange: (value) => console.log(value)
})

Learn more about working with inputs.

API reference

Function signature

ui.checkbox(
id: string,
properties?: Partial<{
label: string,
description: string,
initialValue: boolean, // Default: false
validate: (value: boolean) => string | void,
onChange: (value: boolean) => void,
style: Style | null
}>
)

Parameters

id

required string
A unique identifier for the component. This is necessary so that Compose can properly pass user actions back to the component.

properties.label

optional string

The label to display beside the checkbox. If not provided, the label will be inferred from the id.


properties.description

optional string

A description to display below the checkbox.


properties.initialValue

optional boolean

The initial value of the checkbox. Defaults to false (unchecked).


properties.validate

optional (value: boolean) => string | void
Validate the checkbox value before submitting it. If the function returns a string, it will be displayed as an error message.

properties.onChange

optional (value: boolean) => void
A callback function that is called when the user changes the value of the checkbox.

properties.style

optional Style

Directly style the underlying element using CSS. See the styling guide for more details on available style properties.