Juji Blog

VistaView: A Modern Lightweight Image Lightbox for the Web

VistaView is a zero-dependency, framework-agnostic image lightbox library that brings a smooth, modern viewing experience to your web projects. Whether you're building with React, Vue, Svelte, or vanilla JavaScript, VistaView has you covered.

Docs: https://vistaview.jujiplay.com/

Why VistaView?

Building a beautiful image viewing experience shouldn't require heavy dependencies or complex setup. VistaView delivers:

  • πŸͺΆ Lightweight: Zero dependencies, minimal footprint (~10KB gzipped)
  • 🎨 Beautiful: 17+ pre-built themes with smooth animations
  • πŸ”Œ Extensible: Support for YouTube, Vimeo, Dailymotion, Wistia, Vidyard, Streamable, and more
  • 🎯 Framework Agnostic: Works with React, Vue, Svelte, Solid, or vanilla JS
  • πŸ“± Responsive: Touch-friendly and mobile-optimized
  • β™Ώ Accessible: Keyboard navigation and ARIA support
  • πŸ—ΊοΈ Maps Integration: Google Maps, Mapbox, and OpenStreetMap support

Getting Started

Installation

1npm install vistaview

Basic Usage

The simplest way to get started with VistaView:

1import { vistaView } from 'vistaview';
2import 'vistaview/style.css';
3
4vistaView({
5 elements: 'a.gallery',
6});
1<a href="image-large.jpg" class="gallery">
2 <img src="image-thumb.jpg" alt="Beautiful landscape" />
3</a>

That's it! Your images now open in a beautiful lightbox with smooth transitions.

Beautiful Themes Out of the Box

VistaView comes with 17 carefully crafted themes. Simply import the theme CSS:

1import 'vistaview/dist/styles/midnight-ocean.css';
2import 'vistaview/dist/styles/neon-nights.css';
3import 'vistaview/dist/styles/cotton-candy.css';

Available themes include Dark Rounded, Midnight Ocean, Midnight Gold, Neon Nights, Retro Arcade, Ember Glow, Cotton Candy, Strawberry, Lavender Fields, Paper Light, Soft Neutral, Stark Minimal, and more!

Framework Integration

React

VistaView provides a React hook for seamless integration:

1import { useVistaView } from 'vistaview/react';
2import 'vistaview/style.css';
3
4function Gallery() {
5 const galleryRef = useVistaView({
6 controls: {
7 topRight: ['zoomIn', 'zoomOut', 'close'],
8 },
9 });
10
11 return (
12 <div ref={galleryRef}>
13 <a href="large-1.jpg">
14 <img src="thumb-1.jpg" alt="Image 1" />
15 </a>
16 <a href="large-2.jpg">
17 <img src="thumb-2.jpg" alt="Image 2" />
18 </a>
19 </div>
20 );
21}

Vue

For Vue developers, VistaView provides a composable:

1<script setup>
2import { useVistaView } from 'vistaview/vue';
3import 'vistaview/style.css';
4
5const galleryRef = useVistaView({
6 controls: {
7 topRight: ['zoomIn', 'zoomOut', 'close'],
8 },
9});
10</script>
11
12<template>
13 <div ref="galleryRef">
14 <a href="large-1.jpg">
15 <img src="thumb-1.jpg" alt="Image 1" />
16 </a>
17 </div>
18</template>

Svelte

Svelte users can use the action directive:

1<script>
2 import { useVistaView } from 'vistaview/svelte';
3 import 'vistaview/style.css';
4
5 const galleryRef = useVistaView({
6 controls: {
7 topRight: ['zoomIn', 'zoomOut', 'close'],
8 },
9 });
10</script>
11
12<div use:galleryRef>
13 <a href="large-1.jpg">
14 <img src="thumb-1.jpg" alt="Image 1" />
15 </a>
16</div>

Powerful Extensions

VistaView's extension system is where things get really interesting. Let's explore what you can do.

Video Platform Support

Embed videos from popular platforms directly in your lightbox:

1import { vistaView } from 'vistaview';
2import { youtubeVideo } from 'vistaview/extensions/youtube-video';
3import { vimeoVideo } from 'vistaview/extensions/vimeo-video';
4
5vistaView({
6 elements: '.gallery a',
7 extensions: [
8 youtubeVideo(),
9 vimeoVideo(),
10 ],
11});

