How to change the discount code color on Shopify forms

Solved

How to change the discount code color on Shopify forms

3rdDay
Explorer
44 1 24

Hi & Thanks for checking this out!

 

I have an inline Shopify form added to my website here: https://3rdday.co.uk/#shopify-section-template--23326105829668__1741186850702ce7ae and it provides a discount code when someone enters their email. I want to be able to change the discount code colour to #FFFFFF (which will allow me to change the background of the section - I know it'll look strange for now) but can't seem to get it to work using custom CSS. There is no option to change this using the Shopify Forms app or the custom styling options within the section editor (I'm certain). It could be that CSS won't work and javascript is needed?

 

IF YOU ENTER YOUR EMAIL ADDRESS ON MY FORM TO TEST THINGS OUT & FIND A FIX, I WILL REMOVE YOUR EMAIL FROM THE MAILING LIST SO YOU DON'T GET ANY MARKETING EMAILS!!! 😊

 

I'm using Dawn theme.

 

Thanks so much!

Asa (3rd Day)
3rdday.co.uk
Accepted Solution (1)

tobebuilds
Shopify Partner
558 42 151

This is an accepted solution.

Hi 3rdDay, here's what I saw after entering an email:

 

tobebuilds_0-1741462249963.png

The `form-embed` element has a shadow DOM, so that probably explains why you weren't able to style it. Unless the creator of the `form-embed` component had exposed parts of the component to be used with `::part()` selectors, you wouldn't be able to style this from the outside using just CSS.

 

However, using JavaScript, I was able to style it:

 

document.querySelector('form-embed').shadowRoot.querySelector('[data-testid="banner-success"] span').style.color = '#fff'

 

It's up to you to add your own code to detect when the form is submitted, however. Hopefully this snippet serves as a useful starting point for you.

 

Best,

Tobe

Founder, Regios Discounts app (4.8 stars, 83 reviews, Built for Shopify)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer
- Often imitated, never duplicated

View solution in original post

Replies 2 (2)

tobebuilds
Shopify Partner
558 42 151

This is an accepted solution.

Hi 3rdDay, here's what I saw after entering an email:

 

tobebuilds_0-1741462249963.png

The `form-embed` element has a shadow DOM, so that probably explains why you weren't able to style it. Unless the creator of the `form-embed` component had exposed parts of the component to be used with `::part()` selectors, you wouldn't be able to style this from the outside using just CSS.

 

However, using JavaScript, I was able to style it:

 

document.querySelector('form-embed').shadowRoot.querySelector('[data-testid="banner-success"] span').style.color = '#fff'

 

It's up to you to add your own code to detect when the form is submitted, however. Hopefully this snippet serves as a useful starting point for you.

 

Best,

Tobe

Founder, Regios Discounts app (4.8 stars, 83 reviews, Built for Shopify)
- Custom discounts made simple
- "Just about any discount you'll ever need"
- Built by an ex-Google software engineer
- Often imitated, never duplicated
3rdDay
Explorer
44 1 24

Thanks so much for your help!

 

I appreciate it 🙂

Asa (3rd Day)
3rdday.co.uk