woocommerce/packages/js/components/src/segmented-selection
Chi-Hsuan Huang 7068c78101
Fix JS lint errors (#33484)
* Fix @woocommerce/data lint errors

* Fix internal-e2e-builds lint error

* Fix lint errors
2022-06-21 16:37:34 +08:00
..
stories Moved WCA Packages 2022-03-18 14:25:26 -07:00
README.md Moved WCA Packages 2022-03-18 14:25:26 -07:00
index.js Fix JS lint errors (#33484) 2022-06-21 16:37:34 +08:00
style.scss Moved WCA Packages 2022-03-18 14:25:26 -07:00

README.md

SegmentedSelection

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

Usage

<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

Name Type Default Description
className String null Additional CSS classes
options Array null (required) An Array of options to render. The array needs to be composed of objects with properties label and value
selected String null Value of selected item
onSelect Function null (required) Callback to be executed after selection
name String null (required) This will be the key in the key and value arguments supplied to onSelect
legend String null (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.