LayoutSwitcher
LayoutSwitcher renders a pair of buttons that allows the user to change results layout between list and grid.
It is normally used in combination with ResultMultiLayout, which wraps ResultsList and ResultsGrid.
The component is not displayed while executing the search query, if the current layout is not set or if there are no results.
Usage
<LayoutSwitcher defaultLayout="list" />
Props
defaultLayout
StringoptionalThe default layout, one of
listorgrid. Default value:list.overridableId
StringoptionalAn optional string to define a specific overridable id.
Usage when overriding
const MyLayoutSwitcher = ({ currentLayout, onLayoutChange }) => {
...
}
const overriddenComponents = {
"LayoutSwitcher.element": MyLayoutSwitcher
};
Parameters
currentLayout
StringThe current value of the
layoutquerystate.onLayoutChange
functionThe function to call when the user wants to change the current layout to change the
querystate.onLayoutChange(newValue)