JavaScript UI Component Library

Related tags

React ui
Overview

Fancyapps UI

Collection of task-oriented components that will make you more productive. Packed full of features that you and your clients will love.

Full docs with examples: https://fancyapps.com/docs/ui/quick-start/.

Installation

NPM

Use either npm or yarn as follows:

npm install @fancyapps/ui
// or
yarn add  @fancyapps/ui

Import one or more components:

import { Fancybox, Carousel, Panzoom } from "@fancyapps/ui";

Import the appropriate CSS file, example:

import "@fancyapps/ui/dist/fancybox.css";

CDN

A pre-bundled scripts that contain components are available on CDN.

NOTE: Because Fancybox is build on top of both Carousel and Panzoom components, you only have to include fancybox.umd.js and all 3 components will be available through the window object.

<script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script>

Or use ES6 import:

<script type="module">
  import { Fancybox } from "https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.esm.js";
</script>

Remember to include the appropriate CSS file, example:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" />

Usage

Fancybox

There are two ways to use Fancybox.

Declarative

Add a data-fancybox attribute to any element to enable Fancybox. Galleries are created by adding the same attribute data-fancybox value to multiple elements. Use data-src or href attribute to specify the source of the content. Add a data-caption attribute if you want to show a caption under the content.

<a href="https://lipsum.app/id/1/1024x768" data-fancybox="gallery" data-caption="Optional caption">
  Image
</a>
<a href="http://media.w3.org/2010/05/sintel/trailer.mp4" data-fancybox>
  Video
</a>
<a
  href="https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d10500.902039411158!2d2.2913514905137315!3d48.85391001859112!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1slv!2slv!4v1622011463926!5m2!1slv!2slv"
  data-fancybox
  data-type="iframe"
  data-preload="false"
  data-width="640"
  data-height="480"
>
  Iframe
</a>
<button data-fancybox data-src="#dialog-content">
  HTML element
</button>

<div id="dialog-content" style="display:none;">
  <h2>Hello, world!</h2>
  <p>
    <input type="text" value="See if changes remain after closing the dialog" />
  </p>
</div>

Customize options:

Fancybox.bind("[data-fancybox]", {
  // Your options go here
});

Programmatic

// Image gallery
var gallery = [
  {
    src: "https://lipsum.app/id/2/800x600",
    thumb: "https://lipsum.app/id/2/80x80",
    caption: "First image",
  },
  {
    src: "https://lipsum.app/id/3/800x600",
    thumb: "https://lipsum.app/id/3/80x80",
    caption: "Second image",
  },
  {
    src: "https://lipsum.app/id/4/800x600",
    thumb: "https://lipsum.app/id/4/80x80",
    caption: "Third image",
  },
];

Fancybox.show(gallery, {
  // Your options go here
});

// HTML element
Fancybox.show([{ src: "#dialog-content", type: "inline" }]);

// A copy of HTML element
Fancybox.show([{ src: "#dialog-content", type: "clone" }]);

// Any HTML content
Fancybox.show([{ src: "<p>Lorem ipsum dolor sit amet.</p>", type: "html" }]);

Carousel

Add HTML markup

<div id="myCarousel" class="carousel">
  <div class="carousel__slide">1</div>
  <div class="carousel__slide">2</div>
  <div class="carousel__slide">3</div>
</div>

Initialise Carousel

const myCarousel = new Carousel(document.querySelector("#myCarousel"), {
  // Your options go here
});

Optionally, use CSS to customize container, navigation elements and slides

.carousel {
  color: #170724;

  --carousel-button-bg: #fff;
  --carousel-button-shadow: 0 2px 1px -1px rgb(0 0 0 / 20%), 0 1px 1px 0 rgb(0 0 0 / 14%), 0 1px 3px 0 rgb(0 0 0 / 12%);

  --carousel-button-svg-width: 20px;
  --carousel-button-svg-height: 20px;
  --carousel-button-svg-stroke-width: 2.5;
}

.carousel__slide {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 80%;
  height: 160px;
  margin-right: 6px;

  background-color: #eee;
  border-radius: 6px;
}

Panzoom

Add HTML markup

<div id="myPanzoom" class="panzoom">
  <img class="panzoom__content" src="https://lipsum.app/id/3/2000x1500" alt="" />
