All Projects → jonsuh → Hamburgers

jonsuh / Hamburgers

Licence: mit
Tasty CSS-animated Hamburgers

Programming Languages

CSS
56736 projects
javascript
184084 projects - #8 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Hamburgers

menu-hamburger
🍔 A clean, simple and easy to use library to create a Menu Hamburger
Stars: ✭ 17 (-99.74%)
Mutual labels:  menu, hamburger
vue-burger-button
🍔 vue-burger-button is a functional component, which is faster than a regular component, and is pretty small (JS min+gzip is lower than 700b and CSS min+gzip is lower than 400b).
Stars: ✭ 41 (-99.37%)
Mutual labels:  menu, hamburger
Quickmenu
The new era of mobile navigation for the web, we're out of hamburgers.
Stars: ✭ 119 (-98.18%)
Mutual labels:  menu, sass
Slinky
A light-weight, responsive, mobile-like navigation menu plugin
Stars: ✭ 649 (-90.05%)
Mutual labels:  menu, sass
Eyeglass
NPM Modules for Sass
Stars: ✭ 741 (-88.64%)
Mutual labels:  sass
Backslide
💦 CLI tool for making HTML presentations with Remark.js using Markdown
Stars: ✭ 679 (-89.59%)
Mutual labels:  sass
Boommenu
A menu which can ... BOOM! - Android
Stars: ✭ 5,753 (-11.79%)
Mutual labels:  menu
Wmzdialog
功能最多样式最多的弹窗,支持普通/微信底部/日期/地区/日历/选择/编辑/分享/菜单/自定义弹窗等,支持多种动画,链式编程调用(Pop-up windows with the most functions and styles, support normal/WeChat bottom/date/region/calendar/select/edit/share/menu/custom pop-up windows, etc., support multiple animations, chain programming calls)
Stars: ✭ 673 (-89.68%)
Mutual labels:  menu
Responsive
📱 A super lightweight HTML, Sass, CSS, and JavaScript framework for building responsive websites
Stars: ✭ 772 (-88.16%)
Mutual labels:  sass
Snippetstore
🎉 A snippet management app for developers 🚀
Stars: ✭ 762 (-88.32%)
Mutual labels:  sass
Popover
一款优雅易用的类似QQ和微信消息页面的右上角微型菜单弹窗
Stars: ✭ 732 (-88.78%)
Mutual labels:  menu
Design System Components
🛠 Component code and tests for the Australian Government design system
Stars: ✭ 696 (-89.33%)
Mutual labels:  sass
Anylayer
Android稳定高效的浮层创建管理框架
Stars: ✭ 745 (-88.58%)
Mutual labels:  menu
Generator M Ionic
Advanced workflows and setup for building rock-solid Ionic apps
Stars: ✭ 677 (-89.62%)
Mutual labels:  sass
React Carousel
A pure extendable React carousel, powered by Brainhub (craftsmen who ❤️ JS)
Stars: ✭ 764 (-88.29%)
Mutual labels:  sass
Wordpress Gulp Starter Kit
[NOT MAINTAINED] A starter kit for developing WordPress themes with Gulp.
Stars: ✭ 674 (-89.67%)
Mutual labels:  sass
Vue Music Player
🎵Vue.js写一个音乐播放器+📖One(一个).A music player + One by Vue.js
Stars: ✭ 729 (-88.82%)
Mutual labels:  sass
Generator Angular Fullstack
Yeoman generator for an Angular app with an Express server
Stars: ✭ 6,135 (-5.93%)
Mutual labels:  sass
Cirrus
☁️ The CSS framework for the modern web.
Stars: ✭ 716 (-89.02%)
Mutual labels:  sass
Material Dashboard Lite
A free dashboard template with material design lite
Stars: ✭ 705 (-89.19%)
Mutual labels:  sass

Hamburgers

Hamburgers is a collection of tasty CSS-animated hamburger icons. Also included is the source as a Sass library. It’s modular and customizable, so cook up your own hamburger.

Table of Contents

Usage

  1. Download and include the CSS in the <head> of your site:
<link href="dist/hamburgers.css" rel="stylesheet">
  1. Add the base hamburger markup:
<button class="hamburger" type="button">
  <span class="hamburger-box">
    <span class="hamburger-inner"></span>
  </span>
</button>  

You can use <div>s if you insist, but they’re not accessible as a menu button.

<div class="hamburger">
  <div class="hamburger-box">
    <div class="hamburger-inner"></div>
  </div>
</div>
  1. Append the class name of the type of hamburger you’re craving:
<button class="hamburger hamburger--collapse" type="button">
  <span class="hamburger-box">
    <span class="hamburger-inner"></span>
  </span>
</button>

Here’s the list of hamburger-type classes you can choose from:

hamburger--3dx
hamburger--3dx-r
hamburger--3dy
hamburger--3dy-r
hamburger--3dxy
hamburger--3dxy-r
hamburger--arrow
hamburger--arrow-r
hamburger--arrowalt
hamburger--arrowalt-r
hamburger--arrowturn
hamburger--arrowturn-r
hamburger--boring
hamburger--collapse
hamburger--collapse-r
hamburger--elastic
hamburger--elastic-r
hamburger--emphatic
hamburger--emphatic-r
hamburger--minus
hamburger--slider
hamburger--slider-r
hamburger--spin
hamburger--spin-r
hamburger--spring
hamburger--spring-r
hamburger--stand
hamburger--stand-r
hamburger--squeeze
hamburger--vortex
hamburger--vortex-r

