Organisms

TsCarouselBuilder

Overview

The TsCarouselBuilder component is a Builder.io-specific dynamic carousel that enables drag-and-drop functionality for customizing each slide, offering seamless content management and flexible design.

Component Code

<template>
  <TsCarouselV2
      :id="`carousel-${random_id}`"
      :append-class="twMerge('px-0')"
      :prev-button-class="twMerge('left-0')"
      :next-button-class="twMerge('right-0')"
      :navigation="props.navigation || !isMobile"
      :pagination="props.pagination"
      :direction="props.direction"
      :loop="props.loop"
      :drag-free="props.dragFree"
      :autoplay="props.autoplay"
      :autoscroll="props.autoscroll"
  >
    <TsCarouselSlide
        v-for="(slide, index) in props.slides"
        :key="`carousel-slide-${random_id}-${index}`"
        :append-class="twMerge(
            'p-0 lg:p-0',
            props.slidesWidth === 'full' && 'w-full p-0 flex-[0_0_calc(100%/1)]',
            props.slidesWidth === 'auto' && 'flex-[0_0_auto] min-w-[280px] max-w-max',
            props.slidesGap === '8px' && 'p-1 lg:p-1'
        )"
    >
      <Blocks
          class="w-full h-full"
          :parent="props.builderBlock?.id"
          :path="`component.options.slides.${index}.content`"
          :blocks="slide.content"
      />
    </TsCarouselSlide>
  </TsCarouselV2>
</template>

<script setup lang="ts">
import { Blocks } from '@builder.io/sdk-vue';
import { twMerge } from "tailwind-merge";

type Slide = {
  content: any[]
}

type Props = {
  builderBlock?: object;
  slides?: Slide[];
  slidesWidth?: "auto" | "full";
  slidesGap?: string;
  direction?: "ltr" | "rtl";
  navigation?: boolean;
  pagination?: boolean;
  loop?: boolean;
  dragFree?: boolean;
  autoplay?: boolean;
  autoscroll?: boolean;
}

const props = withDefaults(defineProps<Props>(), {
  slidesWidth: "full",
  direction: "ltr",
  pagination: true
});

const { isMobile } = useDevice();

const random_id = ref('')

onMounted(() => {
  random_id.value = useRandomUUID()
})
</script>

Usage in Builder

  1. Go to the insert tab.
  2. Search Carousel in search bar.
  3. Hold Carousel component & drag where you want to use.
  4. Use any component and drag inside the Carousel Slides blocks in which you want to add.

Props

NameTypeDefaultDescription
builderBlockobject""builderBlock is used for builderBlock object which set by default when dragging TsCarouselBuilder in builder visual editor.
slidesSlide[]""Each slide have the content key which stores the draggable content of the specific slide
slidesWidthauto or full"full"auto adopt the max width of content added in slides automatically, full apply the 100% width to each slide
slidesGapstring""This is the property is used to add gap between slides, this have default value of 8px as a dropdown.
directionltr or rtl"ltr"ltr is used to add direction of carousel from left-to-right and rtl is used to add direction of carousel from right-to-left.
navigationbooleanfalsetoggle the visibility of navigation arrow.
paginationbooleantruetoggle the visibility of pagination dots.
loopbooleanfalsetoggle to enable or disable the loop of carousel
dragFreebooleanfalsetoggle the carousel slides drag free or not
autoplaybooleanfalsetoggle the autoplay feature of carousel
autoscrollbooleanfalsetoggle the autoscroll feature smoothly

Copyright © 2026