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.

Shared element

Shared element

The picture you tap grows out of its own thumbnail into the full view and shrinks back into the same spot when closed (a FLIP transition). Because the object never disappears, people keep their place: the large view is visibly the same thing, not a new page.

Usage

Use it when

  • Opening a photo, diagram or scan from a grid or an article into a lightbox.
  • Any thumbnail whose large version is the same picture: campus photos, lab results, a scanned answer sheet.

Use something else when

  • Opening details that are not the same picture (a course card to its page): use Nav progress. There is no generic shared-element transition for arbitrary elements yet; navigate normally.
  • A form or a question over the page: use Dialog.
  • Browsing a row of pictures in place: use Carousel.
  • Content opening below its trigger: use Height expand.
  • Showing a small picture in a list or a card: use Thumbnail.

Where it goes. On a .thumb link (<a class="thumb" href="large.jpg" data-lds-lightbox>) around an <img>, anywhere: an auto-grid of photos, a figure inside prose, a card. The lightbox is appended to <body> as a fixed layer.

Examples

A grid of campus photosOpen a photo: it grows from its exact place in the grid to the center while the backdrop fades in. Close it (Escape, the close button or the backdrop) and it shrinks back into the same tile.
The central library with its tall windows The biology lab building among trees The main hall in warm evening light
<div class="auto-grid" style="--min: 150px;">
  <a class="thumb" href="library-large.jpg" data-lds-lightbox data-caption="Central library, east entrance">
    <img src="library-small.jpg" alt="The central library with its tall windows">
  </a>
  …
</div>
A figure in a lessonInside an article the figure stays small enough to keep reading; tapping it grows it without losing the place in the text.

Plant cells keep their shape because the cell wall pushes back when water flows in. The photo below shows the lab building where you will run the experiment in week 6.

The biology lab building among trees

Bring a lab coat and your printed worksheet. The room opens 15 minutes before the session.

<div class="prose">
  <p>Plant cells keep their shape because the cell wall pushes back when water flows in. The photo below shows the lab building where you will run the experiment in week 6.</p>
  <div style="max-width: 280px;"><a class="thumb" href="data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%20800%20600'%3E%3Crect%20width%3D'800'%20height%3D'600'%20fill%3D'%23DCFCE7'%2F%3E%3Ccircle%20cx%3D'640'%20cy%3D'130'%20r%3D'56'%20fill%3D'%23FDE68A'%2F%3E%3Crect%20x%3D'170'%20y%3D'210'%20width%3D'460'%20height%3D'270'%20rx%3D'8'%20fill%3D'%2315803D'%2F%3E%3Cpath%20d%3D'M150%20220%20L400%20110%20L650%20220%20Z'%20fill%3D'%2315803D'%2F%3E%3Cg%20fill%3D'%23DCFCE7'%20opacity%3D'0.85'%3E%3Crect%20x%3D'220'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'320'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'420'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'520'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'360'%20y%3D'380'%20width%3D'80'%20height%3D'100'%2F%3E%3C%2Fg%3E%3Crect%20y%3D'480'%20width%3D'800'%20height%3D'120'%20fill%3D'%23166534'%2F%3E%3C%2Fsvg%3E" data-lds-lightbox data-caption="Biology lab, building C, room 2.14"><img src="data:image/svg+xml,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%20800%20600'%3E%3Crect%20width%3D'800'%20height%3D'600'%20fill%3D'%23DCFCE7'%2F%3E%3Ccircle%20cx%3D'640'%20cy%3D'130'%20r%3D'56'%20fill%3D'%23FDE68A'%2F%3E%3Crect%20x%3D'170'%20y%3D'210'%20width%3D'460'%20height%3D'270'%20rx%3D'8'%20fill%3D'%2315803D'%2F%3E%3Cpath%20d%3D'M150%20220%20L400%20110%20L650%20220%20Z'%20fill%3D'%2315803D'%2F%3E%3Cg%20fill%3D'%23DCFCE7'%20opacity%3D'0.85'%3E%3Crect%20x%3D'220'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'320'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'420'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'520'%20y%3D'270'%20width%3D'60'%20height%3D'80'%2F%3E%3Crect%20x%3D'360'%20y%3D'380'%20width%3D'80'%20height%3D'100'%2F%3E%3C%2Fg%3E%3Crect%20y%3D'480'%20width%3D'800'%20height%3D'120'%20fill%3D'%23166534'%2F%3E%3C%2Fsvg%3E" alt="The biology lab building among trees"></a></div>
  <p>Bring a lab coat and your printed worksheet. The room opens 15 minutes before the session.</p>
</div>

Motion and microinteractions

  • FLIP: the large image is placed at its final position, then animated from the thumbnail rectangle (translate plus scale from the measured boxes) to none. Open: 420 ms on the enter curve (cubic-bezier(0.16, 1, 0.3, 1), the --ease-enter values). Close: the same path reversed in 220 ms, back into the thumbnail.
  • Backdrop: .lightbox fades in over --d-standard on --ease-enter and out over --d-exit on --ease-exit.
  • Only transform animates (origin at the top left corner), so the flight stays smooth with large images.
  • Interruption: closing during the opening flight starts the return from the current frame; nothing has to finish first.
  • Reduced motion: no flight. The lightbox fades in and out (120 ms) and the image appears in place.

Accessibility

  • The thumbnail is a real link to the large image, so it works without JS and opens in a new tab on middle click. Give the <img> a real alt.
  • The lightbox is role="dialog" with aria-modal="true", labelled by data-caption (or the alt). Focus goes to the close button; Tab stays on it; Escape closes; focus returns to the thumbnail.
  • Put the caption in data-caption; it is shown under the picture and used as the dialog label.

Do and don't

Do

  • Use data-lds-lightbox on a .thumb link with an <img> inside.
  • Keep the thumbnail at the same aspect ratio as the large image when you can; the flight then has no distortion.
  • Write a caption that says what and where.

Don't

  • Fade a lightbox in from the center when it was opened from a thumbnail.
  • Animate width, height or top to fake the growth.
  • Use it for a picture the person has to compare with text side by side; open it in place instead.

Behavior and code

Plain HTML. init() wires a[data-lds-lightbox] (with an <img> inside): on click it builds the .lightbox dialog with .lightbox__close and .lightbox__caption from data-caption (close label from data-close), runs the FLIP flight, and on close runs it backwards and returns focus. The FLIP is specific to the lightbox; there is no general shared-element helper.