Shopify themes, liquid, logos, and UX
Hi!
I want to make these variant options appear inline with their label so instead of 6 rows, It's just 3. Any idea how it can be done? Here's the image and code 🙂
<fieldset class="variant-picker__option no-js:hidden">
<div class="variant-picker__option-info">
<div class="h-stack gap-2">
<legend class="text-subdued">{{ option.name }}</legend>
</div>
{%- if hide_size_chart != true and block.settings.size_chart_page != blank and size_label_list contains option_downcase -%}
{%- capture drawer_id -%}size-chart-{{ section.id }}-{{ block.id }}{%- endcapture -%}
<button type="button" class="text-sm text-subdued" aria-controls="{{ drawer_id | escape }}" aria-expanded="false">
<span class="link">{{ 'product.general.size_chart' | t }}</span>
</button>
<x-drawer id="{{ drawer_id }}" class="drawer drawer--lg">
<span class="h5" sl ot="header">{{ block.settings.size_chart_page.title }}</span>
<div class="prose">
{{- block.settings.size_chart_page.content -}}
</div>
</x-drawer>
{%- endif -%}
</div>
{%- if selector_type == 'dropdown' -%}
{%- capture popover_id -%}popover-variant-picker-{{ section.id }}-{{ product.id }}-{{ option.position }}{%- endcapture -%}
<div class="relative">
<button type="button" class="select" aria-controls="{{ popover_id }}" aria-expanded="false">
<span id="{{ popover_id }}-selected-value">{{- option.selected_value -}}</span>
{%- render 'icon' with 'chevron-bottom', class: 'select-chevron' -%}
</button>
<x-popover id="{{ popover_id }}" class="popover" initial-focus="[aria-selected='true']" close-on-listbox-select anchor-horizontal="start" anchor-vertical="end">
<p class="h5" sl ot="title">{{ option.name }}</p>
<x-listbox data-option-selector class="popover-listbox" aria-owns="{{ popover_id }}-selected-value">
<input type="hidden" name="option{{ option.position }}" form="{{ form_id }}" value="{{ option.selected_value | escape }}">
{%- for value in option.values -%}
<button type="button" class="popover-listbox__option" role="option" value="{{ value | escape }}" {% if value == option.selected_value %}aria-selected="true"{% endif %} data-option-value>{{ value }}</button>
{%- endfor -%}
</x-listbox>
</x-popover>
</div>
{%- else -%}
<div {% unless block.settings.stack_blocks %}class="scroll-area bleed sm:unbleed"{% endunless %}>
<div data-option-selector class="variant-picker__option-values {% if block.settings.stack_blocks %}wrap{% else %}scroll-area bleed sm:unbleed{% endif %} {% if selector_type == 'color' and settings.color_swatch_style == 'rectangle' %}variant-picker__option-values--color gap-4{% else %}gap-2{% endif %}">
{%- assign name = 'option' | append: option.position -%}
{%- for value in option.values -%}
{%- assign selected = false -%}
{%- if value == option.selected_value -%}
{%- assign selected = true -%}
{%- endif -%}
{%- case selector_type -%}
{%- when 'variant' -%}
{%- assign variant_for_value = product.variants | where: name, value | first -%}
{%- render 'swatch' with 'media', value: value, media: variant_for_value.featured_media, selected: selected, name: name, form: form_id, bordered: true -%}
{%- when 'color' -%}
{%- render 'swatch' with 'color', value: value, selected: selected, name: name, form: form_id -%}
{%- when 'block' -%}
{%- render 'swatch' with 'block', value: value, selected: selected, name: name, form: form_id -%}
{%- when 'block_swatch' -%}
{%- render 'swatch' with 'block', value: value, selected: selected, name: name, form: form_id, show_color: true -%}
{%- endcase -%}
{%- endfor -%}
</div>
</div>
{%- endif -%}
</fieldset>
{%- endfor -%}
Solved! Go to the solution
This is an accepted solution.
Hey @Thehumblelone
Follow these Steps:
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code in the bottom of the file above </body> tag.
<style>
@media screen and (min-width: 768px) {
fieldset.variant-picker__option.no-js\:hidden {
display: flex !important;
align-items: center !important;
gap: 1.5rem !important;
}
}
</style>
RESULT:
If I managed to help you then, don't forget to Like it and Mark it as Solution!
Best Regards,
Moeed
Hey @Thehumblelone
Can you share your store url and password if enabled?
Best Regards,
Moeed
Hey @Thehumblelone
Follow these Steps:
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code in the bottom of the file above </body> tag.
<style>
@media screen and (min-width: 768px) {
.variant-picker__option-values.wrap.gap-2 {
width: 25% !important;
}
}
</style>
RESULT:
If I managed to help you then, don't forget to Like it and Mark it as Solution!
Best Regards,
Moeed
@Moeed Thanks for getting back to me. Unfortunately, I want to make the options in line with the labels. This image will clear things up.
This is an accepted solution.
Hey @Thehumblelone
Follow these Steps:
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code in the bottom of the file above </body> tag.
<style>
@media screen and (min-width: 768px) {
fieldset.variant-picker__option.no-js\:hidden {
display: flex !important;
align-items: center !important;
gap: 1.5rem !important;
}
}
</style>
RESULT:
If I managed to help you then, don't forget to Like it and Mark it as Solution!
Best Regards,
Moeed
Thanks man!
Thank you for your reply. I'm glad to hear that the solution worked well for you. If you require any more help, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated.
Do you mean like this?
If it is check this one.
From your Shopify admin dashboard, click on "Online Store" and then "Themes".
Find the theme that you want to edit and click on "Actions" and then "Edit code".
In the "Assets" folder, click on "base.css, style.css or theme.css" file, depending on which file your theme uses to store its CSS styles. At the bottom of the file, add the following CSS code:
variant-picker.variant-picker {
width: 20%;
}
And Save.
Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025