Utility bar editing changes

Hi,

I am using TASTE theme and want to modify the utility bar above the header.

Url:https://handshere.com

Currently looks likes this:

I want it to look like this:

It already has some custom code in the “announcement-bar.liquid” file:

<div

class=“utility-bar color-{{ section.settings.color_scheme }} gradient{% if section.settings.show_line_separator and section.blocks.size > 0 %} utility-bar–bottom-border{% elsif section.settings.show_line_separator and section.settings.show_social and social_icons%} utility-bar–bottom-border-social-only{% endif %}{% if section.settings.enable_country_selector or section.settings.enable_language_selector %} header-localization{% endif %}”

{{ block.shopify_attributes }}

>

{{ section.settings.text }}
<img src="{{ 'afterpay-logo.png' | asset_url }}" alt="Afterpay" style="height: 20px; margin-left: 0px;">

<img src="{{ 'paypal-logo.png' | asset_url }}" alt="PayPal" style="height: 20px; margin-left: 0px;">

<img src="{{ 'apple-pay-logo.png' | asset_url }}" alt="ApplePay" style="height: 20px; margin-left: 10px;">

<img src="{{ 'google-pay.png' | asset_url }}" alt="GooglePay" style="height: 20px; margin-left: 10px;">

Any help to change this and also be able to edit the font size and weight would be great, thanks!!

PS I have already read a number of posted announcements about this topic and can’t find a solution

Hey @HH_2023,

Instead of sharing the small part of the announcement bar, can you please share the whole file of announcement bar.

This will help me to provide you exact solution. As the require changes required theme customization.

Hi @HH_2023

Replace your current section code with this version:

<div
  class="utility-bar color-{{ section.settings.color_scheme }} gradient
    {% if section.settings.show_line_separator and section.blocks.size > 0 %}
      utility-bar--bottom-border
    {% elsif section.settings.show_line_separator and section.settings.show_social and social_icons %}
      utility-bar--bottom-border-social-only
    {% endif %}
    {% if section.settings.enable_country_selector or section.settings.enable_language_selector %}
      header-localization
    {% endif %}"
>

  <div class="utility-bar__inner">
    <span class="utility-bar__text" style="
      font-size: {{ section.settings.font_size }}px;
      font-weight: {{ section.settings.font_weight }};
    ">
      {{ section.settings.text }}
    </span>

    <div class="utility-bar__icons">
      <img src="{{ 'afterpay-logo.png' | asset_url }}" alt="Afterpay">
      <img src="{{ 'paypal-logo.png' | asset_url }}" alt="PayPal">
      <img src="{{ 'apple-pay-logo.png' | asset_url }}" alt="Apple Pay">
      <img src="{{ 'google-pay.png' | asset_url }}" alt="Google Pay">
    </div>
  </div>

</div>

2. Add CSS so the icons align properly

Add this to base.css:

.utility-bar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.utility-bar__icons img {
  height: 20px;
  margin-left: 10px;
}

3. Make font size and weight editable in Theme Editor

Inside your section schema, add:

{
  "type": "range",
  "id": "font_size",
  "label": "Font size",
  "min": 10,
  "max": 30,
  "default": 14
},
{
  "type": "select",
  "id": "font_weight",
  "label": "Font weight",
  "options": [
    { "value": "300", "label": "Light" },
    { "value": "400", "label": "Regular" },
    { "value": "600", "label": "Semi-bold" },
    { "value": "700", "label": "Bold" }
  ],
  "default": "600"
}

Best regards,
Devcoder :laptop:

In TASTE, the easiest way to get that “text on the left + payment icons on the right” layout is to wrap them in two containers and use flex on the parent (instead of keeping everything inline).

Update your announcement-bar.liquid output to this:

<div class="utility-bar__inner">
  <div class="utility-bar__left">
    {{ section.settings.text }}
  </div>

  <div class="utility-bar__right">
    <img src="{{ 'afterpay-logo.png' | asset_url }}" alt="Afterpay">
    <img src="{{ 'paypal-logo.png' | asset_url }}" alt="PayPal">
    <img src="{{ 'apple-pay-logo.png' | asset_url }}" alt="Apple Pay">
    <img src="{{ 'google-pay.png' | asset_url }}" alt="Apple Pay">
  </div>
