Checkbox

Checkbox

import Checkbox from "@kiwicom/orbit-components/lib/Checkbox";
<Checkbox label="Checkbox" />

Props

NameTypeDefaultDescription
checkedbooleanIf true, the Checkbox will be checked.
defaultCheckedbooleanIf true, the Checkbox will be checked by default. Only to be used in uncontrolled.
disabledbooleanfalseIf true, the Checkbox will be set up as disabled.
dataTeststringOptional prop for testing purposes.
idstringSet id for Checkbox
hasErrorbooleanfalseIf true, the border of the Checkbox will turn red. See Functional specs
infoReact.NodeThe additional info about the Checkbox.
labelstringThe label of the Checkbox.
namestringThe name for the Checkbox.
onChangeevent => void \| PromiseFunction for handling onChange event.
reffuncProp for forwarded ref of the Checkbox. See Functional specs
tabIndexstring \| numberSpecifies the tab order of an element
tooltipElement<Tooltip>Optional property when you need to attach Tooltip to the Checkbox. See Functional specs
valuestringThe value of the Checkbox.

Functional specs

import * as React from "react";
class Component extends React.PureComponent<Props> {
componentDidMount() {
this.ref.current && this.ref.current.focus();
}
ref: { current: React.ElementRef<*> | null } = React.createRef();
render() {
return <Checkbox ref={this.ref} />;
}
}
  • The tooltip property is useful when you need to visually attach Tooltip component only to the Checkbox’s glyph, not the label or other parts of the Checkbox.