SegmentedSwitch

SegmentedSwitch

import SegmentedSwitch from "@kiwicom/orbit-components/lib/SegmentedSwitch";

Usage

const Component = () => {
const [value, setValue] = React.useState("");
return (
<SegmentedSwitch
onChange={ev => setValue(ev.currentTarget.value)}
help={helpMessage}
error={errorMessage}
options={[
{ label: "First option", value: "1" },
{ label: "Second option", value: "2" },
]}
/>
);
};

Props

NameTypeDefaultDescription
dataTeststringOptional prop for testing purposes.
helpReact.NodeOptional help message.
errorReact.NodeOptional error message.
optionsOption[]Array of options.
onChange(ev: ChangeEvent<HTMLInputElement>) => voidFunction for handling change event.
onFocus(ev: FocusEvent<HTMLInputElement>) => voidFunction for handling focus event.
labelReact.NodeLabel of the component.
showTooltipbooleanfalseShow tooltip.

Option

NameTypeDescription
valuestring \| numberThe value of the Option.
labelstringThe label for the Option.
defaultCheckedbooleanSet option checked by default.
disabledbooleanIf true, the Option will be disabled.
namestringName of the Option.

Functional specs

  • The error prop overwrites the help prop, due to higher priority.