Design gestalt figure ground

From Intense-Visions/harness-engineering · View interactive version

Design gestalt figure ground is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Depth perception — distinguishing foreground from background, ambiguous figure-ground as a design tool, z-axis ordering, overlay and modal perception

How to use this skill

Skill file

Gestalt Figure-Ground

Depth perception — distinguishing foreground from background, ambiguous figure-ground as a design tool, z-axis ordering, overlay and modal perception

When to Use

Instructions

  1. Understand the law. The Gestalt principle of figure-ground states that the brain automatically separates visual input into a foreground figure (the object of attention) and a background ground (the surrounding context). This separation is not optional — the brain performs it on every visual scene. Design exploits this by controlling which elements read as "figure" (foreground, interactive, primary) and which read as "ground" (background, contextual, secondary).

The five cues that establish figure-ground:

  1. Create depth through elevation and shadow. The primary mechanism for establishing figure-ground in digital interfaces is the shadow. A shadow beneath an element signals "this element is lifted above the surface, closer to the viewer."

Worked example — Material Design's elevation system:

Material Design codifies figure-ground as literal elevation measured in dp (density-independent pixels):

Each level creates a stronger figure-ground separation. The user intuitively understands: higher shadow = closer to me = more important right now.

Decision procedure: Assign each UI surface to one elevation level. Interactive overlays (menus, popovers, modals) must always be at a higher elevation than the content they overlay. Never place two overlapping surfaces at the same elevation — this creates ambiguous figure-ground.

  1. Use scrim/overlay to reinforce modal figure-ground. When a modal or dialog appears, the content behind it must be visually demoted to "ground." The scrim (semi-transparent overlay) accomplishes this by reducing the contrast, color saturation, and clarity of the background content.

Worked example — Stripe's modal pattern:

Worked example — Apple's iOS sheet presentation:

  1. Apply figure-ground to card design. Cards are the most common figure-ground pattern in web design. A card is a figure that lifts off the page ground.

Worked example — Stripe's pricing cards:

Decision procedure for card backgrounds:

  1. Handle figure-ground in dark mode. Dark mode inverts the typical figure-ground relationship. In light mode, shadows push elements upward. In dark mode, shadows are invisible against dark backgrounds. Material Design solves this by using surface lightness as the elevation signal:

Material Design dark mode elevation:

Higher = lighter. The brain interprets lighter surfaces as closer (figure) and darker surfaces as farther (ground). This maintains the figure-ground hierarchy without any shadows.

  1. Exploit ambiguous figure-ground deliberately. In rare cases, ambiguous figure-ground creates visual interest. The classic example is Rubin's vase — the same image can be seen as a vase (figure) or two faces (ground), depending on the viewer's focus.

Worked example — negative space logos:

When to use ambiguity in interfaces: Almost never. Interface design demands unambiguous figure-ground so users know what is interactive (figure) and what is context (ground). Ambiguity belongs in branding and illustration, not in functional UI.

Details

Z-Index Strategy

Figure-ground in CSS is managed through z-index, and mismanaged z-index is the most common implementation failure of figure-ground design.

Define a z-index scale (not arbitrary values):

| Level | z-index | Usage |

| -------- | ------- | --------------------------------- |

| Base | 0 | Page content, ground |

| Raised | 10 | Cards, sticky headers |

| Dropdown | 100 | Dropdowns, popovers, tooltips |

| Overlay | 200 | Scrims, sidebar overlays |

| Modal | 300 | Modals, dialogs |

| Toast | 400 | Toast notifications, snackbars |

| Maximum | 500 | Development tools, debug overlays |

Never use z-index values like 9999, 99999, or 2147483647. These indicate a z-index arms race where developers are fighting stacking context conflicts by escalating values. The fix is a defined scale — every surface has one correct level.

Stacking context isolation: Use isolation: isolate on component root elements to create new stacking contexts. This prevents a z-index inside one component from competing with z-index in another component. A z-index: 100 inside an isolated component cannot escape to compete with a z-index: 50 in the global context.

Figure-Ground in Data Tables

Tables present a figure-ground challenge: which rows are figure and which are ground?

Layered Figure-Ground (Nested Depth)

Complex interfaces have multiple figure-ground layers:

  1. Page background (deepest ground)
  2. Content cards (figure relative to page, ground relative to popovers)
  3. Popover menus (figure relative to cards)
  4. Modal dialogs (figure relative to everything)
  5. Toast notifications (figure relative to modals — the only thing above modals)

Each layer must maintain unambiguous separation from adjacent layers. If a popover and a card have the same shadow depth, the popover does not feel "above" the card — its figure-ground status is ambiguous.

Anti-Patterns

  1. Flat modals (no scrim, no shadow). A modal that appears as a white box on a white page with no scrim or elevation. The brain cannot determine that this is figure — it reads as "another card appeared" rather than "an overlay is demanding my attention." Fix: always use a scrim (rgba backdrop) plus a shadow that exceeds any other shadow on the page. The modal must be at the highest elevation in the system.
  1. Shadow inflation. Every element has a drop shadow — cards, buttons, inputs, headers, footers. When everything casts a shadow, nothing lifts off the ground. Shadow becomes noise rather than signal. Fix: reserve shadows for true figure-ground separation (cards on a page, menus over content, modals over everything). Flat elements (buttons, inputs, text) should not have shadows in their default state. Stripe uses shadows on exactly two things: cards and modals.
  1. Z-index escalation. Starting with z-index: 1 for a dropdown, then needing z-index: 10 for a modal, then z-index: 9999 for a toast because a third-party widget injected z-index: 1000. Fix: define a z-index scale as a design token. Use stacking context isolation. Audit third-party widgets for rogue z-index values.
  1. Identical elevation on overlapping surfaces. Two overlapping cards with the same shadow — which is on top? The brain cannot resolve this. Fix: any surface that overlaps another must be at a visibly different elevation. If two cards can overlap (e.g., in a draggable UI), the dragged card must gain elevation (increase shadow) to signal "I am above."

Real-World Examples

Stripe's Blue-Tinted Shadows:

Material Design Elevation System:

Apple's Sheet Presentation:

Vercel's Minimal Elevation:

Source

Process

  1. Read the instructions and examples in this document.
  2. Apply the patterns to your implementation, adapting to your specific context.
  3. Verify your implementation against the details and edge cases listed above.

Harness Integration

Success Criteria

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.