GitHub

Reference headless

checkbox

interface 3 type 5 function 1
interface Interfaces 3
interface

# CheckboxContext

Members

toggles
toggles: number

Number of user-initiated toggles since construction.

value
value: CheckboxValue

Mirrored as aria-checked ("true" / "false" / "mixed").

# CheckboxController

Members

checked
readonly checked: boolean
context
readonly context: Readonly<CheckboxContext>
disabled
readonly disabled: boolean
id
readonly id: string
indeterminate
readonly indeterminate: boolean
machine
readonly machine: CheckboxMachine
root
readonly root: Attachment
state
readonly state: CheckboxState
value
readonly value: CheckboxValue
set()
set(value): void

###### Parameters

###### value

CheckboxValue

###### Returns

void

setDisabled()
setDisabled(disabled): void

###### Parameters

###### disabled

boolean

###### Returns

void

subscribe()
subscribe(listener): () => void

###### Parameters

###### listener

(snapshot) => void

###### Returns

() => void

toggle()
toggle(): void

###### Returns

void

# CreateCheckboxOptions

Members

disabled?
optional disabled?: boolean

###### Inherited from

CreateCheckboxInput.disabled

id?
optional id?: string
initial?
optional initial?: CheckboxValue

###### Inherited from

CreateCheckboxInput.initial

onCheckedChange?
optional onCheckedChange?: (value) => void

User-initiated value changes only. NOT called for controlled set() updates that came from the parent.

###### Parameters

###### value

CheckboxValue

###### Returns

void

type Type Aliases 5

# Attachment

Attachment = (node) => void | (() => void)

Parameters

node
HTMLElement

Returns

void | (() => void)
type

# CheckboxEvent

CheckboxEvent = { type: "TOGGLE"; } | { type: "SET"; value: CheckboxValue; } | { type: "DISABLE"; } | { type: "ENABLE"; }
type

# CheckboxState

CheckboxState = "unchecked" | "checked" | "mixed" | "disabled"
type

# CheckboxValue

CheckboxValue = "unchecked" | "checked" | "mixed"

The visible value. 'mixed' = indeterminate (parent w/ partly-checked children).

function Functions 1

# createCheckbox ( )

createCheckbox(options?): CheckboxController

Create a Checkbox controller plus its {@attach}-compatible root attachment.

Parameters

options?
CreateCheckboxOptions = {}

Returns

CheckboxController