Skip to content

Checkbox Component

Checkbox Component

Checkbox component is used for multiple selection from a group of options. Users can change the selected state by clicking.

Basic Usage

Basic checkbox for selecting a single state.

Current Value: false
Show CodeArrow
CopyGitHub

Disabled State

Set the disabled attribute to disable the checkbox.

Show CodeArrow
CopyGitHub

Different Styles

Set the radius attribute to change the checkbox style, supporting default (circular) and square (square, default).

Default Square Style:
Round Style:
Show CodeArrow
CopyGitHub

Indeterminate State

Set the indeterminate attribute to set the checkbox to indeterminate state. Use the indeterminateIcon attribute to customize the indeterminate state icon.

Default Indeterminate Icon:
Custom Indeterminate Icon:
Practical Example:
Show CodeArrow
CopyGitHub

Custom Icon

Set the icon attribute to customize the checkbox icon.

Show CodeArrow
CopyGitHub

Different Sizes

Checkbox supports three sizes: small, default, and large.

Small: true | Default: true | Large: true
Show CodeArrow
CopyGitHub

Checkbox Group

Use the t-checkbox-group component to combine multiple checkboxes into a group, bind values through v-model.

Selected Fruits: apple, orange
Show CodeArrow
CopyGitHub

Checkbox Group Types

Checkbox group supports four types: default (default), text (text), border (border), and button (button).

Default Type:
Text Type:
Border Type:
Button Type:
Show CodeArrow
CopyGitHub

Arrangement Direction

Set the arrangement direction of checkbox group through the direction attribute, supporting row (horizontal) and column (vertical).

Horizontal Layout (Default):
Vertical Layout:
Show CodeArrow
CopyGitHub

Event Handling

Checkbox and checkbox group provide change events.

Single Checkbox Events

Event Log:

Checkbox Group Events

Event Log:
Show CodeArrow
CopyGitHub

Checkbox API

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
v-modelBinding valuestring / number / boolean / object
valueValue when selectedstring / number / boolean / objectfalse
sizeSizestringsmall / default / largedefault
radiusSelected shape stylestringdefault / squaresquare
objKeyBinding object type mark keystring
disabledWhether disabledbooleanfalse
nameNative name attributestring
iconCustom icon typestring
indeterminateWhether indeterminatebooleanfalse
indeterminateIconIndeterminate iconstringminus

Events

Event NameDescriptionParameters
changeTriggered when value changes(value: string / number / boolean / object)

Slots

Slot NameDescription
defaultCheckbox text content
checkboxSpanCustom checkbox icon

Checkbox Group API

Attributes

AttributeDescriptionTypeAccepted ValuesDefault
v-modelBinding valueArray
sizeSizestringsmall / default / largedefault
objKeyBinding object mark keystring
typeCheckbox group typestringdefault / text / border / buttonbutton
directionArrangement directionstringcolumn / rowrow
immediateChangeWhether immediately trigger change eventbooleanfalse

Events

Event NameDescriptionParameters
changeTriggered when value changes(value: Array)

Style Variables

The checkbox component uses the following style variables, which can be customized through SCSS variables:

Variable NameDescription
$theme-color-primaryTheme color - Primary
$border-color-defaultDefault border color
$text-color-defaultDefault text color
$bg-color-defaultDefault background color
$opacity-disabledDisabled state opacity
$font-size-smallSmall font size
$font-size-defaultDefault font size
$font-size-largeLarge font size
$color-whiteWhite color

Released under the MIT License