Type Property 型プロパティ

checkbox

A toggle style that displays a checkbox followed by its label. あるトグルスタイル、それはチェックボックスに続けてそれのラベルを表示します。

Declaration 宣言

static var checkbox: CheckboxToggleStyle { get }
Available when Self is CheckboxToggleStyle.

Discussion 議論

Apply this style to a Toggle or to a view hierarchy that contains toggles using the toggleStyle(_:) modifier:


Toggle("Close windows when quitting an app", isOn: $doesClose)
    .toggleStyle(.checkbox)

The style produces a label that describes the purpose of the toggle and a checkbox that shows the toggle’s state. To change the toggle’s state, the user clicks the checkbox or its label:

A screenshot of a box with a checkmark in it, appearing to the left

The style aligns the trailing edge of the checkbox with the leading edge of the label, and takes as much horizontal space as it needs to fit the label, up to the amount offered by the toggle’s parent view.

This is the default style in macOS in most contexts when you don’t set a style, or when you apply the automatic style. A Form is a convenient way to present a collection of checkboxes with proper spacing and alignment. For guidance on using checkboxes in your user interface, see Checkboxes in the Human Interface Guidelines.