- Primitive UI components
CardViewSwitcher
Primitive UI components in Search UI Components package, are headless, building blocks used to create the headless widget templates for React applications. You can use them to scaffold your custom widgets.
This topic describes the anatomy, API reference, and variations of the CardViewSwitcher primitive component.
Anatomy
For a complete implementation, put together parts of the UI component as shown in the following code block.
Using the component
The following tabs describe use of the CardViewSwitcher primitive component.
Plain component
In your React application, paste the following code block then modify the primitives to match your needs.

Styled component with default list
In your React application, paste the following code block then modify the primitives to match your needs.

Styled component with text
In your React application, paste the following code block then modify the primitives to match your needs.

API reference
This section describes the component or component parts displayed in the anatomy structure. For every component, you will find:
- Components to which you can add it as a child.
- Components you can add as its child.
- Details of any properties you can set.
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.tsx<br>(value) => { //do something }<br> | |
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. |