<div x-ref="tagsSwiper" x-data="plpTags" class="swiper mx-0 md:-ml-5 md:pl-5 md:pr-5
md:before:absolute md:before:bg-gradient-to-l md:before:from-transparent md:before:left-0 md:before:w-5 md:before:h-full md:before:z-10 md:before:top-0
md:after:absolute md:after:bg-gradient-to-r md:after:from-transparent md:after:right-0 md:after:w-5 md:after:h-full md:after:z-10 md:after:top-0
md:before:to-white md:after:to-white overflow-visible md:overflow-hidden">
<div class="swiper-wrapper">
<div class="swiper-slide w-auto">
<a href="#" class=" btn btn-dark-ghost ">
Tag
</a>
</div>
<div class="swiper-slide w-auto">
<a href="#" class=" btn btn-dark-ghost ">
Tag
</a>
</div>
<div class="swiper-slide w-auto">
<a href="#" class=" btn btn-dark-ghost ">
Tag
</a>
</div>
<div class="swiper-slide w-auto">
<a href="#" class=" btn btn-dark-ghost ">
Tag
</a>
</div>
</div>
</div>
<script>
'use strict';
function plpTags() {
return {
swiper: {},
init() {
this.swiper = new Swiper(this.$refs.tagsSwiper, {
slidesPerView: 'auto',
spaceBetween: 8,
freeMode: true,
});
}
}
}
</script>
<div x-ref="tagsSwiper" x-data="plpTags" class="swiper mx-0 md:-ml-5 md:pl-5 md:pr-5
md:before:absolute md:before:bg-gradient-to-l md:before:from-transparent md:before:left-0 md:before:w-5 md:before:h-full md:before:z-10 md:before:top-0
md:after:absolute md:after:bg-gradient-to-r md:after:from-transparent md:after:right-0 md:after:w-5 md:after:h-full md:after:z-10 md:after:top-0
{{ container_classes|default('md:before:to-white md:after:to-white overflow-visible md:overflow-hidden') }}">
<div class="swiper-wrapper">
{% for tag in tags %}
<div class="swiper-slide w-auto">
{% render "@template-button" with tag|merge({color: color|default('dark') ~ '-ghost'}) %}
</div>
{% endfor %}
</div>
</div>
<script>
'use strict';
function plpTags() {
return {
swiper: {},
init() {
this.swiper = new Swiper(this.$refs.tagsSwiper, {
slidesPerView: 'auto',
spaceBetween: 8,
freeMode: true,
});
}
}
}
</script>
{
"tags": [
{
"label": "Tag",
"href": "#"
},
{
"label": "Tag",
"href": "#"
},
{
"label": "Tag",
"href": "#"
},
{
"label": "Tag",
"href": "#"
}
]
}
{% render "@tag-list" with {...} %}
tags: array
| default: []
@template-button
component. For more details on the structure of each item, see the @template-button documentation.color: string
| default: dark
-ghost
for a ghost-style effect).dark
, light
, audio
, etc.container_classes: string
| default: md:before:to-white md:after:to-white overflow-visible md:overflow-hidden
before
and after
elements.The Tag list
component displays a scrolling list of tags in swiper mode with stylized buttons. It uses the Swiper JavaScript library to provide smooth horizontal scrolling and dynamic tag display.
This component uses an Alpine.js function plpTags
to initialize the swiper and configure its options:
slidesPerView: 'auto'
: Displays tags based on their width.spaceBetween: 8
: Sets an 8-pixel space between each tag.freeMode: true
: Enables a free scrolling mode allowing users to scroll through tags without forced alignment.