loading

Answers Variables - Updating Standard Branding Elements| Hitchhikers Platform

What You’ll Learn

In this section, you will learn:

  • Key elements of Answers 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 Answers 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 Files

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

Answers Background Color

--hh-answers-background-color: white;

By default, the background color of the Answers experience will be gray.

Standard Gray Background

However, altering the background to white or to match a customer’s existing background color may help with brand consistency.

White Background

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 Answers 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. Color Brand Primary Example

--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. Color Text Primary Example

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

Results Title Variables Example

Best Practices

Variable Naming Convention

Variables prefixed with yxt are variables used in the Answers 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.

Yext Primary Brand Color

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.

Low Contrast

High Contrast

unit Quiz
+20 points
Daily Quiz Streak Daily Quiz Streak: 0
Quiz Accuracy Streak Quiz Accuracy Streak: 0
    Error Success Question 1 of 3

    Why should we use variables?

    Error Success Question 2 of 3

    What variable would you use to update the color of the Title link on a card?

    Error Success Question 3 of 3

    What variable would you use to update the background color of the entire Answers experience?

    Soon you'll be your brand's hero! 🎓

    You've already completed this quiz, so you can't earn more points.You completed this quiz in 1 attempt and earned 0 points! Feel free to review your answers and move on when you're ready.
1st attempt
0 incorrect
Splash Loading