Re: Making the variant options appear inline with their labels

Solved

Making the variant options appear inline with their labels

Thehumblelone
Shopify Partner
48 0 5

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 🙂

screenshot-renewellcleaners.com-2024.05.02-23_12_34.png


<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 -%}

 

Accepted Solution (1)
Moeed
Shopify Partner
6533 1774 2146

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:

Moeed_0-1714678980627.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


View solution in original post

Replies 8 (8)

Moeed
Shopify Partner
6533 1774 2146

Hey @Thehumblelone 

 

Can you share your store url and password if enabled?

 

Best Regards,

Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


Thehumblelone
Shopify Partner
48 0 5
Moeed
Shopify Partner
6533 1774 2146

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:

Moeed_0-1714677282333.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

 

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


Thehumblelone
Shopify Partner
48 0 5

@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.
screenshot-renewellcleaners.com-2024.05.03-00_38_22.png

Moeed
Shopify Partner
6533 1774 2146

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:

Moeed_0-1714678980627.png

 

If I managed to help you then, don't forget to Like it and Mark it as Solution!

 

Best Regards,
Moeed

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


Thehumblelone
Shopify Partner
48 0 5

Thanks man! 

Moeed
Shopify Partner
6533 1774 2146

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.

- Need a Shopify Specialist? Chat on WhatsApp

- Get a quick Shopify quote – Click here!

- Custom Design | Advanced Coding | Store Modifications


Made4uo-Ribe
Shopify Partner
9567 2279 2828

Hi @Thehumblelone 

Do you mean like this? 

Made4uoRibe_0-1714679866653.png

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!

If this fixed your issue, Likes and Accept as Solution are highly appreciated. Coffee tips fuel my dedication.
Get experienced Shopify developers at affordable rates—visit Made4Uo.com for a quick quote!
Need THEME UPDATES but have custom codes? No worries, for an affordable price.
Create custom Shopify pages effortlessly with PageFly's drag-and-drop ⚙️.