⚡ AMP Surface CSS Framework

Download from GitHub

Alerts

Alerts are dialog boxes that the user can make disappear.

Surface rules! That is all.

Code

				
<div class="alert-wrap">
  <input type="checkbox" id="alert-check">
  <label for="alert-check">CLOSE</label>
  <div class="alert">
    <p>Surface rules! That is all.</p>
  </div>
</div>
				
			

Animations

Animations bring your page to life.

I fade in from the top
I fade in from the right with a 1.5s delay

Code

Direction

There are 4 classes for fading in.

				
<div class="fade-in-from-top">
  I fade in from the top
</div>
<div class="fade-in-from-left">
  I fade in from the right
</div>
				
			

Delays

You can delay an animation for up to 10 seconds.

The suffixes go up to 100. 5 is 0.5s, 25 is 2.5s and so on.

				
<div class="fade-in-from-top anim-delay--5">
  I have 0.5s delay
</div>
<div class="fade-in-from-left anim-delay--50">
  I have a 5s delay
</div>
				
			

Buttons

Buttons are essential web elements for interaction.

Code

Types

There are 3 different types of button.

Colors

By default, the flat and the raised buttons are the $primary variable color and the floating button is the $accent variable. If you want a specific color, there are 7 different colors.

				
<button class="btn--flat">Flat</button>
<button class="btn--float">+</button>
<button class="btn--raised">Raised</button>

<button class="btn--raised btn--green">Green</button>
<button class="btn--raised btn--blue">Blue</button>
<button class="btn--raised btn--accent">Accent</button>
				
			

Cards & Tiles

Cards and tiles are fundamental components of Google's Material Design guidelines.

I'm a card!
I'm a tile!

Code

				
<div class="card">
  I'm a card!
</div>
<div class="tile">
  I'm a tile!
</div>
				
			

Collapsibles

Have information that the user might want be don't want it cluttering up the page if they don't want it? Use a collapsible.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ornare elit aliquet, eleifend eros a, viverra nibh. Suspendisse rhoncus sed sem quis placerat. Maecenas sed malesuada ipsum, vel luctus odio. Morbi quis orci eu nisl consequat molestie. Suspendisse tempor nulla sapien, non mattis nibh mollis in.

Cras lobortis elit sem, ut vulputate nisl aliquet vitae. Fusce luctus orci tincidunt, efficitur arcu nec, mattis tellus. Praesent mollis laoreet nibh in consectetur. Ut facilisis nunc eget lectus consequat, sed auctor nibh dapibus. Nam erat velit, eleifend quis gravida ac, cursus ut tellus. Praesent ut dui justo.

Donec efficitur condimentum lacus, ut efficitur libero pretium quis. Donec accumsan, dolor id congue vulputate, ante lacus consectetur mauris, sit amet aliquet turpis nunc vitae tortor.

Code

If you want a collapsible to be open by default, simply add the checked attribute to the input. For example, the left hand navigation is checked to be open when in the documentation.

				
<div class="collapsible-wrap card no-pad">
  <input type="checkbox" id="collapsible-1">
  <label for="collapsible-1">Collapsible 1</label>
  <div class="collapsible-1-area">
    <p>Lorem ipsum dolor sit amet.</p>
  </div>
</div>

<div class="collapsible-wrap card no-pad">
  <input type="checkbox" id="collapsible-2">
  <label for="collapsible-2">Collapsible 2</label>
  <div class="collapsible-2-area">
    <p>Cras lobortis elit sem.</p>
  </div>
</div>

<div class="collapsible-wrap card no-pad">
  <input type="checkbox" id="collapsible-3">
  <label for="collapsible-3">Collapsible 3</label>
  <div class="collapsible-3-area">
    <p>Donec efficitur condimentum lacus.</p>
  </div>
</div>
				
			

Colors

Background

