Checkbox

@Composable
fun Checkbox(checked: Boolean, onCheckedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, variant: CssStyleVariant<CheckboxKind>? = null, enabled: Boolean = CheckboxDefaults.Enabled, icon: @Composable CheckboxIconScope.() -> Unit = CheckboxDefaults.IconProvider, size: CheckboxSize = CheckboxDefaults.Size, spacing: CSSLengthNumericValue? = null, colorPalette: ColorPalette? = null, borderColor: CSSColorValue? = null, uncheckedColor: CSSColorValue? = null, iconColor: CSSColorValue? = null, focusOutlineColor: CSSColorValue? = null, ref: ElementRefScope<HTMLElement>? = null, content: @Composable () -> Unit? = null)(source)

Creates a checkbox.

Parameters

checked

Whether the checkbox is currently checked or not.

onCheckedChange

A callback which is invoked when the checkbox is toggled.

enabled

Whether the checkbox is enabled or not. If not, the checkbox will be rendered in a disabled state and will not be interactable.

icon

The composable that renders the icon inside the checkbox. This will be passed a CheckboxIconScope which you can use to customize the icon based on potentially relevant context.

size

The size of the checkbox. Defaults to CheckboxSize.MD. You can implement your own CheckboxSize if you want custom sizing.

spacing

An optional spacing parameter to use between the checkbox and any content drawn to the right of it.

colorPalette

A color palette which, if present, controls the colors for this checkbox. If not provided, the checkbox will use the relevant colors from the silk theming Palette.

borderColor

An optional override for the border color of the checkbox when unchecked.

uncheckedColor

An optional override for the background color of the checkbox when unchecked.

iconColor

An optional override for the color of the icon drawn in the checkbox.

focusOutlineColor

An optional override for the border color when the input is focused.

content

Inline content attached to the checkbox. This will be treated as an HTML label, which means when clicked it will toggle the checkbox, and screen readers will read out any text in it when the checkbox is focused.

See also


@Composable
fun Checkbox(checked: Boolean, onCheckedChange: (Boolean) -> Unit, modifier: Modifier = Modifier, variant: CssStyleVariant<CheckboxKind>? = null, enabled: Boolean = CheckboxDefaults.Enabled, icon: @Composable CheckboxIconScope.() -> Unit = CheckboxDefaults.IconProvider, size: CheckboxSize = CheckboxDefaults.Size, spacing: CSSLengthNumericValue? = null, colorScheme: ColorScheme, borderColor: CSSColorValue? = null, uncheckedColor: CSSColorValue? = null, iconColor: CSSColorValue? = null, focusOutlineColor: CSSColorValue? = null, ref: ElementRefScope<HTMLElement>? = null, content: @Composable () -> Unit? = null)(source)

Deprecated

Rename the `colorScheme` parameter to `colorPalette`. `ColorScheme` is a legacy name that is going away.