A media gallery displays a group of thumbnails in a gallery format, allowing users to preview and select different media.
Media galleries are ideal for showcasing multiple images or other media related to a single product or topic. They provide an interactive way to browse through content with thumbnail previews that update the primary display when selected.
When to use
When not to use
To use media gallery in a standalone component, import DAFF_MEDIA_GALLERY_COMPONENTS
into your custom component:
import { DAFF_MEDIA_GALLERY_COMPONENTS } from '@daffodil/design/media-gallery';
@Component({
selector: 'custom-component',
templateUrl: './custom-component.component.html',
imports: [
DAFF_MEDIA_GALLERY_COMPONENTS,
],
})
export class CustomComponent {}
To use media gallery in a module, import DaffMediaGalleryModule
into your custom module:
import { NgModule } from '@angular/core';
import { DaffMediaGalleryModule } from '@daffodil/design/media-gallery';
import { CustomComponent } from './custom.component';
@NgModule({
declarations: [
CustomComponent,
],
exports: [
CustomComponent,
],
imports: [
DaffMediaGalleryModule,
],
})
export class CustomComponentModule { }
This method is deprecated. It's recommended to update all custom components to standalone.
A media gallery consists of the following components:
<daff-media-gallery>
: The wrapper component that contains all thumbnails and manages the display area.
[daffThumbnail]
: A structural directive that defines both the preview image and the content to display when selected. Thumbnails can contain any content type, not just images.
<daff-media-gallery>
<ng-template daffThumbnail thumbnailSrc="/thumbnail-path.jpg" label="Your description">
<daff-image src="/image-path.jpg" alt="Your description" width="500" height="500"></daff-image>
</ng-template>
</daff-media-gallery>
thumbnailSrc
is used for the preview image rendered in the thumbnail strip.label
.isVideo
property can be used to display a video icon on the thumbnail.Never use
[daffThumbnail]
as a standalone element. It must be placed within a<daff-media-gallery>
.
Use a consistent aspect ratio across all content to avoid layout shifts. Mismatched content sizes can cause the primary content area to shift as different thumbnails are selected.
Thumbnails are rendered in a square by default, so a 1:1 ratio is recommended, but not required since thumbnails are automatically centered horizontally and vertically.
label
attribute.aria-controls
value that matches the id
of the content container displayed when the thumbnail is selected.id
values are autogenerated but can be overridden by providing a custom id to the <daff-media-gallery>
element.