Sidebar
The goal of this plugin is to make it easier to change the layout to create a sidebar. The caption of each slide is used for the sidebar content. If a slide does not have a caption, a fallback text is displayed, which can be customized using the defaultCaption option.
Examples
Basic example
Customized
You can optionally disable the toolbar and show your own closing element instead by adding the data-fancybox-close attribute.
Sidebar width and padding can be customized with CSS variables, which can also be passed in with JS.
Toolbar button
This plugin adds an additional button sidebar to the Carousel Toolbar plugin that toggles the sidebar. This example also demonstrates the option when the sidebar is not initially visible:
Usage
Include corresponding JS and CSS files:
import { Sidebar } from "@fancyapps/ui/dist/fancybox/fancybox.sidebar.js";
import "@fancyapps/ui/dist/fancybox/fancybox.sidebar.css";Use plugins option to pass Sidebar to Fancybox constructor.
Fancybox.bind("[data-fancybox]", {
plugins: { Sidebar },
});Use the plugin name as the option name to pass custom options. Example:
Fancybox.bind("[data-fancybox]", {
plugins: { Sidebar },
Sidebar: {
showOnStart: false,
},
});Options
defaultCaption
Default content to display in the sidebar if the active slide has no caption
Type
string | ((instance: FancyboxInstance) => string)
Default
"<em>{{NO_CAPTION}}</em>"mainTpl
HTML template for Fancybox main structure
Type
string
Default
<dialog class="fancybox__dialog">
<div class="fancybox__container" tabindex="0" aria-label="{{MODAL}}">
<div class="fancybox__backdrop"></div>
<div class="fancybox__carousel">
<div class="fancybox__grid">
<div class="fancybox__column with-viewport">
<div class="fancybox__viewport"></div>
</div>
<div class="fancybox__column with-sidebar">
<div class="fancybox__sidebar"></div>
</div>
</div>
</div>
</div>
</dialog>showOnStart
If the sidebar should be visible after launching Fancybox
Type
boolean
Default
true