CheckBox

@ui5/webcomponents
<ui5-checkbox>

Basic CheckBox

<ui5-checkbox text="Chocolate" checked></ui5-checkbox>
<ui5-checkbox text="Strawberry" checked></ui5-checkbox>
<ui5-checkbox text="Waffles" checked value-state="Error"></ui5-checkbox>
<ui5-checkbox text="Cake" checked value-state="Warning"></ui5-checkbox>
	

CheckBox states

<ui5-checkbox text="Error" value-state="Error"></ui5-checkbox>
<ui5-checkbox text="Warning" value-state="Warning"></ui5-checkbox>
<ui5-checkbox text="Disabled" disabled checked></ui5-checkbox>
<ui5-checkbox text="Readonly" readonly checked></ui5-checkbox>
<ui5-checkbox text="Error disabled" disabled value-state="Error" checked></ui5-checkbox>
<ui5-checkbox text="Warning disabled " disabled value-state="Warning" checked></ui5-checkbox>
<ui5-checkbox text="Error readonly" readonly value-state="Error" checked></ui5-checkbox>
<ui5-checkbox text="Warning readonly" readonly value-state="Warning" checked></ui5-checkbox>
	

CheckBox with Text Wrapping

<ui5-checkbox text="ui5-checkbox with 'wrap' set and some long text." wrap style="width:200px"></ui5-checkbox>
<ui5-checkbox text="Another ui5-checkbox with very long text here" wrap style="width:200px"></ui5-checkbox>
	

Overview

Allows the user to set a binary value, such as true/false or yes/no for an item.

The ui5-checkbox component consists of a box and a label that describes its purpose. If it's checked, an indicator is displayed inside the box. To check/uncheck the ui5-checkbox, the user has to click or tap the square box or its label.

The ui5-checkbox component only has 2 states - checked and unchecked. Clicking or tapping toggles the ui5-checkbox between checked and unchecked state.

Usage

You can manually set the width of the element containing the box and the label using the width property. If the text exceeds the available width, it is truncated. The touchable area for toggling the ui5-checkbox ends where the text ends.

You can disable the ui5-checkbox by setting the disabled property to true, or use the ui5-checkbox in read-only mode by setting the readonly property to true.

ES6 Module Import

import "@ui5/webcomponents/dist/CheckBox";

Properties/Attributes

You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.

Name
Type
Default Value
Description
checked
boolean
false
Defines if the ui5-checkbox is checked.

Note: The property can be changed with user interaction, either by cliking/tapping on the ui5-checkbox, or by pressing the Enter or Space key.
disabled
boolean
false
Defines whether the ui5-checkbox is disabled.

Note: A disabled ui5-checkbox is completely noninteractive.
name
string
""
Determines the name with which the ui5-checkbox will be submitted in an HTML form.

Important: For the name property to have effect, you must add the following import to your project: import "@ui5/webcomponents/dist/features/InputElementsFormSupport.js";

Note: When set, a native input HTML element will be created inside the ui5-checkbox so that it can be submitted as part of an HTML form. Do not use this property unless you need to submit a form.
readonly
boolean
false
Defines whether the ui5-checkbox is read-only.

Note: A red-only ui5-checkbox is not editable, but still provides visual feedback upon user interaction.
text
string
""
Defines the text of the ui5-checkbox.
valueState
value-state
ValueState
"None"
Defines the value state of the ui5-checkbox.

Note: Available options are Warning, Error, and None (default).
wrap
boolean
false
Defines whether the ui5-checkbox text wraps when there is not enough space.

Note: By default, the text truncates when there is not enough space.

Events

This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as addEventListener.

Name
Description
change
Fired when the ui5-checkbox checked state changes.
Theme: Quartz Light Quartz Dark Quartz High Contrast Black Quartz High Contrast White Belize High Contrast Black High Contrast White
Content Density: Cozy Compact
Text Direction: LTR RTL
Apply Cancel