1. Search JS SDK for React

CardViewSwitcher

This topic describes the anatomy, API reference, and variations of the CardViewSwitcher primitive component.

Anatomy

import { CardViewSwitcher } from '@sitecore-search/ui';
const MyCardViewSwitcher = () => (
    <CardViewSwitcher.Root>
      <CardViewSwitcher.Item value="grid">
        Use icon or text as children
      </CardViewSwitcher.Item>
      <CardViewSwitcher.Item value="list">
        Use icon or text as children
      </CardViewSwitcher.Item>
    </CardViewSwitcher.Root>
);

Using the component

The following tabs describe use of the CardViewSwitcher primitive component.

API reference

CardViewSwitcher.Root

The CardViewSwitcher.Root component contains all the components of the card view switcher.

Children: CardViewSwitcher.Item

Name

Description

Default

onValueChange

Event handler called when any item is clicked.

(value) =&gt; { //do something }

defaultValue

String.

The controlled stateful value of the item that is pressed.

list or grid

grid

CardViewSwitcher.Item

The CardViewSwitcher.Item component is an item in the group.

Parent: CardViewSwitcher.Root

Name

Description

Default

value

String.

Card value type.

list or grid

grid

children

Content to be displayed.

If you have suggestions for improving this article, let us know!