Making the variant options appear inline with their labels

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 :slightly_smiling_face:

{{ option.name }}

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

{{ 'product.general.size_chart' | t }} {{ block.settings.size_chart_page.title }}
{{- block.settings.size_chart_page.content -}}
{%- endif -%}

{%- if selector_type == ‘dropdown’ -%}
{%- capture popover_id -%}popover-variant-picker-{{ section.id }}-{{ product.id }}-{{ option.position }}{%- endcapture -%}

{{- option.selected_value -}} {%- render 'icon' with 'chevron-bottom', class: 'select-chevron' -%}

{{ option.name }}

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

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

{%- endif -%} {%- endfor -%}
1 Like

Hey @Thehumblelone

Can you share your store url and password if enabled?

Best Regards,

Moeed

Sure. Here’s the URL:

https://rhc9lbdzd4v3tqva-76889850174.shopifypreview.com

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 tag.

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.

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 tag.

RESULT:

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

Best Regards,
Moeed

1 Like

Hi @Thehumblelone

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!

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.