</div>

Then add this to your CSS (base.css/theme.css):

.utility-bar__inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 0 16px;
}

.utility-bar__left{
  font-size:14px;     /* adjust as needed */
  font-weight:600;    /* adjust as needed */
}

.utility-bar__right{
  display:flex;
  align-items:center;
  gap:10px;
}

.utility-bar__right img{
  height:20px;
  width:auto;
  display:block;
}

That will keep the message on the left and the icons grouped on the right, similar to your example. Font size and weight can be controlled from the .utility-bar__left rules.

If you can share the section schema area from the bottom of announcement-bar.liquid, I can show exactly how to make the font size/weight editable from the Theme Editor.

Hello @HH_2023,

I am sharing the complete code with you. In this implementation, I have created settings for top, bottom, left, and right spacing, along with font size, font weight, and alignment options.

After reviewing the Kids Secret announcement bar, I also created a separate mobile text block. This ensures that on mobile devices, only the mobile-specific text is displayed, and the desktop text is hidden.

You only need to add the code and update the text and images as per your requirements.

{%- style -%}

.announcement-bar-{{ section.id }} {

  background-color: {{ section.settings.background_color }};

  color: {{ section.settings.text_color }};

  padding: {{ section.settings.padding_top }}px {{ section.settings.padding_horizontal }}px {{ section.settings.padding_bottom }}px;

  font-size: {{ section.settings.font_size }}px;

  font-weight: {{ section.settings.font_weight }};

}



.announcement-bar__wrapper.page-width {

  width: 100%;

}

.announcement-bar-{{ section.id }} .announcement-bar__content {

  display: flex;

  align-items: center;

  justify-content: {{ section.settings.alignment }};

  gap: {{ section.settings.block_spacing }}px;

  overflow: visible;

}



.announcement-bar-{{ section.id }} .announcement-bar__block {

  display: flex;

  align-items: center;

  gap: 15px;

  flex-shrink: 0;

  white-space: nowrap;

}



.announcement-bar-{{ section.id }} .announcement-bar__text {

  font-size: {{ section.settings.font_size }}px;

  font-weight: {{ section.settings.font_weight }};

  margin: 0;

  line-height: 1.4;

}



.announcement-bar-{{ section.id }} .announcement-bar__image-block {

  display: flex;

  align-items: center;

  gap: 10px;

}



.announcement-bar-{{ section.id }} .announcement-bar__image {

  height: {{ section.settings.image_height }}px;

  width: auto;

  object-fit: contain;

}



/\* Mobile visibility \*/

@media screen and (max-width: 749px) {

  .announcement-bar-{{ section.id }} .announcement-bar__block--text {

    display: none !important;

  }



  .announcement-bar-{{ section.id }} .announcement-bar__block--mobile-text {

    display: flex !important;

  }

}



@media screen and (min-width: 750px) {

  .announcement-bar-{{ section.id }} .announcement-bar__block--mobile-text {

    display: none !important;

  }



  .announcement-bar-{{ section.id }} .announcement-bar__content {

    flex-wrap: wrap;

    justify-content: {{ section.settings.alignment }};

  }

}

{%- endstyle -%}

