Popovers

Popovers are used for any contextual content that shouldn't block the the user. Some common uses are dropdown link menus, hovercards, complex tooltips, etc. Below are some guidelines for usage and structure.


Basic Usage

A Popover, in its most basic form, looks like this.

  <!-- A basic Popover -->
  <div class="Popover-container on-click">
    <div class="Popover">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="js-toggle-popover">Click here</a>
  </div>
  

Broken down; the first line creates the Popover container. This is where the triggering method must also be declared: click or hover. In this example, it is declared as click.

  <div class="Popover-container on-click">

The next line creates the Popover. This is where any optional Popover paramaters can be declared. Details on the available Popover parameters are provided in the sections below.

  <div class="Popover">

Next, the Popover wrapper is created. This wrapper class allows optional max-height to be set on Popovers. This is especially useful for Popovers that function as dropdown menus.

  <div class="Popover__wrapper">

Popovers don't have any padding by default, however padding can be set by nesting a divider inside of the Popover__wrapper. The contents of the Popover are contained within the divider as well.

  <div class="p-s">...</div>

The js-toggle-popover class must be included on the element that will trigger the Popover. In this case, it is an anchor tag.

  <a class="js-toggle-popover">Click here</a>

Triggering

Popovers can be triggered two ways: on click or hover. Click events require JavaScript. To enable click Popovers, append .on-click to the .Popover-container. For hover Popovers, append .on-hover instead.

This Popover only activates on click.
Click Popover

.on-click

This Popover only activates on hover.
Hover Popover

.on-hover

  <!-- Click Popover -->
  <div class="Popover-container on-click">
    <div class="Popover">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Hover Popover -->
  <div class="Popover-container on-hover">
    <div class="Popover">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Caret

The Popover caret it optional. Append .has-caret accordingly. Generally, carets should only be used when the triggering element (ex: the yellow button below) does not also use a caret. That will protect against potential caret alignment issues.

This Popover does not have a caret.
Popover Without Caret
This Popover has a caret.
Popover With Caret

.has-caret

  <!-- Popover with caret -->
  <div class="Popover-container on-click">
    <div class="Popover has-caret">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Alignment & Positioning

Popovers can be aligned top, right, bottom, or left. By default, they are top aligned.

Popover Alignment

This is a top aligned Popover with a caret.
Top Aligned
This is a right aligned Popover with a caret.
Right Aligned

.Popover--right

This is a bottom aligned Popover with a caret.
Bottom Aligned

.Popover--bottom

This is a left aligned Popover with a caret.
Left Aligned

.Popover--left

  <!-- Right aligned Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--right">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Bottom aligned Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--bottom">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Left aligned Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--left">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Popover Positioning

There are left and right positioning classes for Popovers that are top and bottom aligned. Adding a class Popover--flush-left or Popover--flush-right will adjust the Popover's positioning and transform origin accordingly. By default, Popovers are center positioned.

This is a top aligned Popover that is flushed left with the clicked element.
Flush Left

.Popover--flush-left

This is a top aligned Popover that is flushed right with the clicked element.
Flush Right

.Popover--flush-right

  <!-- Flushed left Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--flush-left">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Flushed right Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--flush-right">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

There are also top and bottom positioning classes for Popover that are left or right aligned. Adding classes Popover--flush-top or Popover--flush-bottom will adjust the Popover's positioning and transform origin accordingly. By default, Popovers are middle positioned.

This is a left aligned Popover that is flushed top with the clicked element.
Flush Top

.Popover--flush-top

This is a left aligned Popover that is flushed bottom with the clicked element.
Flush Bottom

.Popover--flush-bottom

  <!-- Flushed top Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--left Popover--flush-top">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Flushed bottom Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--left Popover--flush-bottom">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Themes

There are 4 Popover themes: default (light), dark, error, and success. Apply .Popover--dark, .Popover--error, or .Popover--success accordingly. Omit all of the above to use the default theme.

This is a Popover using the default theme.
Default
This is a Popover using the dark theme.
Dark

.Popover--dark

This is a Popover using the error theme.
Error

.Popover--error

This is a Popover using the success theme.
Success

.Popover--success

  <!-- Dark theme Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--dark">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Error theme Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--error">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Success theme Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--success">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Sizes

There are 3 Popover widths: small, medium, and large. Those don't apply inner padding, but instead change the width of the overall Popover. Apply .Popover--small or .Popover--large accordingly. For medium width popoovers, omit all of the above.

This is a small width Popover.
Small Width

.Popover--small

This is a medium width Popover.
Medium Width
This is a large width Popover.
Large Width

.Popover--large

  <!-- Small width Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--small">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>

  <!-- Large width Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--large">
      <div class="Popover__wrapper">
        <div class="p-s">...</div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Dropdown Menus

Dropdown menus leverage the lists component to create a simple menu with links, possibly used for header nav menus, filters, etc. Horizontal rules can be created within dropdowns by distributing links between multiple Popover__section dividers.

Note that Popover__section dividers are only required for dropdown menu Popovers.

Basic Dropdown Menu

  <!-- Basic dropdown menu Popover -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--bottom">
      <div class="Popover__wrapper">
        <div class="Popover__section">
          <ul class="List List--padding">
            <li><a href="#">Twitter</a></li>
            <li><a href="#">Facebook</a></li>
            <li><a href="#">Google</a></li>
            <li><a href="#">Dedicated Hosting</a></li>
            <li><a href="#">Contact us</a></li>
          </ul>
        </div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>
  

Dropdown Menu With Separator

  <!-- Dropdown menu Popover with a separator -->
  <div class="Popover-container on-click">
    <div class="Popover Popover--bottom">
      <div class="Popover__wrapper">
        <div class="Popover__section">
          <ul class="List List--padding">
            <li><a href="#">Twitter</a></li>
            <li><a href="#">Facebook</a></li>
            <li><a href="#">Google</a></li>
            <li><a href="#">Dedicated Hosting</a></li>
          </ul>
        </div>
        <div class="Popover__section Popover__section--separator">
          <ul class="List List--padding">
            <li><a href="#">Contact us</a></li>
          </ul>
        </div>
      </div>
    </div>
    <a class="Button js-toggle-popover">Click here</a>
  </div>