Back to Woocommerce

README

packages/js/components/src/segmented-selection/README.md

10.8.0-dev1.2 KB
Original Source

SegmentedSelection

Create a panel of styled selectable options rendering stylized checkboxes and labels

Usage

jsx
<SegmentedSelection
	options={ [
		{ value: 'one', label: 'One' },
		{ value: 'two', label: 'Two' },
		{ value: 'three', label: 'Three' },
		{ value: 'four', label: 'Four' },
	] }
	selected={ selected }
	legend="Select a number"
	onSelect={ ( data ) => setState( { selected: data[ name ] } ) }
	name={ name }
/>

Props

NameTypeDefaultDescription
classNameStringnullAdditional CSS classes
optionsArraynull(required) An Array of options to render. The array needs to be composed of objects with properties label and value
selectedStringnullValue of selected item
onSelectFunctionnull(required) Callback to be executed after selection
nameStringnull(required) This will be the key in the key and value arguments supplied to onSelect
legendStringnull(required) Create a legend visible to screen readers

options structure

The options array needs to be composed of objects with properties:

  • value: String - Input value for this option.
  • label: String - Label for this option.