Note: -r classes are reverse variants (e.g. hamburger--spin spins clockwise whereas hamburger--spin-r spins counterclockwise.

  1. Trigger the active state by appending class name is-active:
<button class="hamburger hamburger--collapse is-active" type="button">
  <span class="hamburger-box">
    <span class="hamburger-inner"></span>
  </span>
</button>

Since the class name would have to be toggled via JavaScript and implementation would differ based on the context of how you plan on using the hamburger, I’m going to leave the rest up to you.

Sass

.scss source files are available if you use Sass as your CSS precompiler. It’s customizable and modular.

  1. Hamburgers is available on npm, yarn and Bower.
npm install hamburgers

yarn add hamburgers

bower install css-hamburgers

Also available as a Ruby gem to use within your Rails application—see below for more information.

Or to manually install it, download and unzip the source files, then copy the files from the _sass/hamburgers directory into your project.

  1. Import the hamburgers.scss file in your Sass manifest file:
@import "path/to/hamburgers";
  1. Customize your hamburger and/or remove any types you don’t want in hamburgers.scss.
  2. Compile your Sass*, and voila!

* Be sure to run the CSS through Autoprefixer since the Sass doesn’t account for vendor prefixes.

Install for Ruby on Rails

  1. Add Hamburgers to your Gemfile.
gem 'hamburgers'
  1. Run bundle install.
  2. Include Hamburgers by using Sass’s native @import**:
// application.scss
@import "hamburgers";

** More information on why Sass’s native @import + why you should ditch Sprockets directives altogether.

Customization

To override default settings, declare them before importing Hamburgers:

$hamburger-padding-x: 20px;
$hamburger-padding-y: 15px;
$hamburger-types     : (collapse);

@import "hamburgers";

You can also create a separate file (e.g. hamburgers-settings.scss) with those declarations, then import it before Hamburgers:

@import "hamburgers-settings"
@import "hamburgers";

Here is the full list of default settings (found in _sass/hamburgers/hamburgers.scss);

$hamburger-padding-x           : 15px;
$hamburger-padding-y           : 15px;
$hamburger-layer-width         : 40px;
$hamburger-layer-height        : 4px;
$hamburger-layer-spacing       : 6px;
$hamburger-layer-color         : #000;
$hamburger-layer-border-radius : 4px;
$hamburger-hover-opacity       : 0.7;
$hamburger-active-layer-color  : $hamburger-layer-color;
$hamburger-active-hover-opacity: $hamburger-hover-opacity;

// To use CSS filters as the hover effect instead of opacity,
// set $hamburger-hover-use-filter as true and
// change the value of $hamburger-hover-filter accordingly.
$hamburger-hover-use-filter   : false;
$hamburger-hover-filter       : opacity(50%);
$hamburger-active-hover-filter: $hamburger-hover-filter;

// Remove or comment out the hamburger types you don’t want
// or need, so they get excluded from the compiled CSS.
$hamburger-types: (
  3dx,
  3dx-r,
  3dy,
  3dy-r,
  3dxy,
  3dxy-r,
  arrow,
  arrow-r,
  arrowalt,
  arrowalt-r,
  arrowturn,
  arrowturn-r,
  boring,
  collapse,
  collapse-r,
  elastic,
  elastic-r,
  emphatic,
  emphatic-r,
  minus,
  slider,
  slider-r,
  spring,
  spring-r,
  stand,
  stand-r,
  spin,
  spin-r,
  squeeze,
  vortex,
  vortex-r
);

ems or rems

Wanna work with ems or rems instead of px? Just change all the px values to the unit of your choice. Note: Be consistent (all px or all ems), otherwise it may break—the math behind the customization will fail if it attempts to perform operations with values of different units.

Not satisfied?

Dig into _base.scss or types/ and customize to your heart’s content. Fair warning: It‘s pretty delicate and may break, especially if you tweak the animations themselves.

Accessibility

Hamburger menu icons can be useful in the right context, but they’re not the most accessible.

ARIA will help make it accessible to people with disabilities.

<nav>
  <button class="hamburger hamburger--elastic" type="button"
          aria-label="Menu" aria-controls="navigation" aria-expanded="true/false">
    <span class="hamburger-box">
      <span class="hamburger-inner"></span>
    </span>
  </button>

  <div id="navigation">
    <!--navigation goes here-->
  </div>
</nav>

You will need JavaScript to toggle between aria-expanded attribute being set to true and false, as this will indicate to visually impaired users whether the menu is opened or closed.

The hamburger button belongs inside the <nav> so that assistive technologies will be able to locate the navigation, and to allow these users to easily locatate the hamburger button, without having to search up and down the DOM, once they realize they've found themselves in an empty navigation.

If you insist on using <div>s, by default they’re not focusable (i.e. via keyboard or assistive technology). Add the tabindex attribute alongside ARIA. You will also need to recreate expected keyboard functionality for these <div>s. Using JavaScript, you will need to make sure that both Space and Enter will toggle the hamburger states.

<nav id="navigation">

  <div class="hamburger hamburger--elastic" tabindex="0"
       aria-label="Menu" role="button" aria-controls="navigation" aria-expanded="true/false">
    <div class="hamburger-box">
      <div class="hamburger-inner"></div>
    </div>
  </div>

  <div id="navigation">
    <!--navigation goes here-->
  </div>
</nav>

A label will help make it more obvious that it toggles a menu.

<button class="hamburger hamburger--collapse" type="button">
  <span class="hamburger-box">
    <span class="hamburger-inner"></span>
  </span>
  <span class="hamburger-label">Menu</span>
</button>

Here are some resources on web accessibility and ARIA.

Browser Support

Animations use CSS3 3D transforms (translate3d whenever possible for GPU acceleration), which is supported by most browsers (not supported by IE9 and older and Opera Mini). For detailed browser support, check caniuse.com.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].