Checkbox

The Checkbox control provides your component a boolean value that is editable in the Makeswift builder.

AnchorExamples

AnchorA simple toggle switch

In this example we register a simple Switch component with an on prop controlled by a Checkbox control.

Switch checkbox panel

import { ReactRuntime } from '@makeswift/runtime/react'
import { Checkbox } from '@makeswift/runtime/controls'

function Switch({ on }) {
  return <p>{on ? 'On' : 'Off'}</p>
}

ReactRuntime.registerComponent(Switch, {
  type: 'switch',
  label: 'Switch',
  props: {
    on: Checkbox({ label: 'On?', defaultValue: true }),
  },
})

AnchorAPI

AnchorParameters

ParameterTypeRequiredDefaultDescription
labelstringno'Label'Text for the panel label.
defaultValuebooleannoundefinedWill be used when the value isn't set.

AnchorProvided value

The Checkbox control provides a boolean value to your component—or undefined if there's no value set. Use defaultValue if you never want your component to receive undefined.