Red
Alizarin
Pomegranate
Pumpkin
Carrot
Blood Orange
Orange
Dull Orange
Amber
Sunflower
Yellow
Lime
Light Green
Green
Nephritis
Emerald
Green Sea
Turqoise
Teal
Cyan
Light Blue
Blue
River
Belize
Asphalt
Midnight Blue
Indigo
Deep Purple
Purple
Plum
Amethyst
Pink
Brown
Asbestos
Gun Metal
Grey
Silver
Concrete
Clouds
Paper
Black

Code

Use the .bg-- class suffixed with your color of choice.

				
<div class="tile bg--pink">Pink</div>
				
			

Text

Red
Alizarin
Pomegranate
Pumpkin
Carrot
Blood Orange
Orange
Dull Orange
Amber
Sunflower
Yellow
Lime
Light Green
Green
Nephritis
Emerald
Green Sea
Turqoise
Teal
Cyan
Light Blue
Blue
River
Belize
Asphalt
Midnight Blue
Indigo
Deep Purple
Purple
Plum
Amethyst
Pink
Brown
Asbestos
Gun Metal
Grey
Silver
Concrete
Clouds
Paper
Black

Code

Use the .color-- class suffixed with your color of choice.

				
<div class="tile color--pink">Pink</div>
				
			

Footer

Use a footer to show extra information or links that aren't necessary elsewhere.

Some footer information

Code

Simply use the HTML5 footer element.

				
<footer class="g--10 m--2 no-margin-vertical">
  <div class="g--10 m--1">
    Some footer information
  </div>
</footer>
				
			

Forms

Form elements.

Code

HTML5 Elements

The following elements need only for you to use the HTML5 elements.

				
<input type="text" required placeholder="Username">
<input type="password" required placeholder="Password">
<label>Label</label>
<textarea></textarea>
<input type="checkbox">
<input type="radio" name="radio">
<input type="radio" name="radio">
<input type="radio" name="radio">
<input type="range">
				
			

Class Based

The following elements need to be used as the code shows, in order and with classes.

				
<input type="checkbox" class="toggle" id="toggle">
<label for="toggle"></label>
				
			

Grid

The grid system is the basis of Surface layouts.

I'm a g--5 and g-s--12
I'm a g--1 and g-m--12
I'm a g--2 with a m--3, and a g-m--8 with a m-m--2
I'm a g--3 with a m--1
We're in a container
We're in a container

Code

Grid

The grid system by default is 12 columns wide. This can be changed in the _variables file by altering the $grid-columns variable.

To give an element a grid size, use the class .g-- suffixed by the size of the grid. For example, .g--5 g-s--12 will be 5/12ths wide.

To make your grid elements responsive, include the breakpoint classes listed below. The breakpoint sizes can be changed in the _variables file.

				
<div class="g--5 g-s--12">
  I'm a g--5 g-s--12
</div>
<div class="g--1 g-m--4 g-t--12">
  I'm a g--1 at regular size, g--4 at medium and g--12 at tiny size.
</div>
				
			

Margins

The margins work exactly the same as the grid system. Each m--1 is equal size to a g--1

To give an element a margin, use the class .m-- suffixed by the size of the margin. For example, .m--3 will push your element along a quart of the grid (assuming you have a 12 column grid).

To make your margins responsive, include the breakpoint classes listed below. The breakpoint sizes can be changed in the _variables file.

				
<div class="m--3">
  I have a 3 grid wide margin
</div>
<div class="m--1 m-s--5">
  I have a 1 grid wide margin at regular size and a m--5 at small size.
</div>
				
			

Containers

Containers are a way of display elements that are usually block level inline. A container has the display flex declaration. Such as displaying divs next to each other. It also gets rid of those pesky gaps between inline-blocks.

To add a container class simply use the .container class. The following suffixes will control where the elements align vertically.

				
<div class="container g--6">
  <div class="g--5 g-s--12 tile">
    We're in a container
  </div>
  <div class="g--5 g-s--12 tile">
    We're in a container
  </div>
</div>
				
			

