Updating Standard Branding Elements | Yext Hitchhikers Platform
What You’ll Learn
In this section, you will learn:
- Key elements of Search styling
- How to use variables to update multiple components
Introduction
As a reminder, we use CSS and SASS in order to customize our frontend experiences across Search and Pages. Please make sure to complete Introduction to CSS before proceeding.
The files we’ll be handling can be found under static > scss.
The Answers Variables File
As you learned in the CSS Module, CSS Variables gives you the flexibility to use variables to define things like colors, fonts, borders, and more in one place to use it across several CSS rules.
We store most of these variables in the file answers-variables.scss
, where we can define the value here without having to update the CSS of all sections that should use that variable.
We’ll walk through the variables you’ll most commonly use in this training.
Common Variables to Update
Search Background Color
--hh-answers-background-color: white;
By default, the background color of the Search experience will be gray.
However, altering the background to white or to match a customer’s existing background color may help with brand consistency.
Brand Colors
--yxt-color-brand-primary: #0f70f0;
--yxt-color-text-primary: #212121;
These variables give you the most bang-for-your-buck. They control the color of many different elements across the Search experience.
--yxt-color-brand-primary
will control the color of several elements on the page - from title links, to CTAs, to the nav menu items and view all links.
--yxt-color-text-primary
will update the text color of the search bar text, the card text, the nav bar text, and the vertical title text. In the example below, we’ve set it to #881111, but most often you’ll change this to a black or dark gray color.
--yxt-results-title-bar-text-color: white;
--yxt-results-title-bar-background: var(--yxt-color-brand-primary);
The --yxt-results-title-bar
variables help us control the colors for the title bar on Universal pages.
As you can see below, we can change the background color to blue and the text color to white to achieve a more prominent title bar.
There will be some additional tweaks necessary to ensure the icon and View All text is updated, but you’ll learn more about how to do that in the next module.
Best Practices
Variable Naming Convention
Variables prefixed with yxt
are variables used in the Search Library (and can also be referenced in the theme), while those prefixed with hh
are variables defined just in the theme. If you want to add new variables in your variables files, we recommend you prefix them with something like hh
to ensure there are no conflicts with other CSS variables your customer may be setting.
Choose Brand-Specific and Accessible Colors
You’ll want to inspect a customer’s website to ensure you’re adhering to their styles as much as possible. Customers might even have a style guide that will give you the specific colors and other styles to apply. For example, we can pull the Yext blue color by inspecting the CTA on the homepage, and grabbing the value #0f70f0
to use as our --yxt-color-brand-primary
.
For the --yxt-color-brand-primary
and --yxt-color-text-primary
, we recommend pulling dark colors that have enough contrast for accessibility purposes. You can use a tool like
WebAim’s Contrast Checker
to verify if this passes sufficient contrast. Typically, we aim for a contrast above 7:1. See examples of bad contrast (orange) and good contrast (blue) in the images below.