---
title: "Core"
description: "Use Blossom Carousel Core directly with DOM elements, lazy loading, and lifecycle cleanup."
canonical_url: "https://www.blossom-carousel.com/docs/framework-guides/core"
---

> Index of every page on this site: [llms.txt](https://www.blossom-carousel.com/llms.txt)

## Install

<code-group>

```bash [pnpm]
pnpm add @blossom-carousel/core
```

```bash [bun]
bun add @blossom-carousel/core
```

```bash [yarn]
yarn add @blossom-carousel/core
```

```bash [npm]
npm install @blossom-carousel/core
```

</code-group>

## Basic setup

```js
import { Blossom } from "@blossom-carousel/core";
import "@blossom-carousel/core/style.css";

const element = document.querySelector("#my-carousel-element");

if (element) {
  const blossom = Blossom(element);
  blossom.init();
}
```

## Lazy loading

Lazy load Blossom Carousel only on non-touch devices.

```js
const hasMouse = window.matchMedia(
  "(hover: hover) and (pointer: fine)",
).matches;

if (hasMouse) {
  const { Blossom } = await import("@blossom-carousel/core");
  const element = document.querySelector("#my-carousel-element");
  const blossom = Blossom(element);
  blossom.init();
}
```

## Options

`Blossom(element, options?)` accepts an optional second argument.

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        repeat
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Experimental looping mode. See the <a href="/docs/examples/experimental/repeat">
        Repeat example
      </a>
      
      .
    </td>
  </tr>
</tbody>
</table>

```js
const blossom = Blossom(element, { repeat: true });
```

<note color="neutral" icon="i-lucide-lightbulb">

Before `@blossom-carousel/core` 1.1.10, TypeScript required the second argument, so you had to pass `{}`.

</note>

## Methods

After `init()`, the instance can smooth-scroll to the previous or next snap point, or to the adjacent slide when nothing snaps:

```js
blossom.prev();
blossom.next({ align: "center" });
```

`align` accepts `"start"` (default), `"center"`, or `"end"`. When scroll snap is active, the slides' CSS `scroll-snap-align` is used instead and `align` is ignored.

These methods belong to the drag engine, so they aren't available when you skip loading it on touch devices. For controls that work everywhere, use the [Web Components](https://www.blossom-carousel.com/docs/framework-guides/web-components) or a framework package.

## Destroy

```js
blossom.destroy();
```

Call `destroy()` during route changes, component unmounting, or whenever the carousel root will be removed from the DOM.

## Overscroll API

Tap into Blossom's drag engine's overscroll behavior to create your own style.

```js
element.addEventListener("overscroll", (event) => {
  // prevent Blossom's default rubberbanding effect
  event.preventDefault();

  const overScroll = event.detail.left;

  Array.from(event.currentTarget.children).forEach((slide) => {
    slide.style.transform = `scale(${1 - overScroll * 0.1})`;
  });
});
```

## Sitemap

See the full [sitemap](https://www.blossom-carousel.com/sitemap.md) for all pages.
