Checkbox

A component that can be selected by a user.

Preview

Button Preview

Code Example

let model = CheckboxVM {
  $0.title = "Checkbox"
  $0.color = .primary
  $0.cornerRadius = .full
  $0.size = .large
}

API

CheckboxVM Props

A model that defines the appearance properties for a checkbox component.

NameTypeDefaultDescription
titleString?nilThe label text displayed next to the checkbox.
colorComponentColoraccentThe color of the checkbox.
cornerRadiusComponentRadiusmediumThe corner radius of the checkbox.
fontUniversalFont?nilThe font used for the checkbox label text. If not provided, the font is automatically calculated based on the checkbox's size.
isEnabledBooltrueA Boolean value indicating whether the checkbox is enabled or disabled.
sizeComponentSizemediumThe predefined size of the checkbox.

SUCheckbox

public init(
  isSelected: Binding<Bool>,
  model: CheckboxVM = .init()
)

UKCheckbox

Initializers

public init(
  initialValue: Bool = false,
  model: CheckboxVM = .init(),
  onValueChange: @escaping (Bool) -> Void = { _ in }
)

Public Properties

NameTypeDescription
onValueChange(Bool) -> VoidA closure that is triggered when the checkbox is selected or unselected.
modelCheckboxVMA model that defines the appearance properties.
isSelectedBoolA Boolean value indicating whether the checkbox is selected.

Public Subviews

NameTypeDescription
titleLabelUILabelA label that displays the title from the model.
stackViewUIStackViewA stack view that contains a checkbox and a title label.
checkboxContainerUIViewA view that contains another view with a checkmark. Animates the checkbox border.
checkboxBackgroundUIViewA view that contains a checkmark. Animates the checkbox background.
checkmarkLayerCAShapeLayerA layer that draws a checkmark.