Now your gallery can display videos seamlessly:

1<a href="https://www.youtube.com/watch?v=VIDEO_ID">
2 <img src="thumbnail.jpg" alt="Video thumbnail" />
3</a>

Supported platforms:

  • YouTube
  • Vimeo
  • Dailymotion
  • Wistia
  • Vidyard
  • Streamable

Image Story Extension

Add rich descriptions and stories to your images:

1import { imageStory } from 'vistaview/extensions/image-story';
2import 'vistaview/dist/styles/extensions/image-story.css';
3
4vistaView({
5 elements: '.gallery a',
6 extensions: [
7 imageStory({
8 getStory: async (index) => ({
9 content: `<p>Description for image ${index + 1}</p>`,
10 }),
11 }),
12 ],
13 controls: {
14 bottomCenter: ['imageStory'],
15 },
16});

Download Extension

Let users download images with a single click:

1import { download } from 'vistaview/extensions/download';
2
3vistaView({
4 elements: '.gallery a',
5 extensions: [download()],
6 controls: {
7 topRight: ['download', 'close'],
8 },
9});

Maps Integration

Display interactive maps in your lightbox:

1import { googleMaps } from 'vistaview/extensions/google-maps';
2import { openStreetMap } from 'vistaview/extensions/openstreetmap';
3
4vistaView({
5 elements: '.gallery a',
6 extensions: [
7 googleMaps({ apiKey: 'YOUR_API_KEY' }),
8 openStreetMap(),
9 ],
10});
1<a href="https://www.google.com/maps/@40.7128,-74.0060,15z">
2 <img src="map-thumbnail.jpg" alt="New York City" />
3</a>

Advanced Configuration

Custom Controls

Position controls exactly where you want them:

1vistaView({
2 elements: '.gallery a',
3 controls: {
4 topLeft: ['counter'],
5 topRight: ['zoomIn', 'zoomOut', 'download', 'close'],
6 bottomCenter: ['imageStory'],
7 },
8});

Responsive Images

Support multiple image resolutions:

1<a href="large.jpg"
2 data-vistaview-srcset="medium.jpg 800w, large.jpg 1600w, xlarge.jpg 2400w">
3 <img src="thumb.jpg" alt="Responsive image" />
4</a>

Real-World Example

Here's a complete example combining multiple extensions:

1import { vistaView } from 'vistaview';
2import { youtubeVideo } from 'vistaview/extensions/youtube-video';
3import { vimeoVideo } from 'vistaview/extensions/vimeo-video';
4import { download } from 'vistaview/extensions/download';
5import { imageStory } from 'vistaview/extensions/image-story';
6import 'vistaview/style.css';
7import 'vistaview/dist/styles/midnight-ocean.css';
8import 'vistaview/dist/styles/extensions/image-story.css';
9
10vistaView({
11 elements: '.my-gallery a',
12 controls: {
13 topRight: ['zoomIn', 'zoomOut', 'download', 'close'],
14 bottomCenter: ['imageStory'],
15 },
16 extensions: [
17 youtubeVideo(),
18 vimeoVideo(),
19 download(),
20 imageStory({
21 getStory: async (index) => ({
22 content: `
23 <h3>Image ${index + 1}</h3>
24 <p>This is a beautiful photo taken in 2024.</p>
25 `,
26 }),
27 }),
28 ],
29});

Performance Matters

VistaView is designed with performance in mind:

  • Lazy loading: Images load only when needed
  • Hardware-accelerated animations: Smooth 60fps transitions
  • Small bundle: ~10KB gzipped for core, extensions loaded on-demand
  • Zero dependencies: No bloat from third-party libraries

Browser Support

VistaView works on all modern browsers:

  • Chrome/Edge 90+
  • Firefox 88+
  • Safari 14+
  • Mobile browsers (iOS Safari, Chrome Android)

Try It Yourself

Check out the interactive demo to see VistaView in action with all themes and extensions.

Conclusion

VistaView makes it easy to add a beautiful, performant lightbox to any web project. With zero dependencies, extensive framework support, and powerful extensions, it's the modern solution for image viewing on the web.

Whether you're building a portfolio, a photo gallery, an e-commerce site, or any project that needs a great image viewing experience, VistaView has you covered.

Links:

Give it a try and let me know what you think! ⭐


Built with ❀️ by juji