You can also apply flex-wrap: wrap to your containers at different breakpoints with the following classes.

				
<div class="container container--wrap--t g--6">
  <div class="g--5 g-s--12 tile">
    This container wraps at the tiny breakpoint
  </div>
</div>
				
			

Nudges

Sometimes 1 margin space is too big. That's what nudges are for. Use the .nudge--left and .nudge--right classes. These classes have a margin on their respective side that gets smaller as the screen width gets smaller. Particularly useful for buttons and smaller elements.

You can remove the nudges at small screen sizes using the following classes.

				
<button class="btn--flat">Flat</button>
<button class="btn--float nudge--left nudge--right">+</button>
<button class="btn--raised">Raised</button>

<div class="card nudge--left nudge--right no-nudge--s">
I have a nudge left and right, but no nudge when smaller than the small breakpoint size.
  <p>Words...</p>
</div>
				
			

Header

Headers display titles, website names, navigation and logos.

You can see an example of a header at the top of this page

Code

Simply use the HTML5 header element.

				
<header class="container">
  <h1 class="m--1 g--4">Header</h1>
</header>
				
			

Lightbox

A lightbox is used to display images without other distractions.

Code

Use a checkbox, followed by a label with your img inside. Be sure to make your lightboxes have different numbered suffixes.

				
<input type="checkbox" id="lightbox-1">
<label for="lightbox-1"><amp-img src="https://via.placeholder.com/600x400" width="600" height="400" layout="responsive"></amp-img></label>
				
			

Links

We all know what links are, right?

Check out this amazing website example.com.

Code

Simply use the HTML a tag.

				
<a href="http://www.example.com">example.com</a>
				
			

Media

Images, video and audio.

Code

Simply use the required HTML tag, img, video or audio.

By default, all media will be 100% width of their parent

				
<amp-img src="https://via.placeholder.com/600x400" width="600" height="400" layout="responsive"></amp-img>
				
			

Modals

Modals are pop out peices of information.

Code

				
<div class="g--4">
  <input type="checkbox" id="modal-1">
  <label class="modal-trigger" for="modal-1">Modal Link</label>
  <div class="modal-content g--4">
    <p>Lorem ipsum dolor.</p>
  </div>
</div>
				
			

Navigation

Navigation systems are the fundamental method of moving around a website.

An example of a horizontal navigation bar can be found at the top of this page.

An example of a super vertical navigation can be found on the left hand side of this page.

Code

Horizontal Navigation

				
<header class="container--baseline">
  <h1 class="m--1 g--4">Navigation</h1>
  <nav class="g--3 nav--horizontal">
    <ul>
      <li><a href="http://www.google.com">Nav link</a></li>
      <li><a href="http://www.google.com">Hello</a></li>
      <li><a href="http://www.google.com">Contact</a></li>
      <li class="dropdown"><a href="http://www.g.com">Dropdown</a>
        <ul>
          <li><a href="http://www.google.com">D Link</a></li>
          <li><a href="http://www.google.com">D Link</a></li>
          <li><a href="http://www.google.com">D Link</a></li>
          <li><a href="http://www.google.com">D Link</a></li>
        </ul>
      </li>
      <li><a href="http://www.google.com">Portfolio</a></li>
    </ul>
  </nav>
</header>
				
			
Responsive

To make your horizontal navigation responsive, use the following code before the .nav--horizontal class.

				
<input type="checkbox" id="nav--horizontal-responsive">
<label for="nav--horizontal-responsive">MENU</label>
<nav class="nav--horizontal g--4">
    ....
				
			

Super Vertical Navigation

				
<aside class="nav--super-vertical g--2 g-med--3 g-small--6 g-tiny--12 no-margin-vertical">
  <div class="g--12 logo-area no-margin-vertical">
    Your logo here
  </div>
  <nav class="g--12">
    <a href="">About</a>
    <div class="nav-collapsible">
      <input type="checkbox" id="nav-collapsible-1">
      <label for="nav-collapsible-1">Components</label>
      <div class="nav-collapsible-links">
        <a href="../docs/alerts.html">Alerts</a>
        <a href="../docs/animations.html">Animations</a>
        <a href="../docs/buttons.html">Buttons</a>
      </div>
    </div>
    <a href="">Contact</a>
  </nav>
