19.2.0 • Published 3 days ago

@commercetools-uikit/view-switcher v19.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

ViewSwitcher

Description

ViewSwitchers allow users to toggle between two or more different views of the same, similar or related content items within the same space on screen.

When to use

ViewSwitchers are frequently used to let users toggle between different formatting's, like with a grid view and a table view.

When not to use

Do not use the ViewSwitcher as Tabs Tabs should be used when the content on the page is divided into related sections but without any overlap. See tabs as separate of content.

Do not use the ViewSwitcher as Toggle Toggles are used for “yes/no” or “on/off” binary decisions.

Do's and Don'ts“

  • If you use an icon within the ViewSwitcher, each switch needs to have an icon.
  • No colored icons are allowed. Only color-solid (black)
  • Do not use two lines of text in one switch field.

Installation

yarn add @commercetools-uikit/view-switcher
npm --save install @commercetools-uikit/view-switcher

Additionally install the peer dependencies (if not present)

yarn add react
npm --save install react

Usage

import ViewSwitcher from '@commercetools-uikit/view-switcher';

const Example = () => (
  <ViewSwitcher.Group
    defaultSelected="Button 2"
    onChange={(value) => console.log(value)}
  >
    <ViewSwitcher.Button isDisabled value="button 1">
      View 1
    </ViewSwitcher.Button>
    <ViewSwitcher.Button value="button 2">View 2</ViewSwitcher.Button>
    <ViewSwitcher.Button value="button 3">View 3</ViewSwitcher.Button>
  </ViewSwitcher.Group>
);

export default Example;

Properties

ViewSwitcher.Group

PropsTypeRequiredDefaultDescription
isCondensedbooleanIndicates that the view switcher can be reduced to save space
childrenReactNodePass one or more ViewSwitcher.Button components
onChangeFunctionSee signature.Will be triggered whenever a ViewSwitcher.Button is clicked. Called with the ViewSwitcherButton value
defaultSelectedstringIndicates the default selected button

Signatures

Signature onChange

(value: string) => void

ViewSwitcher.Button

PropsTypeRequiredDefaultDescription
isDisabledbooleanIf true, indicates that the button is in a disabled state.
childrenReactNodeIndicates the label of the ViewSwitcher.Button.
onClickFunctionSee signature.Will be triggered whenever a button is clicked.
valuestringThe value identifying this ViewSwitcher.Button.

Signatures

Signature onClick

(value: string) => void

Invariants

  1. The ViewSwitcher.Group must have at least one ViewSwitcher.Button element as children
19.2.0

8 days ago

19.1.0

19 days ago

19.0.0

2 months ago

18.5.0

2 months ago

18.4.0

2 months ago

18.3.0

2 months ago

18.2.0

3 months ago

18.1.0

3 months ago

18.0.0

3 months ago

17.1.0

3 months ago

17.0.1

3 months ago

17.0.0

4 months ago

16.12.1

5 months ago

16.12.0

5 months ago

16.5.0

10 months ago

16.6.1

9 months ago

16.6.0

9 months ago

16.4.1

10 months ago

16.9.0

6 months ago

16.11.0

6 months ago

16.10.0

6 months ago

16.7.3

8 months ago

16.7.2

8 months ago

16.7.1

8 months ago

16.7.0

9 months ago

16.7.5

8 months ago

16.7.4

8 months ago

16.8.0

6 months ago

16.4.0

10 months ago

16.3.0

11 months ago

16.2.1

11 months ago

16.2.0

11 months ago

16.1.1

12 months ago

16.1.0

12 months ago

15.15.0

1 year ago

15.15.1

1 year ago

16.0.0

1 year ago

15.13.2

1 year ago

15.14.3

1 year ago

15.14.1

1 year ago

15.14.2

1 year ago

15.14.0

1 year ago

15.13.1

1 year ago

15.13.0

1 year ago

15.12.0

1 year ago

15.10.0

1 year ago

15.9.0

1 year ago

15.11.2

1 year ago

15.11.0

1 year ago

15.11.1

1 year ago

15.7.0

1 year ago

15.4.0

1 year ago

15.8.0

1 year ago

15.5.0

1 year ago

15.5.1

1 year ago

15.6.0

1 year ago

15.3.0

2 years ago

15.2.4

2 years ago

15.2.1

2 years ago

15.2.2

2 years ago

15.2.3

2 years ago

15.2.0

2 years ago

15.1.2

2 years ago

15.1.1

2 years ago

15.1.0

2 years ago