Skip to main content

Layout Settings

Overview

The layout settings system provides two complementary components: LayoutSettings, a compact toolbar widget that exposes the ViewToggle for switching between list, grid, and masonry layouts; and LayoutSwitcher, a richer popover that lets users choose between home page layouts (Home 1 / Home 2) and toggle between fixed and fluid container widths. Both components read from and write to the shared LayoutThemeContext.

Architecture

template/components/
layout-settings.tsx # Compact view-toggle wrapper for item listings
layout-switcher.tsx # Full layout/container-width popover
view-toggle.tsx # Icon toggle bar (classic / grid / masonry / map)

LayoutSettings

Import

import { LayoutSettings } from "@/components/layout-settings";

Props

PropTypeRequiredDefaultDescription
classNamestringNoundefinedAdditional CSS classes for the outer wrapper div.
isParentStickybooleanNofalseWhen true, tooltips in the child ViewToggle flip below the button to avoid clipping under a sticky header.

Usage Examples

Basic Usage

<LayoutSettings />

Inside a Sticky Toolbar

<div className="sticky top-0 z-10">
<LayoutSettings isParentSticky />
</div>

LayoutSwitcher

Import

import { LayoutSwitcher } from "@/components/layout-switcher";

Props

PropTypeRequiredDefaultDescription
inlinebooleanNofalseWhen true, renders the layout cards directly without a popover wrapper. Useful for embedding in settings panels.
iconOnlybooleanNofalseWhen true, renders as a single icon button with a portal-based tooltip and dropdown. Ideal for compact header navigation.

Usage Examples

Default Popover Mode

<LayoutSwitcher />

Icon-Only Mode for Header

<LayoutSwitcher iconOnly />

Inline Mode for Settings Panel

<div className="settings-section">
<h3>Choose Layout</h3>
<LayoutSwitcher inline />
</div>

Layout Options

The switcher presents two home page layouts:

KeyNameDescription
Home_OneHome 1Classic layout with traditional listing design.
Home_TwoHome 2Modern grid-based layout with visual elements.

Each option shows a preview image that changes based on the current theme (light/dark).

Container Width Options

ValueLabelDescription
fixedFixed WidthContent constrained to a maximum container width.
fluidFull WidthContent stretches edge-to-edge across the viewport.

ViewToggle

Import

import ViewToggle from "@/components/view-toggle";

Props

PropTypeRequiredDefaultDescription
activeViewLayoutKeyNo"classic"Currently active view mode. One of "classic", "grid", or "masonry".
onViewChange(view: LayoutKey) => voidNoundefinedCallback fired when a view button is clicked.
isParentStickybooleanNofalseFlips tooltips below the buttons when inside a sticky container.
isMapAvailablebooleanNofalseShows an additional map view toggle button.
isMapActivebooleanNofalseWhether the map view is currently active.
onMapToggle() => voidNoundefinedCallback to toggle the map view on/off.

View Modes

ModeIconDescription
classicList iconTraditional vertical list of items.
gridGrid iconCard-based grid layout.
masonryMasonry iconPinterest-style masonry layout.
mapMap iconGeographic map view (conditionally shown).

Styling

  • ViewToggle: Rendered as a compact button group with bg-white/90 dark:bg-gray-800/90 backdrop-blur-xs and rounded pill styling. Active buttons use bg-theme-primary text-white shadow-md with a scale-105 transform.
  • LayoutSwitcher popover: 500px wide dropdown with backdrop-blur-xl, glassmorphic borders, and rounded-2xl. Layout cards have hover animations (hover:scale-[1.01]) and gradient overlays.
  • Container width toggle: Two full-width buttons using gradient backgrounds for the active state (from-theme-primary-500 to-theme-primary-600).
  • Tooltips: Portal-based fixed tooltips with z-[9999] to avoid stacking context issues.

Accessibility

  • All toggle buttons include aria-label attributes with translated view names (e.g., "Switch to list view").
  • Focus states use focus:ring-1 focus:ring-theme-primary for keyboard visibility.
  • The LayoutSwitcher trigger has aria-expanded and aria-controls linking to the popover panel via useId().
  • Escape key closes the popover.
  • Tooltips appear on both hover and focus for keyboard users.