</aside>
				
			
Responsive

To make your super vertical navigation responsive, use the following code before the .nav--super-vertical class.

				
<input type="checkbox" id="nav--super-vertical-responsive">
<label for="nav--super-vertical-responsive">MENU</label>
<nav class="nav--super-vertical g--2">
    ....
				
			

Tables

Number Name Age Job
521 Ben 23 Front End Dev
951 Zoe 21 Care Worker
444 Simon 22 Film Producer

Code

Simple use the HTML table elements along with the .table-header class for the header.

				
<table class="g--8 card">
  <tr class="table-header">
    <td>Number</td>
    <td>Name</td>
    <td>Age</td>
    <td>Job</td>
  </tr>
  <tr>
    <td>521</td>
    <td>Ben</td>
    <td>23</td>
    <td>Front End Dev</td>
  </tr>
  <tr>
    <td>951</td>
    <td>Zoe</td>
    <td>21</td>
    <td>Care Worker</td>
  </tr>
</table>
				
			

Tooltips

Tooltips are hidden snippets of information that show when the user hovers over.

Lorem ipsum tooltip

Lorem ipsum really loooooooooooong tooltip

Code

To use a tooltip, add an element with the class .tooltip and use data-text="" to specify the tooltips text.

				
<p>Lorem ipsum <span class="tooltip" data-text="Hello">tooltip</span></p>
<p>Lorem ipsum <span class="tooltip" data-text="Hello">really loooooooooooong tooltip</span></p>
				
			

Typography

The base elements of text.

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5
Heading 6

Pellentesque luctus scelerisque odio at euismod. Integer purus massa, varius eget justo sed, ultricies ornare massa. Suspendisse commodo tortor maximus magna pulvinar, vel porta ligula placerat. Sed feugiat tortor quis nisl mattis, nec lobortis nisi faucibus. Pellentesque sed risus vel nisl molestie tincidunt. In suscipit quis nisl et iaculis. Ut sit amet sodales odio. Aenean pretium nec velit eget dictum. Aenean vestibulum magna quis nunc iaculis, ut accumsan nisl accumsan. Nunc ante metus, accumsan sed ornare porta, finibus ac odio. Integer eu tempus lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam elementum, nulla a viverra tempor, lacus mauris auctor ex, quis pulvinar massa nulla id massa. Suspendisse convallis, ligula vitae auctor ultrices, lectus ex condimentum nisi, nec lobortis ipsum lectus et mauris. Phasellus ultricies mollis sapien, id elementum justo gravida non.

Subtitle

Code

Simply use the base HTML elements for text.

For emphasis on a subtitle, add the .subtitle class.

For white or black text, add the .color--white class or the .color--black class.

				
<h1>Heading 1</h1>
<h2 class="subtitle">Heading 2 which is a subtitle</h2>
<h3>Heading 3</h3>
<h4 class="color--white">Heading 4 which is white</h4>
				
			

Utility

A bunch of useful utility classes.

Code

Floats

Classes for floating and clearing elements.

				
<p class="left">I'm floating left.</p>
<p class="right">I'm floating right.</p>
<p class="clear">I'm clearing both.</p>
				
			

Display

Classes for changing the display attribute on an element.

				
<p class="inline">I'm inline.</p>
<p class="inline-block">I'm inline-block.</p>
<p class="block">I'm block.</p>
				
			

Padding & Margin

By default, the grid system will apply padding and vertical margins. To remove these, use these classes.

				
<div class="g--1 no-pad">I have no padding.</div>
<div class="g--1 no-margin">I have no margin.</div>
<div class="g--1 no-margin-vertical">I have no vertical margins.</div>
				
			

Centering

Classes for centering text or elements.

				
<p class="center">I have margin: 0 auto</p>
<p class="text-center">I have text-align: center</p>