Bento

Bento Inline Gallery

<head>

    <script
      type="module"
      async
      src="https://cdn.ampproject.org/bento.mjs"
    ></script>
    <script nomodule src="https://cdn.ampproject.org/bento.js"></script>
    <script
      type="module"
      async
      src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.mjs"
    ></script>
    <script
      nomodule
      async
      src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.js"
    ></script>
    <link
      rel="stylesheet"
      href="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.css"
    />
    <script
      type="module"
      async
      src="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.mjs"
    ></script>
    <script
      nomodule
      async
      src="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.js"
    ></script>
    <link
      rel="stylesheet"
      href="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.css"
    />
</head>

<body>

    <bento-inline-gallery id="inline-gallery">
      <bento-inline-gallery-thumbnails
        style="height: 100px"
        loop
      ></bento-inline-gallery-thumbnails>
      <bento-base-carousel
        style="height: 200px"
        snap-align="center"
        visible-count="3"
        loop
      >
        <img
          src="https://picsum.photos/id/237/640/480"
          data-thumbnail-src="https://picsum.photos/id/237/64/48"
        />
        <img
          src="https://picsum.photos/id/238/640/480"
          data-thumbnail-src="https://picsum.photos/id/238/64/48"
        />
        <img
          src="https://picsum.photos/id/239/640/480"
          data-thumbnail-src="https://picsum.photos/id/239/64/48"
        />
        <img
          src="https://picsum.photos/id/240/640/480"
          data-thumbnail-src="https://picsum.photos/id/240/64/48"
        />
        <img
          src="https://picsum.photos/id/241/640/480"
          data-thumbnail-src="https://picsum.photos/id/241/64/48"
        />
        <img
          src="https://picsum.photos/id/242/640/480"
          data-thumbnail-src="https://picsum.photos/id/242/64/48"
        />
      </bento-base-carousel>
      <bento-inline-gallery-pagination
        style="height: 20px"
      ></bento-inline-gallery-pagination>
    </bento-inline-gallery>
</body>

Displays slides, with optional pagination dots and thumbnails. Its implementation uses a Bento Base Carousel. Both components must be properly installed for the environment (Web Component vs Preact).

Use bento-inline-gallery as a web component or a React functional component:

↓ Web Component ↓ React / Preact

Web Component

You must include each Bento component's required CSS library to guarantee proper loading and before adding custom styles. Or use the light-weight pre-upgrade styles available inline. See Layout and style.

Import via npm

npm install @bentoproject/inline-gallery
import {defineElement as defineBentoInlineGallery} from '@bentoproject/inline-gallery';
defineBentoInlineGallery();

Include via <script>

<script type="module" src="https://cdn.ampproject.org/bento.mjs" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.ampproject.org/bento.js" crossorigin="anonymous"></script>
<script type="module" src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.mjs" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.css" crossorigin="anonymous">

Example

<head>

<script
      type="module"
      async
      src="https://cdn.ampproject.org/bento.mjs"
    ></script>
    <script nomodule src="https://cdn.ampproject.org/bento.js"></script>

    <script
      type="module"
      async
      src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.mjs"
    ></script>
    <script
      nomodule
      async
      src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.js"
    ></script>
    <link
      rel="stylesheet"
      href="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.css"
    />

    <script
      type="module"
      async
      src="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.mjs"
    ></script>
    <script
      nomodule
      async
      src="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.js"
    ></script>
    <link
      rel="stylesheet"
      href="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.css"
    />
</head>

<body>

<bento-inline-gallery id="inline-gallery">
      <bento-inline-gallery-thumbnails
        style="height: 100px"
        loop
      ></bento-inline-gallery-thumbnails>

      <bento-base-carousel
        style="height: 200px"
        snap-align="center"
        visible-count="3"
        loop
      >
        <img src="img1.jpeg" data-thumbnail-src="img1-thumbnail.jpeg" />
        <img src="img2.jpeg" data-thumbnail-src="img2-thumbnail.jpeg" />
        <img src="img3.jpeg" data-thumbnail-src="img3-thumbnail.jpeg" />
        <img src="img4.jpeg" data-thumbnail-src="img4-thumbnail.jpeg" />
        <img src="img5.jpeg" data-thumbnail-src="img5-thumbnail.jpeg" />
        <img src="img6.jpeg" data-thumbnail-src="img6-thumbnail.jpeg" />
      </bento-base-carousel>

      <bento-inline-gallery-pagination
        style="height: 20px"
      ></bento-inline-gallery-pagination>
    </bento-inline-gallery>
</body>

Layout and style

Each Bento component has a small CSS library you must include to guarantee proper loading without content shifts. Because of order-based specificity, you must manually ensure that stylesheets are included before any custom styles.

<link
rel="stylesheet"
type="text/css"
href="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.css"
/>

Alternatively, you may also make the light-weight pre-upgrade styles available inline:

<style>
bento-inline-gallery,
bento-inline-gallery-pagination,
bento-inline-gallery-thumbnails
{
display: block;
}
bento-inline-gallery {
contain: layout;
}
bento-inline-gallery-pagination,
bento-inline-gallery-thumbnails
{
overflow: hidden;
position: relative;
}
</style>

inset

Boolean attribute indicating whether to display the pagination indicator as inset (overlaying the carousel itself). Default is false.

aspect-ratio

A Number defining the ratio of width to height that slides should be displayed in. This value is optional.

loop

Boolean attribute indicating whether thumbnails should loop. The default is false.

Styling

You may use the bento-inline-gallery, bento-inline-gallery-pagination, bento-inline-gallery-thumbnails, and bento-base-carousel element selectors to style the pagination indicator, thumbnails, and carousel freely.


Preact/React Component

Import via npm

npm install @bentoproject/inline-gallery
import React from 'react';
import {BentoInlineGallery} from '@bentoproject/inline-gallery/react';
import '@bentoproject/inline-gallery/styles.css';

function App() {
return (
<BentoInlineGallery id="inline-gallery">
<BentoInlineGalleryThumbnails aspect-ratio="1.5" loop />
<BentoBaseCarousel snap-align="center" visible-count="1.2" loop>
<img src="server.com/static/inline-examples/images/image1.jpg" />
<img src="server.com/static/inline-examples/images/image2.jpg" />
<img src="server.com/static/inline-examples/images/image3.jpg" />
</BentoBaseCarousel>
<BentoInlineGalleryPagination inset />
</BentoInlineGallery>
);
}

Layout and style

Container type

The BentoInlineGallery component has a defined layout size type. To ensure the component renders correctly, be sure to apply a size to the component and its immediate children via a desired CSS layout (such as one defined with width). These can be applied inline:

<BentoInlineGallery style={{width: 300}}>...</BentoInlineGallery>

Or via className:

<BentoInlineGallery className="custom-styles">...</BentoInlineGallery>
.custom-styles {
background-color: red;
}

Props for BentoInlineGalleryPagination

In addition to the common props, BentoInlineGalleryPagination supports the props below:

inset

Boolean attribute indicating whether to display the pagination indicator as inset (overlaying the carousel itself). Default is false.

Props for BentoInlineGalleryThumbnails

In addition to the common props, BentoInlineGalleryThumbnails supports the props below:

aspectRatio

A Number defining the ratio of width to height that slides should be displayed in (this is optional).

loop

Boolean attribute indicating whether thumbnails should loop. Default is false.

More details