Community project. This is not an official government website.

Run by volunteers. Lampung Design System is built by an open source community. No government agency runs or endorses it.

Official services use go.id. Government websites in Indonesia end in .go.id. Never enter your national ID number on a site you are unsure of.

View swap

View swap

One view replaces another in the same place: a tab panel, the next step of a form, a different range on a chart. The old view goes at once and the new one fades in from a 4 px blur and a 4 px rise in 240 ms. Quick enough to never feel like a page load; soft enough that the eye sees the change.

Usage

Use it when

  • A step-by-step form moves forward or back: the step content swaps under a fixed steps header and fixed buttons.
  • A tab or segmented control changes the content below it.
  • A card or panel switches what it shows (this week, this month) while its frame stays.

Use something else when

Where it goes. On the region that changes, below the control that changed it. The control, the header and the action buttons stay still; only the content swaps.

Examples

A step-by-step form, forward and backContinue and Back swap the step content; the steps header fills its bar on the in-out curve and the focus moves to the new heading. Nothing slides sideways, so going back feels the same as going forward.
  1. 1Program
  2. 2Documents
  3. 3Review

Choose a program

Undergraduate, Computer Science, starting in February.

<ol class="steps" aria-label="Application">…</ol>
<section class="step-view" aria-labelledby="step-title" style="animation: lds-blur-in var(--d-standard) var(--ease-enter);">
  <h3 id="step-title" tabindex="-1">Upload your documents</h3>
  …
</section>
<!-- Render the new step (or unhide it): the animation plays each time the element is shown.
     Then move focus to its heading. -->
Tab panelsThe ink slides; the panel below swaps with the blur-in. .tab-panel has the swap built in.
Measure the mass of each potato slice before and after two hours in salt water.
<div style="max-width: 460px;">
  <div class="tabs" role="tablist" aria-label="Lab report" data-lds-tabs>
    <span class="tabs__ink"></span>
    <button class="tabs__btn" role="tab" aria-selected="true" aria-controls="vs-1">Instructions</button>
    <button class="tabs__btn" role="tab" aria-selected="false" aria-controls="vs-2">Rubric</button>
    <button class="tabs__btn" role="tab" aria-selected="false" aria-controls="vs-3">Submissions <span class="tabs__count">28</span></button>
  </div>
  <div class="tab-panel" role="tabpanel" id="vs-1">Measure the mass of each potato slice before and after two hours in salt water.</div>
  <div class="tab-panel" role="tabpanel" id="vs-2" hidden>Method 30 %, results 40 %, discussion 30 %. Late work loses 5 % a day.</div>
  <div class="tab-panel" role="tabpanel" id="vs-3" hidden>28 of 32 students have submitted. 4 are still drafting.</div>
</div>
A card that changes its rangeThe segmented control switches the period; the figure and its label swap below while the card frame stays put.

6 h 40 m

Study time this week

<div class="card" style="width: 100%; max-width: 360px;">
  <div class="seg" role="group" aria-label="Period" data-lds-segmented onclick="const b = event.target.closest('.seg__btn'); if (!b) return; const i = [...this.querySelectorAll('.seg__btn')].indexOf(b); this.parentElement.querySelectorAll('[data-pane]').forEach((p, j) => { p.hidden = j !== i; });">
    <span class="seg__thumb"></span>
    <button class="seg__btn" aria-pressed="true">Week</button>
    <button class="seg__btn" aria-pressed="false">Month</button>
    <button class="seg__btn" aria-pressed="false">Term</button>
  </div>
  <div data-pane style="animation: lds-blur-in var(--d-standard) var(--ease-enter); margin-top: 16px;"><p class="chart-card__big">6 h 40 m</p><p class="card__sub">Study time this week</p></div>
  <div data-pane hidden style="animation: lds-blur-in var(--d-standard) var(--ease-enter); margin-top: 16px;"><p class="chart-card__big">27 h</p><p class="card__sub">Study time this month</p></div>
  <div data-pane hidden style="animation: lds-blur-in var(--d-standard) var(--ease-enter); margin-top: 16px;"><p class="chart-card__big">94 h</p><p class="card__sub">Study time this term</p></div>
</div>

Motion and microinteractions

  • Swap: the old view is hidden at once; the new one plays lds-blur-in (4 px rise, 4 px blur, opacity 0 to 1) over --d-standard (240 ms) on --ease-enter. .tab-panel has it built in.
  • Direction: none. Forward and back look the same. The steps header carries the direction: its bar fills over --d-considered (480 ms) on --ease-inout and the dot turns into a check.
  • Keep the frame still: the container, the header and the buttons never animate; if the new view is taller, the frame just grows.
  • Interruption: a second press during the 240 ms swaps again immediately; the newest view starts its own fade. Nobody waits for the previous one.
  • Reduced motion: the fade runs in 1 ms, so views switch instantly; the steps bar fills in 120 ms.

Accessibility

  • Move focus to the heading of the new step (tabindex="-1") so screen readers announce where they are.
  • Hidden views are hidden, not just transparent, so they leave the tab order and the accessibility tree.
  • Tabs keep aria-selected and aria-controls; steps keep aria-current="step" on the current one.

Do and don't

Do

  • Keep controls and frame still and swap only the content.
  • Show direction in the steps header, not with sideways slides.
  • Focus the new heading after a step change.

Don't

  • Slide whole views left and right, or cross-fade both views at once on top of each other.
  • Animate the height of the frame on every swap.
  • Make Continue wait for the animation.

Behavior and code

Plain HTML. Tabs: data-lds-tabs hides and shows the panels for you. Steps and other swaps: toggle hidden (or render the new view); the animation plays each time the element is shown. There is no directional swap class in the system.

React. From lampung-design-system/react.

import { Steps } from 'lampung-design-system/react';

<Steps label="Application" items={['Program', 'Documents', 'Review']} current={step} />
<section key={step} style={{ animation: 'lds-blur-in var(--d-standard) var(--ease-enter)' }}>{views[step]}</section>