Lightbox
BsLightbox is a modal image gallery component that is used to display a collection of images.
Overview
BsLightbox uses <bs-overlay>
component internally and can be closed using the ESC key (enabled by default), or clicking the backdrop (enabled by default). BsLightbox has previous/next controls, indicator and toolbar buttons enabled by default. Data sources is provided via items
property. Additionally, you can use arrow key left/right as navigation.
Custom Toolbar
BsLightbox toolbar buttons can be customized to some extent. Additionally, you can add custom menus to your needs via menubar
slot and enable the menubar
button via toolbar
property to make the custom menus work correctly. Some buttons do not perform any action, only trigger an event. You must provide your own method for these buttons. The buttons that don't provide any actions are: download, delete and info buttons.
Single Image
BsLightbox can also be used to display single modal image. To achieve this, you have to sets show-counter
, show-nav-control
, and show-thumbnail
property to false
. Additionally, you can also sets show-toolbar
property to false
, if you don't need any toolbar buttons.
CSS Variables
Added since v2.0.0--md-lightbox-element-padding-x: 0.5rem;
--md-lightbox-display-bg: rgba(0,0,0, .3);
--md-lightbox-toolbar-bg: (0,0,0, .9);
--md-lightbox-toolbar-color: #ced4da;
--md-lightbox-overlay-bg: #151515;
--md-lightbox-title-bg: rgba(0,0,0, .7);
--md-lightbox-title-color: #ced4da;
--md-lightbox-title-size: 1.25rem;
--md-lightbox-thumbnail-bg: rgba(0,0,0, .95);
--md-lightbox-thumbnail-border: 1px solid rgba(0,0,0, .6);
--md-lightbox-thumbnail-opacity: 0.5;
--md-lightbox-thumbnail-active-border-color: #f44336;
--md-lightbox-thumbnail-active-border-width: 2px;
API Reference
Property | Type | Default | Description |
---|---|---|---|
esc-close | Boolean | true | Close Lightbox when ESC key is pressed. |
image-class | String /String[] | Additional css class name for active image. | |
image-styles | Object | Additional css styles for active image. | |
items | TImageDataset[] | Lightbox source dataset. | |
open v-model | Boolean | false | Show or hide the lightbox. |
overlay | Boolean | true | Show backdrop overlay or not. |
overlay-click-close | Boolean | true | Close Lightbox when the backdrop is clicked. v2.0.0 |
overlay-color | String | '#000' | The backdrop overlay color. |
overlay-opacity | Number | 0.9 | The backdrop overlay opacity. |
show-counter | Boolean | true | Show or hide indicator counter. |
show-item-title | Boolean | true | Show or hide active item image title. |
show-nav-control | Boolean | true | Show or hide navigation controls. |
show-thumbnail | Boolean | true | Show or hide image thumbnails. |
show-toolbar | Boolean | true | Show or hide toolbar buttons. |
thumbnail-height | Number | 72 | Default image thumbnails height. |
toolbar | TLightboxToolbarItems | Configure the toolbar buttons. Defaults value: {'download': false, 'zoom': true, 'rotate': true, 'info': true, 'delete': true, 'menubar': false, 'close': true} | |
transition | String | 'slide-top-bottom' | Transition animation name when showing the active image. Available transitions are: fade , scale , slide-fade , slide-fade-reverse , slide-bottom-top , slide-top-bottom , slide-left-right , slide-right-left . |
transition-mode | String | Controls the timing sequence of leaving/entering transitions. Available modes are out-in and in-out . | |
z-index | Number | Insert inline css style z-index to control the component positioning on the html layers. v2.0.15 |
Name | Arguments | Description |
---|---|---|
change | ( activeItem:TImageDataset , newIndex:Number ) | Triggers when active item is changed. |
close | Triggers when Lightbox is closed. | |
exec-delete | ( item:TImageDataset ) | Triggers when button DELETE is clicked. |
exec-download | ( item:TImageDataset ) | Triggers when button DOWNLOAD is clicked. |
exec-info | ( item:TImageDataset ) | Triggers when button INFO is clicked. |
exec-rotate-left | ( item:TImageDataset , rotate:Number ) | Triggers when button ROTATE-LEFT is clicked. |
exec-rotate-right | ( item:TImageDataset , rotate:Number ) | Triggers when button ROTATE-RIGHT is clicked. |
exec-zoomin | ( item:TImageDataset , zoom:Number ) | Triggers when button ZOOM-IN is clicked. |
exec-zoomout | ( item:TImageDataset , zoom:Number ) | Triggers when button ZOOM-OUT is clicked. |
update:open | ( state:Boolean ) | Used to update the open property. |
Name | Description |
---|---|
menubar | The outlet slot used to place the toolbar button menus. |
Method | Description |
---|---|
setActive( index:Number ) | Change the active item. |
openAt( index:Number ) | Open modal lightbox at the given index. |
nextSlide() | Navigate slide at next to the active item. |
prevSlide() | Navigate slide at prior to the active item. |