<div class="announcement-bar__content">

  {%- for block in section.blocks -%}

    {%- case block.type -%}

      {%- when 'text' -%}

        <div class="announcement-bar__block announcement-bar__block--text" {{ block.shopify_attributes }}>

          <p

            class="announcement-bar__text"

            style="font-size: {{ block.settings.font_size }}px; font-weight: {{ block.settings.font_weight }};"

          >

            {{ block.settings.text }}

          </p>

        </div>

      {%- when 'mobile_text' -%}

        <div class="announcement-bar__block announcement-bar__block--mobile-text" {{ block.shopify_attributes }}>

          <p

            class="announcement-bar__text"

            style="font-size: {{ block.settings.font_size }}px; font-weight: {{ block.settings.font_weight }};"

          >

            {{ block.settings.text }}

          </p>

        </div>

      {%- when 'images' -%}

        <div class="announcement-bar__block announcement-bar__block--images" {{ block.shopify_attributes }}>

          <div class="announcement-bar__image-block">

            {%- if block.settings.image_1 != blank -%}

              <img

                src="{{ block.settings.image_1 | image_url: width: 200 }}"

                alt="{{ block.settings.image_1.alt | escape }}"

                class="announcement-bar__image"

                loading="lazy"

                width="{{ block.settings.image_1.width }}"

                height="{{ block.settings.image_1.height }}"

              >

            {%- endif -%}

            {%- if block.settings.image_2 != blank -%}

              <img

                src="{{ block.settings.image_2 | image_url: width: 200 }}"

                alt="{{ block.settings.image_2.alt | escape }}"

                class="announcement-bar__image"

                loading="lazy"

                width="{{ block.settings.image_2.width }}"

                height="{{ block.settings.image_2.height }}"

              >

            {%- endif -%}

          </div>

        </div>

    {%- endcase -%}

  {%- endfor -%}

</div>

{% schema %}

{

“name”: “Announcement Bar New”,

“tag”: “section”,

“class”: “section-announcement-bar”,

“settings”: [

{

  "type": "header",

  "content": "Style Settings"

},

{

  "type": "color",

  "id": "background_color",

  "label": "Background Color",

  "default": "#2c2c2c"

},

{

  "type": "color",

  "id": "text_color",

  "label": "Text Color",

  "default": "#ffffff"

},

{

  "type": "range",

  "id": "padding_top",

  "min": 0,

  "max": 50,

  "step": 2,

  "unit": "px",

  "label": "Padding Top",

  "default": 12

},

{

  "type": "range",

  "id": "padding_bottom",

  "min": 0,

  "max": 50,

  "step": 2,

  "unit": "px",

  "label": "Padding Bottom",

  "default": 12

},

{

  "type": "range",

  "id": "padding_horizontal",

  "min": 0,

  "max": 100,

  "step": 5,

  "unit": "px",

  "label": "Padding Horizontal",

  "default": 20

},

{

  "type": "range",

  "id": "font_size",

  "min": 10,

  "max": 24,

  "step": 1,

  "unit": "px",

  "label": "Default Font Size",

  "default": 14,

  "info": "Default font size for all blocks. Can be overridden per block."

},

{

  "type": "select",

  "id": "font_weight",

  "label": "Default Font Weight",

  "default": "400",

  "options": \[

    {

      "value": "400",

      "label": "Regular"

    },

    {

      "value": "700",

      "label": "Bold"

    }

  \]

},

{

  "type": "select",

  "id": "alignment",

  "label": "Content Alignment",

  "default": "space-between",

  "options": \[

    {

      "value": "flex-start",

      "label": "Left"

    },

    {

      "value": "center",

      "label": "Center"

    },

    {

      "value": "flex-end",

      "label": "Right"

    },

    {

      "value": "space-between",

      "label": "Space Between"

    }

  \]

},

{

  "type": "range",

  "id": "block_spacing",

  "min": 0,

  "max": 100,

  "step": 5,

  "unit": "px",

  "label": "Block Spacing",

  "default": 30

},

{

  "type": "range",

  "id": "image_height",

  "min": 16,

  "max": 80,

  "step": 2,

  "unit": "px",

  "label": "Image Height",

  "default": 24

}

],

“blocks”: [

{

  "type": "text",

  "name": "Text Block",

  "settings": \[

    {

      "type": "textarea",

      "id": "text",

      "label": "Text",

      "default": "Enter your announcement text here"

    },

    {

      "type": "range",

      "id": "font_size",

      "min": 10,

      "max": 24,

      "step": 1,

      "unit": "px",

      "label": "Font Size",

      "default": 14

    },

    {

      "type": "select",

      "id": "font_weight",

      "label": "Font Weight",

      "default": "400",

      "options": \[

        {

          "value": "400",

          "label": "Regular"

        },

        {

          "value": "700",

          "label": "Bold"

        }

      \]

    }

  \]

},

{

  "type": "images",

  "name": "Images Block",

  "settings": \[

    {

      "type": "image_picker",

      "id": "image_1",

      "label": "Image 1"

    },

    {

      "type": "image_picker",

      "id": "image_2",

      "label": "Image 2"

    }

  \]

},

{

  "type": "mobile_text",

  "name": "Mobile Text Block",

  "settings": \[

    {

      "type": "textarea",

      "id": "text",

      "label": "Mobile Text",

      "default": "Enter your mobile announcement text here",

      "info": "This text will only be visible on mobile devices. Regular text and image blocks will be hidden on mobile."

    },

    {

      "type": "range",

      "id": "font_size",

      "min": 10,

      "max": 24,

      "step": 1,

      "unit": "px",

      "label": "Font Size",

      "default": 14

    },

    {

      "type": "select",

      "id": "font_weight",

      "label": "Font Weight",

      "default": "400",

      "options": \[

        {

          "value": "400",

          "label": "Regular"

        },

        {

          "value": "700",

          "label": "Bold"

        }

      \]

    }

  \]

}

],

“presets”: [

{

  "name": "Announcement Bar New",

  "blocks": \[

    {

      "type": "text",

      "settings": {

        "text": "30-Day Returns"

      }

    },

    {

      "type": "text",

      "settings": {

        "text": "Free shipping Australia-wide over $150"

      }

    },

    {

      "type": "images",

      "settings": {}

    },

    {

      "type": "mobile_text",

      "settings": {

        "text": "Free shipping over $150"

      }

    }

  \]

}

]

}

