Equality
Equality

List or Grid View Toggle

List or Grid View Toggle with sizes and variants

Overview


The List or Grid View Toggle component is used to switch between list and grid view.

Please adjust the order using the order parameter so that the default viewMode is always on the left side.

Usage


Import the component:

import { ListOrGridViewToggle } from "@eqtylab/equality";

viewMode and onViewModeChange are required props and should be controlled by the parent component.

const [viewMode, setViewMode] = useState("grid");

<ListOrGridViewToggle viewMode={viewMode} onViewModeChange={setViewMode} />;

Examples


Default

Reordered

Reordering


Reorder the order of the buttons using the order prop. The default viewMode should always be placed on the left side.

<ListOrGridViewToggle
  viewMode={viewMode}
  onViewModeChange={setViewMode}
  order={["list", "grid"]}
/>

Props


PropTypeDefaultDescription
viewMode"grid" | "list"RequiredSets the active state.
onViewModeChange(mode: "grid" | "list") => voidRequiredFunction to call when the active state changes.
order["grid", "list"] | ["list", "grid"]["grid", "list"]Controls the order of the buttons.
classNamestring-Additional CSS classes to apply to the toggle.