Enter
Selection

ViewToggle

Cycles through layout modes. The icon's bars slide and resize into their new arrangement instead of cross-fading.

Icon only
Disabled

Usage

<ViewToggle
  size="md"
  spring="smooth"
/>

How the motion works

Every mode describes the same four rectangles as [x, y, width, height, opacity]. Rectangles a mode doesn't use are not removed — they are parked on top of a neighbour at zero opacity. Keeping array length and ordering identical across modes is what allows a plain numeric spring to morph between them; a mode with fewer bars would have nothing to interpolate against.

useMorphSwapLabelusePress

Props

PropTypeDefaultDescription
value / defaultValue"grid" | "column" | "list"Controlled or initial mode.
onChange(value: ViewMode) => voidFires when the mode cycles.
modesViewMode[]all threeWhich modes to cycle through, in order.
labelsPartial<Record<ViewMode, string>>Override the text per mode.
iconOnlybooleanfalseHide the label.