Hi @swarique
copy/paste the code below and replace the whole code of this section: custom-collection-tabs.liquid
All your pointers are covered.
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-price.css' | asset_url | stylesheet_tag }}
{{ 'component-slider.css' | asset_url | stylesheet_tag }}
{{ 'template-collection.css' | asset_url | stylesheet_tag }}
{% if section.settings.image_shape == 'blob' %}
{{ 'mask-blobs.css' | asset_url | stylesheet_tag }}
{%- endif -%}
{%- unless section.settings.quick_add == 'none' -%}
{{ 'quick-add.css' | asset_url | stylesheet_tag }}
<script src="{{ 'product-form.js' | asset_url }}" defer="defer"></script>
{%- endunless -%}
{%- if section.settings.quick_add == 'standard' -%}
<script src="{{ 'quick-add.js' | asset_url }}" defer="defer"></script>
{%- endif -%}
{%- if section.settings.quick_add == 'bulk' -%}
<script src="{{ 'quick-add-bulk.js' | asset_url }}" defer="defer"></script>
<script src="{{ 'quantity-popover.js' | asset_url }}" defer="defer"></script>
<script src="{{ 'price-per-item.js' | asset_url }}" defer="defer"></script>
<script src="{{ 'quick-order-list.js' | asset_url }}" defer="defer"></script>
{%- endif -%}
{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}
@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
.tab-link-custom {
padding: 12px 24px;
border: 1px solid {{ section.settings.button_border_color }};
background: {{ section.settings.tab_btn_bg_color }};
color: {{ section.settings.tab_btn_color }};
cursor: pointer;
text-transform: uppercase;
font-size: 1.3rem;
letter-spacing: 0.1rem;
transition: all 0.3s ease;
}
.tab-link-custom.active {
background: {{ section.settings.tab_btn_bg_color_hover }};
color: {{ section.settings.tab_btn_color_hover }};
border-color: #000;
}
.tab-panel-custom {
animation: fadeInTabs 0.5s ease;
}
@keyframes fadeInTabs {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.button-row.center {
margin-top: 4rem;
}
@media screen and (min-width: 750px) and (max-width: 989px) {
.collection-tabs-container.page-width.mobile-layout-carousel {
padding: 0;
}
}
@media screen and (max-width: 749px) {
.mobile-layout-stacked .tabs-wrapper {
display: flex;
flex-direction: column;
gap: 10px;
}
.mobile-layout-stacked .tab-link-custom {
width: 100%;
}
.mobile-layout-flex .tabs-header {
justify-content: flex-start !important;
flex-wrap: nowrap !important;
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
scroll-snap-type: x mandatory;
gap: 10px;
padding-bottom: 5px;
}
.mobile-layout-flex .tab-link-custom {
flex: 0 0 auto;
white-space: nowrap;
scroll-snap-align: start;
}
.mobile-layout-flex .tabs-header::-webkit-scrollbar {
display: none;
}
.collection-tabs-container.page-width.mobile-layout-carousel {
padding-right: 0;
}
.mobile-layout-carousel .tabs-content ul {
margin-left: -1.5rem !important;
width: auto !important;
}
.mobile-layout-stacked .tabs-header.center {
margin-right: -1.5rem;
}
}
{%- endstyle -%}
<div class="collection-tabs-container page-width color-{{ section.settings.color_scheme }} gradient section-{{ section.id }}-padding mobile-layout-flex mobile-layout-{{ section.settings.mobile_layout }}" style="margin-top: 40px; margin-bottom: 40px;">
<h2 class="title inline-richtext h1 center" style="text-align: {{ section.settings.heading_alignment }};">
{{ section.settings.heading }}
</h2>
<div class="tabs-header center" style="display: flex; justify-content: center; gap: 10px; margin-bottom: 30px; flex-wrap: wrap;">
{% for block in section.blocks %}
<div class="tabs-wrapper">
<button
class="tab-link-custom {% if forloop.first %}active{% endif %}"
data-tab="tab-{{ block.id }}-{{ section.id }}"
>
{% if block.settings.title != blank %}
{{ block.settings.title }}
{% else %}
{{ block.settings.collection.title | default: 'Collection ' }}
{% endif %}
</button>
</div>
{% endfor %}
</div>
<div class="tabs-content">
{% for block in section.blocks %}
<div
id="tab-{{ block.id }}-{{ section.id }}"
class="tab-panel-custom"
style="{% if forloop.first %}display: block;{% else %}display: none;{% endif %}"
>
{% if section.settings.mobile_layout == 'carousel' %}
<slider-component class="slider-mobile-gutter">
{% endif %}
<ul
id="Slider-{{ block.id }}-{{ section.id }}"
class="grid product-grid contains-card contains-card--product grid--2-col-tablet-down grid--{{ section.settings.columns_desktop }}-col-desktop {% if section.settings.mobile_layout == 'carousel' %}slider slider--tablet grid--peek{% endif %}"
role="list"
aria-label="{{ 'general.slider.name' | t }}"
>
{%- if block.settings.collection != blank -%}
{%- for product in block.settings.collection.products limit: section.settings.columns_desktop -%}
<li class="grid__item {% if section.settings.mobile_layout == 'carousel' %}slider__slide{% endif %}">
{% render 'card-product',
card_product: product,
media_aspect_ratio: section.settings.image_ratio,
image_shape: section.settings.image_shape,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
section_id: section.id,
quick_add: section.settings.quick_add
%}
</li>
{%- endfor -%}
{%- else -%}
<p class="center">Please select a collection in the customizer.</p>
{%- endif -%}
</ul>
{% if section.settings.mobile_layout == 'carousel' %}
</slider-component>
{% endif %}
{% if block.settings.collection != blank and block.settings.collection.all_products_count > section.settings.columns_desktop %}
<div class="button-row center">
<a
href="{{ block.settings.collection.url }}"
class="button view-all-btn"
data-view="tab-{{ block.id }}-{{ section.id }}"
>
View All
</a>
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const tabs = document.querySelectorAll('.tab-link-custom');
tabs.forEach(tab => {
tab.addEventListener('click', function() {
const parent = this.closest('.collection-tabs-container');
const targetId = this.getAttribute('data-tab');
parent.querySelectorAll('.tab-link-custom').forEach(btn => {
btn.classList.remove('active');
});
this.classList.add('active');
parent.querySelectorAll('.tab-panel-custom').forEach(panel => {
panel.style.display = 'none';
});
document.getElementById(targetId).style.display = 'block';
});
});
});
</script>
{% schema %}
{
"name": "Custom Collection Tabs",
"settings": [
{
"type": "text",
"id": "heading",
"label": "Section Heading",
"default": "PALMONAS TOP STYLES"
},
{
"type": "select",
"id": "heading_alignment",
"label": "Heading Alignment",
"options": [
{
"value": "left",
"label": "Left"
},
{
"value": "center",
"label": "Center"
},
{
"value": "right",
"label": "Right"
}
],
"default": "left"
},
{
"type": "header",
"content": "t:sections.featured-collection.settings.header_collection.content"
},
{
"type": "range",
"id": "columns_desktop",
"min": 1,
"max": 4,
"step": 1,
"default": 4,
"label": "t:sections.featured-collection.settings.columns_desktop.label"
},
{
"type": "select",
"id": "image_ratio",
"options": [
{
"value": "adapt",
"label": "t:sections.featured-collection.settings.image_ratio.options__1.label"
},
{
"value": "portrait",
"label": "t:sections.featured-collection.settings.image_ratio.options__2.label"
},
{
"value": "square",
"label": "t:sections.featured-collection.settings.image_ratio.options__3.label"
}
],
"default": "adapt",
"label": "t:sections.featured-collection.settings.image_ratio.label"
},
{
"type": "select",
"id": "image_shape",
"options": [
{
"value": "default",
"label": "t:sections.all.image_shape.options__1.label"
},
{
"value": "arch",
"label": "t:sections.all.image_shape.options__2.label"
},
{
"value": "blob",
"label": "t:sections.all.image_shape.options__3.label"
},
{
"value": "chevronleft",
"label": "t:sections.all.image_shape.options__4.label"
},
{
"value": "chevronright",
"label": "t:sections.all.image_shape.options__5.label"
},
{
"value": "diamond",
"label": "t:sections.all.image_shape.options__6.label"
},
{
"value": "parallelogram",
"label": "t:sections.all.image_shape.options__7.label"
},
{
"value": "round",
"label": "t:sections.all.image_shape.options__8.label"
}
],
"default": "default",
"label": "t:sections.all.image_shape.label"
},
{
"type": "checkbox",
"id": "show_secondary_image",
"default": false,
"label": "t:sections.featured-collection.settings.show_secondary_image.label"
},
{
"type": "checkbox",
"id": "show_vendor",
"default": false,
"label": "t:sections.featured-collection.settings.show_vendor.label"
},
{
"type": "checkbox",
"id": "show_rating",
"default": false,
"label": "t:sections.featured-collection.settings.show_rating.label",
"info": "t:sections.featured-collection.settings.show_rating.info"
},
{
"type": "select",
"id": "quick_add",
"default": "none",
"label": "t:sections.main-collection-product-grid.settings.quick_add.label",
"options": [
{
"value": "none",
"label": "t:sections.main-collection-product-grid.settings.quick_add.options.option_1"
},
{
"value": "standard",
"label": "t:sections.main-collection-product-grid.settings.quick_add.options.option_2"
},
{
"value": "bulk",
"label": "t:sections.main-collection-product-grid.settings.quick_add.options.option_3"
}
]
},
{
"type": "header",
"content": "Set background and text color for tab button"
},
{
"type": "color",
"id": "tab_btn_bg_color",
"label": "Button Background Color"
},
{
"type": "color",
"id": "tab_btn_color",
"label": "Button Text Color"
},
{
"type": "color",
"id": "tab_btn_bg_color_hover",
"label": "Button Background Color (Active)"
},
{
"type": "color",
"id": "tab_btn_color_hover",
"label": "Button Text Color (Active)"
},
{
"type": "color",
"id": "button_border_color",
"label": "Button Border Color",
"default": "#000000"
},
{
"type": "color_scheme",
"id": "color_scheme",
"label": "t:sections.all.colors.label",
"default": "scheme-1"
},
{
"type": "header",
"content": "t:sections.all.padding.section_padding_heading"
},
{
"type": "range",
"id": "padding_top",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_top",
"default": 36
},
{
"type": "range",
"id": "padding_bottom",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_bottom",
"default": 36
},
{
"type": "select",
"id": "mobile_layout",
"label": "Mobile Layout",
"options": [
{
"value": "stacked",
"label": "Stacked"
},
{
"value": "carousel",
"label": "Carousel"
}
],
"default": "stacked"
}
],
"blocks": [
{
"type": "collection",
"name": "Collection Tab",
"limit": 8,
"settings": [
{
"type": "collection",
"id": "collection",
"label": "Select Collection"
},
{
"type": "text",
"id": "title",
"label": "Title"
}
]
}
],
"presets": [
{
"name": "Custom Collection Tabs"
}
]
}
{% endschema %}
Thanks