woocommerce/plugins/woocommerce-blocks/assets/js/editor-components/toggle-button-control
Seghir Nadir 94d8d580a2 Fix isDefault on Buttons and switch Toolbar with ToolbarGroup (https://github.com/woocommerce/woocommerce-blocks/pull/3577)
* Fix isDefault notice

* fix Toolbar to ToolbarGroup
2020-12-21 17:03:54 +01:00
..
README.md Rename js/components to js/editor-components (https://github.com/woocommerce/woocommerce-blocks/pull/3069) 2020-09-02 10:21:46 +02:00
index.js Fix isDefault on Buttons and switch Toolbar with ToolbarGroup (https://github.com/woocommerce/woocommerce-blocks/pull/3577) 2020-12-21 17:03:54 +01:00
screenshot.png Rename js/components to js/editor-components (https://github.com/woocommerce/woocommerce-blocks/pull/3069) 2020-09-02 10:21:46 +02:00
style.scss Rename js/components to js/editor-components (https://github.com/woocommerce/woocommerce-blocks/pull/3069) 2020-09-02 10:21:46 +02:00

README.md

ToggleButtonControl

ToggleButtonControl is used to generate a series of toggle buttons where only one selection is possible. It uses a ButtonGroup component to output each toggle button.

A toggle button control

Usage

Render a user interface to select multiple users from a list.

  <ToggleButtonControl
    label={ __( 'Display style', 'woo-gutenberg-products-block' ) }
    value={ isDropdown ? 'dropdown' : 'list' }
    help="This is some helper text that shows below the controls."
    options={ [
      { label: __( 'List', 'woo-gutenberg-products-block' ), value: 'list' },
      { label: __( 'Dropdown', 'woo-gutenberg-products-block' ), value: 'dropdown' },
    ] }
    onChange={ ( value ) => setAttributes( { isDropdown: 'dropdown' === value } ) }
  />
) );

Props

The component accepts the following props:

label

If this property is added, a label will be generated using label property as the content.

  • Type: String
  • Required: No

help

If this property is added, a help text will be generated using help property as the content.

  • Type: String|WPElement
  • Required: No

value

If value is passed, one of the options will have pressed state. If no value is passed no button will have pressed state.

  • Type: String
  • Required: No

onChange

A function that receives the selected value (string) as input.

  • Type: function
  • Required: Yes

className

The class that will be added with components-base-control and components-toggle-button-control to the classes of the wrapper div. If no className is passed only components-base-control and components-toggle-button-control are used.

Type: String Required: No

options

An array of objects containing the following properties:

  • label: (string) The label to be shown to the user.
  • value: (Object) The internal value used to choose the selected value. This is also the value passed to onChange when the option is selected.

Type: Array Required: No