Skip to main content

Arrow

Adds arrow navigation buttons to move to the previous/next panel.

import Flicking from "@egjs/flicking";
import { Arrow } from "@egjs/flicking-plugins";
import "@egjs/flicking/dist/flicking.css";
import "@egjs/flicking-plugins/dist/arrow.css";
import "./styles.css";

const COLORS = ["#e74c3c", "#3498db", "#2ecc71", "#f39c12", "#9b59b6"];

const camera = document.querySelector(".flicking-camera");
COLORS.forEach((color, i) => {
  const panel = document.createElement("div");
  panel.className = "flicking-panel";
  panel.style.background = color;
  panel.textContent = i + 1;
  camera.appendChild(panel);
});

const flicking = new Flicking("#flick", {
  circular: true
});

flicking.addPlugins(new Arrow());

Summary

Key Options

OptionTypeDefaultDescription
parentElHTMLElement-Parent element for the arrow buttons. By default, placed inside the viewport

Required CSS

import "@egjs/flicking-plugins/dist/arrow.css";

Details

How It Works

The Arrow plugin finds elements with the .flicking-arrow-prev and .flicking-arrow-next classes and binds click events to move to the previous/next panel.

HTML Structure

Arrow elements must be placed inside the viewport.

<div class="flicking-viewport">
<div class="flicking-camera">
<!-- Panels -->
</div>
<span class="flicking-arrow-prev"></span>
<span class="flicking-arrow-next"></span>
</div>

Framework-specific Usage

React — Use ViewportSlot to place arrows inside the viewport:

<Flicking plugins={plugins}>
{/* Panels */}
<ViewportSlot>
<span className="flicking-arrow-prev"></span>
<span className="flicking-arrow-next"></span>
</ViewportSlot>
</Flicking>

Vue — Use the #viewport slot:

<Flicking :plugins="plugins">
<!-- Panels -->
<template #viewport>
<span class="flicking-arrow-prev"></span>
<span class="flicking-arrow-next"></span>
</template>
</Flicking>

Notes

Caution
  • You must import @egjs/flicking-plugins/dist/arrow.css for the arrows to display correctly.
  • Arrow elements must be located inside .flicking-viewport.