Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Vue3 Carousel 🎠


I couldn't make carousel to work shocked


<template>
<div id="kt_sliders_widget_1_slider" class="card card-flush carousel carousel-custom carousel-stretch slide h-250px"
data-bs-ride="carousel" data-bs-interval="1000">
<div class="card-header d-flex align-items-center justify-content-between flex-wrap"
>
<span class="text-gray-400 fs-4 fw-bolder pe-2" />
<ol class="p-0 m-0 carousel-indicators carousel-indicators-bullet carousel-indicators-active-primary">
<li data-bs-target="#kt_sliders_widget_1_slider" :data-bs-slide-to="index - 1" class="ms-1 "
:class="{ active: index - 1 == 0 }" aria-current="true" v-test-id=""item-dots"" v-for="index in messages.length"
:key="index - 1" />

</div>
<div class="card-body carousel-inner pt-2">
<div class="carousel-item " :class="{ "active show": index == 0 }" v-test-id=""items""
v-for="(message, index) in messages" :key="index">
<div class="m-0">
<span class="fs-4 text-dark fw-bolder text-hover-primary text-dark lh-base cursor-pointer">
{{ message.title }}
</span>
<div class="fw-bold fs-5 text-gray-600 text-dark mt-2 mb-5"
v-html="removeHtml(message.content).slice(0, 150).trim() + "..."" />
<span class="text-muted me-2 fs-7"
v-html="$t("phrases.message-send-at-by", { sendAt: message.sentAt, sentBy: message.author })" />
</div>
</div>
<div class="d-flex align-items-center justify-content-center min-h-95px" v-if="messages.length === 0"
v-test-id=""no-data"">
{{ $t("common.no-data") }}
</div>
</div>
</div>
</template>


<script lang="ts">
import { defineComponent, PropType } from "vue"
import { Message } from "@support/core/types"

export default defineComponent({
props: {
messages: {
type: Array as PropType<Array<Message>>,
required: true
},
device: {
type: String,
required: true,
default: "web:desktop"
},
storyMode: {
type: Boolean as PropType<boolean>,
required: false,
default: false
}
},
setup (props, { emit }) {
....
}

})
</script>



<style>
.carousel.carousel-custom .carousel-indicators {
align-items: center;
position: static;
z-index: auto;
margin: 0;
padding: 0;
list-style: none;
}

.carousel.carousel-custom .carousel-indicators.carousel-indicators-bullet li.active {
transition: all 0.3s ease;
background-color: #33589E;
height: 6px;
width: 16px;
}

.carousel.carousel-custom .carousel-indicators.carousel-indicators-bullet li {
transition: all 0.3s ease;
background-color: #D9D9D9;
border-radius: 6px;
height: 6px;
width: 6px;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
}

.carousel.carousel-custom .carousel-indicators li {
transform: none;
opacity: 1;
}

.carousel-indicators [data-bs-target] {
box-sizing: content-box;
flex: 0 1 auto;
width: 30px;
height: 3px;
padding: 0;
margin-right: 3px;
margin-left: 3px;
text-indent: -999px;
cursor: pointer;
background-color: #ffffff;
background-clip: padding-box;
border: 0 !important;
border-top-color: currentcolor;
border-top-style: none;
border-top-width: 0px;
border-bottom-color: currentcolor;
border-bottom-style: none;
border-bottom-width: 0px;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
opacity: 0.5;
transition: opacity 0.6s ease;
}
</style>


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (8)


I should say only that its awesome! The blog is informational and always produce amazing things. aitelephone.com



These websites are really needed, you can learn a lot. Lakeland Pest Control



This content is simply exciting and creative. I have been deciding on a institutional move and this has helped me with one aspect. Oviedo Termite Treatment



Within this webpage, you'll see the page, you need to understand this data. Orlando Bed Bug Treatment



I prefer merely excellent resources - you will see these people in: Kissimmee Pest Control



Hi,

Thank you for contacting our support.

From the first look your carousel code looks fine, could you please verify that your indexes in attribute data-bs-slide-to are generated correctly?

You can find Bootstrap 5 carousel usage examples in our doc.
https://preview.keenthemes.com/metronic8/vue/docs/#/carousel

Also, for more usage examples, check out Bootstrap 5 official doc.


Regards,



v-for="index in messages.length"
here index starts from 1 so i have to subtract one

<ol class="p-0 m-0 carousel-indicators carousel-indicators-bullet carousel-indicators-active-primary">
<li data-bs-target="#kt_sliders_widget_1_slider" data-bs-slide-to="0" class="ms-1 active" aria-current="true" data-test>
<li data-bs-target="#kt_sliders_widget_1_slider" data-bs-slide-to="1" class="ms-1" aria-current="true" data-test>
<li data-bs-target="#kt_sliders_widget_1_slider" data-bs-slide-to="2" class="ms-1" aria-current="true" data-test>
<li data-bs-target="#kt_sliders_widget_1_slider" data-bs-slide-to="3" class="ms-1" aria-current="true" data-test>
<li data-bs-target="#kt_sliders_widget_1_slider" data-bs-slide-to="4" class="ms-1" aria-current="true" data-test>


Hi,

Does carousel work now?

Also, please check your console for errors.

Regards,
Lauris Stepanovs,
Keenthemes Support Team


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(