{% endschema %}

Please review and let me know if any changes are needed.
Thanks.

No worries, here is the whole announcement-bar.liquid file

{{ ‘component-slideshow.css’ | asset_url | stylesheet_tag }}

{{ ‘component-slider.css’ | asset_url | stylesheet_tag }}

{%- liquid

assign social_icons = true

if settings.social_facebook_link == blank and settings.social_instagram_link == blank and settings.social_youtube_link == blank and settings.social_tiktok_link == blank and settings.social_twitter_link == blank and settings.social_pinterest_link == blank and settings.social_snapchat_link == blank and settings.social_tumblr_link == blank and settings.social_vimeo_link == blank

assign social_icons = false

endif

if section.settings.enable_country_selector or section.settings.enable_language_selector

assign language_country_selector = true

endif

if section.blocks.size > 0

assign announcement_bar = true

endif

-%}

{% if social_icons %}

{{ ‘component-list-social.css’ | asset_url | stylesheet_tag }}

{% endif %}

<div

class=“utility-bar color-{{ section.settings.color_scheme }} gradient{% if section.settings.show_line_separator and section.blocks.size > 0 %} utility-bar–bottom-border{% elsif section.settings.show_line_separator and section.settings.show_social and social_icons%} utility-bar–bottom-border-social-only{% endif %}{% if section.settings.enable_country_selector or section.settings.enable_language_selector %} header-localization{% endif %}”

{{ block.shopify_attributes }}

>

{{ section.settings.text }}
<img src="{{ 'afterpay-logo.png' | asset_url }}" alt="Afterpay" style="height: 20px; margin-left: 0px;">

<img src="{{ 'paypal-logo.png' | asset_url }}" alt="PayPal" style="height: 20px; margin-left: 0px;">

<img src="{{ 'apple-pay-logo.png' | asset_url }}" alt="ApplePay" style="height: 20px; margin-left: 10px;">

<img src="{{ 'google-pay.png' | asset_url }}" alt="GooglePay" style="height: 20px; margin-left: 10px;">
{%- if section.settings.show_social and social_icons -%}

  {%- render 'social-icons' -%}

{%- endif -%}

