Introduction Modules Flavors Customization Github

mini.css

v2.0

Contextual

The contextual module provides you with simple tags, marks and highlights for your pages, allowing you to easily emphasize parts of your text. The contextual alerts aim to replace the commonly used modal dialog design paradigm with a more modern one. HTML5 elements and simple rules are used in order to make important messages and pieces of content stand out easily.

All examples showcased refer to the mini-default flavor, some class names and styles might differ based on the flavor you're using.

Quick overview

Almost every piece of content present on the web has some sort of content that needs highlighting in one way or another. The contextual module provides you with simple semantic text highlighting that utilises the <mark> HTML element. Apart from that, this module contains styles and definitions for a simple .alert container, that you can use to show alerts on your websites and web apps. Alerts replace the traditional design paradigms of modals, messages and alerts by defining a simple, usable container that is also mobile friendly. All components in this module are fully accessible, so that's another thing not to worry about.


Quick start

To use the contextual module, simply include the link to the flavor you are using and start writing your HTML page as usual. One suggestion we will make is to add the following line inside your HTML page's <head> to utilize the viewport meta tag:


<meta name="viewport" content="width=device-width, initial-scale=1">

Text highlighting

This is some text with a highlight.

Apart from the primary highlight style, there are also secondary and tertiary styles for highlighting.


If you want to highlight a longer piece of text, without line breaks, you can turn the highlight into an inline-block like you see this piece of text being displayed.


Finally, you can create contextual tags like this or 7.


To add simple highlights in your text, you can use the <mark> HTML element. These highlights come pre-styled to use the default primary color, but if you would rather use another color for your highlight you can easily add the .secondary or .tertiary class to a <mark> element. For longer pieces of text that need highlighting, consider adding the .inline-block class to make them stand out even more. Finally, you can create contextual tags, using the .tag class.

Sample code

<mark>primary</mark>
<mark class="secondary">secondary</mark>
<mark class="tertiary">tertiary</mark>
<mark class="inline-block">long highlight text...</mark>
<mark class="tag">tag</mark>

Notes

  • Try to use elements with the .inline-block class only when absolutely necessary, as they break the normal text flow of the document. Avoid using this class on shorter pieces of text that span a few words and contain no line breaks.
  • <mark> elements, along with their supporting classes (except for .inline-block) can be easily used in paragraphs, headings and other elements, as they scale according to their parent element.

<mark class="tag tertiary">green tag</mark>
<!-- or -->
<mark class="inline-block secondary">red chunk</mark>

Do: You can combine any of the contextual color classes (.secondary or .tertiary) with the .tag or .inline-block class.

<mark class="secondary tertiary">no, no</mark>
<!-- or -->
<mark class="inline-block tag">oh, no</mark>

Don't: Avoid combining two contextual color classes or a .tag and an .inline-block, as these combinations might result in unexpected behavior.

<mark class="inline-block">some 
  <mark class="secondary">text</mark>
</mark>

Do: You can only nest a <mark> inside another if the outer one is of the .inline-block class. You can color the inner <mark> using any of the contextual color classses or even make it a .tag. Be careful, however, to not make the inner <mark> an .inline-block as well.

<mark>some 
  <mark class="secondary">text</mark>
</mark>

Don't: Avoid using nested <mark> elements, unless the outer <mark> element is an .inline-block.

Alerts

This is an alert

Make sure you read this!

This is an urgent alert

Make absolutely sure you read this!

This is a critical alert

Make certain you read and actually understand this!

Alerts replace modal dialogs, along with messages, notifications and traditional alerts with a simpler, easier design paradigm. To create an alert, use a <div> element, which will contain one or more elements (for example a <h3> and a <p>) and add the .alert class to it. For more urgent alerts, use the .urgent class and for critical alerts, use the .critical class.

Sample code

<div class="alert">
  <h3>This is an alert</h3>
  <p>Make sure you read this!</p>
</div>
<div class="alert urgent">
  <h3>This is an urgent alert</h3>
  <p>Make absolutely sure you read this!</p>
</div>
<div class="alert critical">
  <h3>This is a critical alert</h3>
  <p>Make certain you read and actually understand this!</p>
</div>

Notes

  • Alert elements do not have any pre-defined behavior. You should use your own Javascript code and interactive HTML elements to deal with showing and hiding them as necessary.

<p class="alert">Short and to the point</p>
<!-- or -->
<h2 class="alert urgent">Large and to the point</h2>

Do: Instead of using a <div> element, you can also apply the .alert class to common textual elements, such as paragraphs or headings.

<button class="alert">Not a good alert</button>

Don't: Avoid applying the .alert class to non-textual HTML elements, such as buttons or images. Doing so might result in unexpected behavior.

Animated alerts

This is an alert

Make sure you read this!

This is an urgent alert

Make absolutely sure you read this!

This is a critical alert

Make certain you read and actually understand this!

Alerts can be animated, so that they pop out a little more to make sure your users can see them. To animate an alert box, use the .animated class on an existing .alert and it shall periodically scale up a little bit to make users notice it.

Sample code

<div class="alert animated">
  <h3>Animated alert</h3>
</div>
<div class="alert urgent animated">
  <h3>Animated urgent alert</h3>
</div>
<div class="alert critical animated">
  <h3>Animated critical alert</h3>
</div>

Notes

  • Animated alerts may not display properly on older browsers, especially legacy versions of Internet Explorer.
  • It has been reported that some Webkit-based browsers, such as Chrome, display animated alerts in a very blurry fashion. Despite our best attempts at solving these problems, they seem to be quite persistent and we do not yet know how to fix them. Thus, you might want to hold off on using animated alerts if you think this might be an issue or try to control them using Javascript code to make the animation stop after a short amount of time (i.e. removing the .animated class).

If you want to learn more about mini.css's modules, go back to the modules page and choose another module to see its documentation.