If you have keyboard affordances, you might need to explain them. To that end, there's a simple keystroke character affordance in Foundation.

For example, to close your browser hit Cmd + Q. Don't actually do it. There's more docs to read.

Build With Predefined HTML Classes

There are two ways to build keystrokes in Foundation 4: with our predefined HTML or with our mixins. Building keystrokes using our predefined classes is simple, you simply wrap kbd or .keystroke around whatever you want to call out.

<p>For example, to close your browser hit <kbd>Cmd</kbd> + <kbd>Q</kbd>

For these styles to come across, make sure you have the default Foundation CSS package or that you've selected keystrokes from a custom package. These should be linked up following our default HTML page structure.

Build with a Mixin

We've included SCSS mixins used to style keystrokes. To use the mixin, you'll need to have the extension installed or grab _variables.scss, _global.scss and _keystrokes.scss from Github and throw them into a Foundation folder in your project directory. From there, you can import the files at the top of your own SCSS stylesheet, like so:

@import "foundation/variables";
@import "foundation/components/global";
@import "foundation/components/keystrokes";
Quick Mixin

You can build your keystrokes using our global mixin by including it on your custom class or the kbd element in your own stylesheet. The mixin contains options for changing the background color, which also controls the border and text color. The rest of the defaults can be modified using the available variables. The global mixin looks like this:

.your-class-name { @include keystroke($bg); }

/* You can set the background color of your keystrokes, which also effects text and border */
$bg: $keystroke-bg

Here's an example of a custom keystroke style.

Default SCSS Variables
$include-html-type-classes: $include-html-classes;

/* We use these to control text styles. */
$keystroke-font: "Consolas", "Menlo", "Courier", monospace;
$keystroke-font-size: em-calc(14);
$keystroke-font-color: #222;
$keystroke-font-color-alt: #fff;
$keystroke-function-factor: 7%;

/* We use this to control keystroke padding. */
$keystroke-padding: em-calc(2 4 0);

/* We use these to control background and border styles. */
$keystroke-bg: darken(#fff, $keystroke-function-factor);
$keystroke-border-style: solid;
$keystroke-border-width: 1px;
$keystroke-border-color: darken($keystroke-bg, $keystroke-function-factor);
$keystroke-radius: $global-radius;

Note: em-calc(); is a function we wrote to convert px to em. It is included in _variables.scss.

This is a modal.

Reveal makes these very easy to summon and dismiss. The close button is simply an anchor with a unicode character icon and a class of close-reveal-modal. Clicking anywhere outside the modal will also dismiss it.

Finally, if your modal summons another Reveal modal, the plugin will handle that for you gracefully.

Second Modal...


This is a second modal.

See? It just slides into place after the other first modal. Very handy when you need subsequent dialogs, or when a modal option impacts or requires another decision.


This modal has video