{%- if section.blocks.size == 1 -%}

  <div

    class="announcement-bar{% if section.settings.show_social %} announcement-bar--one-announcement{% endif %}"

    role="region"

    aria-label="{{ 'sections.header.announcement' | t }}"

    {{ block.shopify_attributes }}

  >

    {%- if section.blocks.first.settings.text != blank -%}

      {%- if section.blocks.first.settings.link != blank -%}

        <a

          href="{{ section.blocks.first.settings.link }}"

          class="announcement-bar__link link link--text focus-inset animate-arrow"

        >

      {%- endif -%}

      <p class="announcement-bar__message h3">

        <span>{{ section.blocks.first.settings.text | escape }}</span>

        {%- if section.blocks.first.settings.link != blank -%}

          {{- 'icon-arrow.svg' | inline_asset_content -}}

        {%- endif -%}

      </p>

      {%- if section.blocks.first.settings.link != blank -%}

        </a>

      {%- endif -%}

    {%- endif -%}

  </div>

{%- elsif section.blocks.size > 1 -%}

  <slideshow-component

    class="announcement-bar"

    role="region"

    aria-roledescription="{{ 'sections.announcements.carousel' | t }}"

    aria-label="{{ 'sections.announcements.announcement_bar' | t }}"

  >

    <div class="announcement-bar-slider slider-buttons">

      <button

        type="button"

        class="slider-button slider-button--prev"

        name="previous"

        aria-label="{{ 'sections.announcements.previous_announcement' | t }}"

        aria-controls="Slider-{{ section.id }}"

      >

        <span class="svg-wrapper">

          {{- 'icon-caret.svg' | inline_asset_content -}}

        </span>

      </button>

      <div

        class="grid grid--1-col slider slider--everywhere"

        id="Slider-{{ section.id }}"

        aria-live="polite"

        aria-atomic="true"

        data-autoplay="{{ section.settings.auto_rotate }}"

        data-speed="{{ section.settings.change_slides_speed }}"

      >

        {%- for block in section.blocks -%}

          <div

            class="slideshow__slide slider__slide grid__item grid--1-col"

            id="Slide-{{ section.id }}-{{ forloop.index }}"

            {{ block.shopify_attributes }}

            role="group"

            aria-roledescription="{{ 'sections.announcements.announcement' | t }}"

            aria-label="{{ forloop.index }} {{ 'general.slider.of' | t }} {{ forloop.length }}"

            tabindex="-1"

          >

            <div

              class="announcement-bar__announcement"

              role="region"

              aria-label="{{ 'sections.header.announcement' | t }}"

              {{ block.shopify_attributes }}

            >

              {%- if block.settings.text != blank -%}

                {%- if block.settings.link != blank -%}

                  <a

                    href="{{ block.settings.link }}"

                    class="announcement-bar__link link link--text focus-inset animate-arrow"

                  >

                {%- endif -%}

                <p class="announcement-bar__message h3">

                  <span>{{ block.settings.text | escape }}</span>

                  {%- if block.settings.link != blank -%}

                    {{- 'icon-arrow.svg' | inline_asset_content -}}

                  {%- endif -%}

                </p>

                {%- if block.settings.link != blank -%}

                  </a>

                {%- endif -%}

              {%- endif -%}

            </div>

          </div>

        {%- endfor -%}

      </div>

      <button

        type="button"

        class="slider-button slider-button--next"

        name="next"

        aria-label="{{ 'sections.announcements.next_announcement' | t }}"

        aria-controls="Slider-{{ section.id }}"

      >

        <span class="svg-wrapper">

          {{- 'icon-caret.svg' | inline_asset_content -}}

        </span>

      </button>

    </div>

    



  </slideshow-component>

  {%- if request.design_mode -%}

    <script src="{{ 'theme-editor.js' | asset_url }}" defer="defer"></script>

    <style>

      /\* theme editor power preview fix \*/

      .announcement-bar-slider .slider__slide\[aria-hidden='true'\] {

        visibility: hidden;

      }

    </style>

  {%- endif -%}

{%- endif -%}