</div>

Initialise Panzoom

const myPanzoom = new Panzoom(document.querySelector("#myPanzoom"), {
  // Your options go here
});

Optionally, use CSS to customize container

.panzoom {
  width: 400px;
  height: 300px;
}

License

This is commercial software. See LICENSE.md for more info.

Comments
  • About licensing

    About licensing

    Hello, I wonder are we allowed to use it in our wordpress themes that we are selling to multiple clients with extended license? It was enough for V3 but I wanna be sure for V4.

    Thanks.

    question 
    opened by flyingatm 22
  • Wait for DOMContentLoaded event instead of checking for document.body

    Wait for DOMContentLoaded event instead of checking for document.body

    document.body might not yet be available during the load of the script (especially with the UMD version). So have to wait for it to become available.

    Fixes #81

    opened by djmaze 12
  • New upscaling/zoom behaviour causes blurry images (Panzoom)

    New upscaling/zoom behaviour causes blurry images (Panzoom)

    If I'm not completely wrong, the behavior of how images are scaled to 100% has changed in comparison to fancybox 3.

    Fancybox 4 uses now css transform and scales the image up to - for example - scale(1.4066). This causes naturally a little blurred image also if the calculation is right and the scaled image corresponds 1:1 to the natural image size.

    It's the browser's transform scale rendering that blurs the image and after a lot of research about this, this can't be fixed with css tweaks.

    The lower the screen resolution, the more the problem appears:

    left fancybox 4, right the image url opened

    At the end this is very sad for all user who want to show her images on mobile devices with panzoom functionality.

    The solution could only be another way to reach the 1:1 / zoomed view of an image - without any css transform upscaling.

    bug 
    opened by amkdev 10
  • Initial scale behavior broken in Safari 11–13

    Initial scale behavior broken in Safari 11–13

    Great update - thank you!

    Working on a project and my client is running macOS High Sierra and was seeing some unexpected scale behavior when clicking on a Fancybox-designated image.

    On click, the image is scaled to fill the viewport instead of being contained within the viewport (expected).

    Here is a screenshot of the behavior:

    CleanShot 2021-09-27 at 23 19 42@2x

    Here is a screenshot of the expected behavior:

    CleanShot 2021-09-27 at 23 20 27@2x

    ^^ in the expected version, the initial image size/scale is constrained to the viewport or window. In Safari versions 11–13, the image is scaled all the way to the width of the container.

    This seems to be fixed in Big Sur but was able to reproduce the behavior using Browserstack with Safari + High Sierra/Mojave/Catalina.

    Not sure if this is a Safari bug but initially was having a hard time counteracting it with CSS.

    Hopefully this may be fixed in a future update?

    needs triage 
    opened by joshuaiz 9
  • data-type=

    data-type="pdf" for url that `redirect` to pdf or `download` pdf

    @fancyapps

    for example if file extension not present in url fancybox instead of showing pdf content

    will open black iframe and download it after iframe loaded

    opened by sadeghbarati 8
  • Iframe Keyboard Navigation

    Iframe Keyboard Navigation

    Hello,

    I am currently in search for a lightbox alternative for our project and Fancybox looks like a very good choice. Especially the good integration of keyboard controls is a big plus for this plugin.

    However, we have some cases where there are multiple Iframes in one gallery. The current behaviour is that once you get into one iframe, you navigate through all the other iframes of the gallery as well before regaining focus in the lightbox overlay.

    To replicate this you can simply adjust this playground example (https://fancyapps.com/playground/vk) by duplicating the last video 'a'-tag.

    Can a fix for this issue still be expected for the 4.0.0 release?

    Thanks in advance!

    opened by fcjm 8
  • Panzoom buttons

    Panzoom buttons

    Hi! I recently install Panzoom, but I can´t make the buttons for zoom in & zoom out appear over my image, just like in Quick Demo example. What I´m missing?

    quick-demo

    documentation 
    opened by Darq2016 7
  • Fancybox Slideshow autostart issue

    Fancybox Slideshow autostart issue

    I have a Fancybox Slideshow triggered by an image-hyperlink : slideshow autoStart does not work. When replacing the image-hyperlink by text-hyperlink, the autoStart is working OK. Any possible explanation ?

    fancybox-text.txt fancybox-image.txt

    opened by lionel-dieu 7
  • Cannot scroll around zoomed image using Firefox Mobile

    Cannot scroll around zoomed image using Firefox Mobile

    After clicking on an image and using "pinch to zoom" you cannot scroll around the zoomed in image using touch. Instead, attempting to scroll around the image results in erratic zooming in and out.

    This is using Firefox Mobile 97.2.0 on Android. It's fine in Google Chrome.

    opened by 1stwebdesigns 6
  • Nested <Fancybox> React components - allowed or antipattern?

    Nested React components - allowed or antipattern?

    Hi. I create a React component Fancybox

    import { memo, useEffect, FC } from 'react';
    import { Fancybox as NativeFancybox } from '@fancyapps/ui/dist/fancybox.umd';
    
    export interface FancyboxProps {
      delegate?: string;
      options?: {};
    }
    
    const Fancybox: FC<FancyboxProps> = (props) => {
      const { delegate = '[data-fancybox]', options = {}, children } = props;
    
      useEffect(() => {
        const opts = options;
    
        NativeFancybox.bind(delegate, opts);
    
        return () => {
          NativeFancybox.destroy();
        };
      }, [delegate, options]);
    
      // eslint-disable-next-line react/jsx-no-useless-fragment
      return <>{children}</>;
    };
    
    export default memo(Fancybox);
    
    

    And inside root of my app I just wrapped it in this component

    <Fancybox>
    //...
    </Fancybox>
    

    And, later, inside one of my sections I want to bind some spefific options for a gallery. It is allowed to make another <Fancybox options={{..}} > inside first global one? Purpose of global one is to global control all modals / triggers of the app, that have not required some specific options on instance.

    opened by 7iomka 6
  • The animation are not smooth

    The animation are not smooth

    Trying to use new fancybox, i found the animation are not smooth

    fancybox 3 TEST

    fanvybox 4 TEST2

    it seem like you are remove the hash option, can you bring it back? i want to set it to false, because it will cause the website reload when use in pjax

    bug 
    opened by jerryc127 6
  • Carousel doesn't clear its styles on destroy

    Carousel doesn't clear its styles on destroy

    At the carousel, after calling the destroy() method, the carousel _ track block has inline styles. Workaround: clear styles manually before destroying using slider.$track.style = ''. Are there any other workarounds?

    Why do I need this: on a small screen resolution, I use a carousel, on the rest, the blocks line up with a grid.

    Playground: https://fancyapps.com/playground/4hU

    Reproduction steps: press the "destroy" button in the playground and look at the carousel styles through DevTools.

    Can you please make changes to the carousel source code? I will be very grateful.

    opened by pleomax13 0
  • Zoom into original image when using `srcset` in Fancybox

    Zoom into original image when using `srcset` in Fancybox

    When using data-srcset, zooming zooms into the currently selected source of the srcset. If the source sizes are judiciously selected, the image is already appropriately sized for the viewport, so very little zooming actually happens. Or, if data-width and data-height were specified, the image is indeed zoomed to those dimensions, but the source is not switched, which can cause upscaling.

    Is there a way to always use the original (href / data-src) image for zooming instead? I understand this can cause a delay as the image may need to be loaded when the zoom action is triggered (and prefetching the original would defeat the point of using srcset).

    Observed with latest Fancybox on MacOS Chrome 107.

    enhancement 
    opened by mikaraunio 8
  • Support for multiple image formats

    Support for multiple image formats

    Problem Description

    Fancybox only allows a single image format to be used (https://github.com/fancyapps/ui/blob/main/src/Fancybox/plugins/Image/Image.js#L204). Since lightbox image viewers are meant to load higher quality images on click, allowing "next-gen" formats improves loading times.

    Design

    There are several ways to solve it, Photoswipe for instance provides a hardcoded attribute for webp since it's the most used nowadays.

    Implementation Details

    Simple

    Assume most devs will just end up using webp. Create a new attribute (data-srcset-webp) for HTML markup.

    HTML Markup

    <a
        href="https://image.placeholder/rand.jpeg"
        data-fancybox="gallery"
        data-caption="Optional caption"
        data-srcset="https://image.placeholder/rand.jpeg 800w, https://image.placeholder/rand_1600w.jpeg 1600w"
        data-srcset-webp="https://image.placeholder/rand.webp 800w, https://image.placeholder/rand_1600w.webp 1600w"
    >
        <div class="foo">
          <picture>
            <source type="image/webp" srcset="..." sizes="...">
            <source type="image/avif" srcset="..." sizes="...">
            <img sizes="..." src="https://lipsum.app/id/2/80x80" srcset="...">
          </picture>
        </div>
    </a>
    

    API

    const gallery = [
      {
        src: "https://lipsum.app/id/2/800x600",
        thumb: "https://lipsum.app/id/2/80x80",
        caption: "First image",
        webp: "https://lipsum.app/id/2/800x600",
      },
      // ...
    ]
    
    Fancybox.show(gallery, {
      // Your options go here
    })
    

    Advanced

    Parse all attributes starting with data-source-xxx/data-srcset-xxx as sources.

    HTML Markup

    <a
        href="https://image.placeholder/rand.jpeg"
        data-fancybox="gallery"
        data-caption="Optional caption"
        data-srcset="https://image.placeholder/rand.jpeg 800w, https://image.placeholder/rand_1600w.jpeg 1600w"
        data-srcset-webp="https://image.placeholder/rand.webp 800w, https://image.placeholder/rand_1600w.webp 1600w"
        data-srcset-avif="https://image.placeholder/rand.avif 800w, https://image.placeholder/rand_1600w.avif 1600w"
        data-srcset-heic="https://image.placeholder/rand.heic 800w, https://image.placeholder/rand_1600w.heic 1600w"
    >
        <div class="foo">
          <picture>
            <source type="image/webp" srcset="..." sizes="...">
            <source type="image/avif" srcset="..." sizes="...">
            <img sizes="..." src="https://lipsum.app/id/2/80x80" srcset="...">
          </picture>
        </div>
    </a>
    

    API

    const gallery = [
      {
        src: "https://lipsum.app/id/2/800x600",
        thumb: "https://lipsum.app/id/2/80x80",
        caption: "First image",
        formats: {
            webp: "...",
            avif: "...",
        }
      },
      // ...
    ]
    
    Fancybox.show(gallery, {
      // Your options go here
    })
    
    enhancement 
    opened by bre7 0
  • How to set a minimum width / height for an image slide?

    How to set a minimum width / height for an image slide?

    I'm using Fancybox to present some small animated gifs. A high quality animated gif may be very small dimensionally, but they look good when scaled up. My gifs however are presented in their original size and take up very little of the available area. How do I tell fancybox to scale the images to fit the available area, or better yet, to set a minimum image width/height?

    I've tried the following to make them fit the slide area:

    fb.on("reveal", ()=>{
        var slide = fb.getSlide();
        slide.$content.style.width = "100%";
        slide.$content.style.height = "100%";
        slide.$image.style.width = "100%";
        slide.$image.style.height = "100%";
    });
    

    It works but it leads to some glitchy looking effects when changing slides. I presume there's a better way?

    opened by hedgehog90 1
  • How to programatically enable zoom effect from clicked image on new Fancybox instance?

    How to programatically enable zoom effect from clicked image on new Fancybox instance?

    I start my fancybox like so:

    var fb = new Fancybox(
        [
            {src: "https://site.com/image1"},
            {src: "https://site.com/image2"},
            {src: "https://site.com/image3"}
        ], {
            startIndex: index,
        }
    );
    

    But I trigger it on clicking an image. How do I make it do the cool scaling effect on opening from the image that was clicked? I can't find an answer anywhere in the documentation.

    opened by hedgehog90 2
  • Carousel  slides unexpectedly when toggling class

    Carousel slides unexpectedly when toggling class

    I'm using the carousel to slide some posts and once I added a "expand" function which basically toggles a class the carousel jumps unexpectedly . I first got this issue when I tried to implement the function in react, I thought it might have been something wrong with my application, but I managed to reproduce it with the regular package.

    You can see the issue here which I tried to reproduce https://fancyapps.com/playground/3To If you navigate once to the right and click the second last item in the carousel once or twice you should see jump.

    or where the problem originated from https://lajara.se/projekt/brf-villastaden at the bottom of the page you have icons if you click them before the slide is fully finished it will jump

    bug 
    opened by ombicen 1
Owner
Jānis Skarnelis
Jānis Skarnelis
Material-UI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start with Material Design.

Material-UI Quickly build beautiful React apps. Material-UI is a simple and customizable component library to build faster, beautiful, and more access

Material-UI 83.6k Dec 30, 2022
A React Component library implementing the Base design language

Base Web React Components Base is a design system comprised of modern, responsive, living components. Base Web is the React implementation of Base. Us

Uber Open Source 8.1k Dec 29, 2022
A small component based app library composing user interfaces and apps.

See https://vibejs.com for ongoing documentation and info. VibeJS A small component based JavaScript library to build user interfaces and apps. If you

Bret 20 Nov 16, 2022
React component library for displaying code samples with syntax highlighting!!

react-code-samples usage example: import {} from 'react-code-samples'; import 'highlight.js/styles/default.css'; // or use another highlight js style

Pranav Teegavarapu 8 Jan 3, 2022
Accessible, unstyled, open-sourced, and fully functional react component library for building design systems

DORAI UI Accessible, unstyled, open-sourced and fully functional react component library for building design systems Documentation site coming soon St

Fakorede Boluwatife 38 Dec 30, 2022
This library is a template to generate new angular component libraries.

Open Template Hub - UI Library Template v1 This library is a template to generate new angular component libraries. About the NPM Package Package Insta

Open Template Hub 6 Dec 18, 2022
A component library based on Material Design 3 & Web Components

material-web-entity Material Web Entity A component library based on Material Design & Web Components Go to link to see what components this library s

HugePancake 5 Jun 3, 2022
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!

Build bulletproof UI components faster Storybook is a development environment for UI components. It allows you to browse a component library, view the

Storybook 75.8k Jan 4, 2023
The Select Component for React.js

React-Select The Select control for React. Initially built for use in KeystoneJS. See react-select.com for live demos and comprehensive docs. React Se

Jed Watson 25.6k Jan 3, 2023
:hourglass_flowing_sand: A higher order component for loading components with promises.

A higher order component for loading components with dynamic imports. Install yarn add react-loadable Example import Loadable from 'react-loadable'; i

Jamie Kyle 16.5k Jan 3, 2023
A Higher Order Component using react-redux to keep form state in a Redux store

redux-form You build great forms, but do you know HOW users use your forms? Find out with Form Nerd! Professional analytics from the creator of Redux

Redux Form 12.6k Jan 3, 2023
⚪ SVG-Powered component to easily create skeleton loadings.

SVG-Powered component to easily create placeholder loadings (like Facebook's cards loading). Features ⚙️ Customizable: Feel free to change the colors,

Danilo Woznica 12.7k Jan 4, 2023
Isolated React component development environment with a living style guide

Isolated React component development environment with a living style guide React Styleguidist is a component development environment with hot reloaded

Styleguidist 10.6k Jan 5, 2023
Markdown component for React

react-markdown Markdown component for React using remark. Learn markdown here and check out the demo here. Install npm: npm install react-markdown Why

remark 9.7k Jan 4, 2023
React draggable component

React-Draggable A simple component for making elements draggable. <Draggable> <div>I can now be moved around!</div> </Draggable> Demo Changelog Vers

RGL 8.1k Jan 4, 2023
Accessible modal dialog component for React

react-modal Accessible modal dialog component for React.JS Table of Contents Installation API documentation Examples Demos Installation To install, yo

React Community 7.1k Jan 1, 2023
A Vue.js popover component based on PopperJS

vue3-popper A popover component for Vue 3 Documentation Check out the documentation Getting started Usage Install NPM npm install vue3-popper Yarn yar

Valgeir Björnsson 170 Dec 30, 2022
Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS.

React Table + Tailwind CSS = ❤️ Source code for my tutorial on how to build customizable table component with React Table and Tailwind CSS. Both parts

Samuel Liedtke 147 Jan 7, 2023
To eleventy and beyond! The all-in-one tool for templates where you want them, component frameworks where you need them 🚀

Slinkity ?? This project is heavily under construction! ?? As excited as you may be, we don't recommend this early alpha for production use. Still, gi

Benjamin Holmes 398 Dec 27, 2022