Skip to main content

Toggle View

A button that switches between two views, such as list and thumbnail. Use for immediate, reversible view toggles that do not require form submission. Don't use when the toggle controls a persistent system setting.

Figma Storybook Docs

Description

What it does

Lets users switch the display format of a content area between two mutually exclusive views — typically list and grid (thumbnail) — without navigating away or submitting a form.

Where it appears

In content listing pages such as stakeholder directories, document libraries, consultation response lists, and community project galleries where multiple display formats are meaningful.

Why it exists

Different users process information differently. Some prefer a compact list for scanning names or dates; others prefer a grid to compare images or cards at a glance. Toggle View gives users immediate control without changing application state or requiring a page reload.

Dependencies

Icon Button, Data Table, Card

Anatomy

PartRequired?Notes
Button group container Required Wraps both toggle buttons as a single logical control. Communicates grouping to assistive technologies via role='group' and an accessible label.
List view button Required Icon button representing the list/row layout. Carries the active state when list view is selected.
Grid view button Required Icon button representing the grid/thumbnail layout. Carries the active state when grid view is selected.
Button icon Required A recognisable icon (e.g. list-bullet, grid-2x2) that communicates the view type without relying on a visible label.
Visible label (optional) Optional Short text label ('List', 'Grid') displayed alongside the icon for additional clarity in low-density toolbars. Often hidden at small breakpoints.
Active indicator Required Visual treatment — filled or outlined background — that distinguishes the currently active view button from the inactive one.

Variants

Icon only

Compact pair of icon buttons with no visible text label

Use in dense toolbars or when space is constrained, such as alongside filter and sort controls on a listing page. Ensure each button has an aria-label.

Icon with label

Icon accompanied by a short visible text label

Use when users may be unfamiliar with the icon convention, or when the toolbar has sufficient horizontal space. Preferred for first-time or low-frequency government users.

States

State Behaviour
Default (inactive) The button appears at rest with a transparent or subtle background. Communicates that the view it represents is available but not currently active.
Active The button representing the current view is visually filled or highlighted using --op-color-interactive-default. aria-pressed='true' is set programmatically.
Hover (inactive) On pointer hover, the inactive button background shifts to --op-color-interactive-hover at reduced opacity, signalling interactivity.
Focus A 3px focus ring using --op-color-interactive-focus appears around the focused button. Both buttons in the group are individually focusable.
Disabled Both buttons are disabled when the content area is loading or unavailable. Opacity is reduced to 40%; pointer-events are removed. aria-disabled='true' is set; do not use the HTML disabled attribute on buttons inside a group if you need them to remain focusable for assistive technology.

Usage guidelines

When to use

  • A content listing page supports two meaningfully different display formats (e.g. a stakeholder directory shown as a compact table or a card grid).
  • The user's display preference is session-scoped — it resets on next visit without persisting to their profile.
  • The view switch is immediate and does not trigger a form submission or navigation event.
  • The listing contains enough items (more than six) that the choice of layout is practically useful.

When not to use

  • The toggle controls a persistent user preference stored in their profile — use a Settings page or a Switch component instead.
  • There are more than two view options — use a segmented control or select menu instead.
  • The content area contains only a few items where layout difference is negligible — remove the toggle to reduce noise.
  • The toggle changes application mode or navigates the user to a different route — use navigation tabs or a link instead.

Do / Don't

Do

Place the Toggle View control in the toolbar directly above the content area it affects, aligned to the trailing edge.

Don't

Place the control below the content, in a sidebar, or in a page header that is not visually connected to the listing.

Do

Persist the selection for the duration of the session so users are not surprised when they paginate or filter.

Don't

Reset the view to default on every filter or search interaction — this forces users to re-select their preferred layout repeatedly.

Do

Provide a meaningful aria-label on the group element, e.g. aria-label='View format'.

Don't

Leave the button group without an accessible name — screen reader users will not know what the buttons control.

Do

Use established iconography (list lines for list view, grid squares for grid view) that government users will recognise.

Don't

Use abstract or decorative icons that require a legend to interpret.

Was this page helpful?

Updated 9 September 2026