<div class="localization-wrapper">

  {%- if section.settings.enable_country_selector and localization.available_countries.size > 1 -%}

    <localization-form class="small-hide medium-hide">

      {%- form 'localization', id: 'AnnouncementCountryForm', class: 'localization-form' -%}

        <div>

          <h3 class="visually-hidden" id="AnnouncementCountryLabel">{{ 'localization.country_label' | t }}</h3>

          {%- render 'country-localization', localPosition: 'AnnouncementCountry' -%}

        </div>

      {%- endform -%}

    </localization-form>

  {% endif %}



  {%- if section.settings.enable_language_selector and localization.available_languages.size > 1 -%}

    <localization-form class="small-hide medium-hide">

      {%- form 'localization', id: 'AnnouncementLanguageForm', class: 'localization-form' -%}

        <div>

          <h3 class="visually-hidden" id="AnnouncementLanguageLabel">{{ 'localization.language_label' | t }}</h3>

          {%- render 'language-localization', localPosition: 'AnnouncementLanguage' -%}

        </div>

      {%- endform -%}

    </localization-form>

  {%- endif -%}

</div>

{% schema %}

{

“name”: “t:sections.announcement-bar.name”,

“max_blocks”: 12,

“class”: “announcement-bar-section”,

“enabled_on”: {

"groups": \["header"\]

},

“settings”: [

{

  "type": "color_scheme",

  "id": "color_scheme",

  "label": "t:sections.all.colors.label",

  "default": "scheme-4"

},

{

  "type": "checkbox",

  "id": "show_line_separator",

  "default": true,

  "label": "t:sections.header.settings.show_line_separator.label"

},

{

  "type": "header",

  "content": "t:sections.announcement-bar.settings.header__1.content",

  "info": "t:sections.announcement-bar.settings.header__1.info"

},

{

  "type": "checkbox",

  "id": "show_social",

  "default": false,

  "label": "t:sections.announcement-bar.settings.show_social.label"

},

{

  "type": "header",

  "content": "t:sections.announcement-bar.settings.header__2.content"

},

{

  "type": "checkbox",

  "id": "auto_rotate",

  "label": "t:sections.announcement-bar.settings.auto_rotate.label",

  "default": false

},

{

  "type": "range",

  "id": "change_slides_speed",

  "min": 3,

  "max": 10,

  "step": 1,

  "unit": "s",

  "label": "t:sections.announcement-bar.settings.change_slides_speed.label",

  "default": 5

},

{

  "type": "header",

  "content": "t:sections.announcement-bar.settings.header__3.content",

  "info": "t:sections.announcement-bar.settings.header__3.info"

},

{

  "type": "checkbox",

  "id": "enable_country_selector",

  "default": false,

  "label": "t:sections.announcement-bar.settings.enable_country_selector.label"

},

{

  "type": "header",

  "content": "t:sections.announcement-bar.settings.header__4.content",

  "info": "t:sections.announcement-bar.settings.header__4.info"

},

{

  "type": "checkbox",

  "id": "enable_language_selector",

  "default": false,

  "label": "t:sections.announcement-bar.settings.enable_language_selector.label"

}

],

“blocks”: [

{

  "type": "announcement",

  "name": "t:sections.announcement-bar.blocks.announcement.name",

  "settings": \[

    {

      "type": "text",

      "id": "text",

      "default": "t:sections.announcement-bar.blocks.announcement.settings.text.default",

      "label": "t:sections.announcement-bar.blocks.announcement.settings.text.label"

    },

    {

      "type": "url",

      "id": "link",

      "label": "t:sections.announcement-bar.blocks.announcement.settings.link.label"

    }

  \]

}

],

“presets”: [

{

  "name": "t:sections.announcement-bar.presets.name",

  "blocks": \[

    {

      "type": "announcement"

    }

  \]

}

]

}

{% endschema %}

Unfortunately this didn’t work

Hi, sorry this didn’t work

Hi, do I put all this code into the announcement-bar.liquid file? Or does some need to go into the base.css file? Sorry if this is a basic question - I’m new to coding

@HH_2023

Can you please send me the announcement bar file code, or alternatively share the Collaborate code? I will check it and update you.

Best regards,
Devcoder :laptop:

Thank you

Code: 1655