Checkbox

May 31, 2019 ยท View on GitHub

Form control to select one or more options from a set. Generates a styled checkbox input element.

Main features

  • Custom icons
  • Customize button behaviour
  • Set size
  • Set the active state based on the checked state
  • Keyboard control
  • RTL (right-to-left) support

Usage

Keyboard control

Press TAB to navigate to a button - it will show a highlight. Press ENTER to execute the equivalent of a click.

Options

Checkbox specific

ParameterRequiredTypeDefaultDescription
checkedoptionalBooleanfalseManaged checked state (see: Handling state)
defaultCheckedoptionalBooleanfalseInitially checked state; ignored if value is used
disabledoptionalBooleanSet to true to disable the Checkbox
iconButtonoptionalOptions object for the Icon ButtonAdd attributes like wash and ink
iconOffoptionalOptions object for IconAssigns a different icon for the off state
iconOnoptionalOptions object for IconAssigns a different icon for the on state
labeloptionalStringText label
nameoptionalStringInput element name
onChangeoptionalFunction ({ event: Event, checked: boolean, value: string }) => undefinedSee: Handling state
selectableoptionalFunction (selected: boolean) => booleanSets the active state based on the checkbox state; receives the current selected state, return the selectable state
sizeoptionalString"regular"Equivalent to Icon's type option; either "small" (16px), "regular" (24px), "medium" (32px), "large" (40px)
valueoptionalStringInput element value

Common component options

ParameterRequiredTypeDefaultDescription
afteroptionalString, hyperscript or componentExtra content after main content; note that this content is placed right of preceding elements with a higher stacking depth
beforeoptionalString, hyperscript or componentExtra content before main content; note that this content is placed left of subsequent elements with a lower stacking depth
classNameoptionalStringExtra CSS class appended to pe-checkbox-control
elementoptionalString"div"HTML element tag for the checkbox container
eventsoptionalObjectOptions object containing one or more standard events such as onclick (React: onClick)
idoptionalStringHTML element id for the checkbox container
tabindex (React: tabIndex)optionalIntegerTab index
toneoptionalString: "dark" or "light"Renders the component light on dark (sets class pe-dark-tone); use "light" to locally inverse (sets class pe-light-tone)

Composition

Checkbox is composed from:

CSS classes