Hamburger
Eighteen animated menu icons for the button that opens your mobile menu. The lines turn into a close icon when the menu opens and turn back when it closes. Every animation uses the same rounded line, and you set its width, thickness and colour.
It is Bricks' own Toggle underneath, so it opens your Offcanvas or Nav (Nestable) exactly like the native one. Hamburger is a Free widget: it works as soon as the companion plugin is installed.
Requires: no animation library. The animations are CSS; a small script only starts the Morph animation and keeps Retract & turn from playing on page load.
Where to find it#
| How | Where |
|---|---|
| As an element | Elements panel › Bricksify › Hamburger |
| As a control group | Hamburger (Bricksify) on the native Toggle. Pick an Animation and it replaces the Toggle's bars. Leave the Toggle's Icon setting empty: with a custom icon set, the Toggle keeps that icon. |
The control group is handy on a header you already have: the Toggle's CSS selector, aria-label and Offcanvas or Nav keep working as before. See How widgets work.
Settings#
| Setting | Options and default | What it does |
|---|---|---|
| Animation | The eighteen below. On the element the default is Converge; in the control group it is None (Bricks bars), which leaves the Toggle as it was. | Which icon and animation you get. |
| Width (px) | Default 32 | Length of the lines. The height follows the animation's own proportions. |
| Line thickness (px) | Default 3 | The real thickness of the lines in pixels, whatever the animation. |
| Line color | Default: the element's text colour | Colour of the lines. |
| aria-label (element) | Default Open | What screen readers announce for the button. Bricks' own Toggle setting. |
| CSS selector, Attribute, Value (element, under Toggle) | Defaults .brxe-offcanvas, class, brx-open | What the button opens, exactly as on the native Toggle. Copy the ID of the element you want to toggle and paste it into CSS selector. |
Width, Line thickness and Line color can be set per breakpoint, like any Bricks style setting. The element has no bar or icon settings of the native Toggle: the hamburger replaces them. Timings and curves are the originals' and are not settings.
The animations#
| Animation | What it does when the menu opens |
|---|---|
| Converge | The outer lines meet in the middle, then rotate into an X. |
| Shrink & cross | The lines shrink to the centre, then the X grows from it. |
| Split | Each line is two halves: the outer halves fold into the X, the middle one splits apart. |
| Fold | The outer lines halve, then fold; the middle one tilts. |
| Collapse | The outer lines collapse with a little anticipation, then rotate. |
| Spin | The icon turns half a turn with a spring while the lines cross. |
| Wipe | The lines shrink towards their ends while both arms of the X draw in. |
| Wipe in sequence | The same, with the arms drawn one after the other. |
| Cascade | The lines erase to the right one by one, then the arms draw. |
| Slide away | The lines slide right and fade one by one, then the arms draw. |
| Spring away | The lines spring out to the right with an overshoot, then the arms draw. |
| Swirl | The lines run along curves into an X. |
| Morph | The lines bend into an X. |
| Circle | An X inside a circle, drawn from the middle line. |
| Retract & turn (2 lines) | Two lines retract, turn and redraw while the icon spins. |
| Loop (2 lines) | One stroke travels round a loop into an X. |
| Glide (2 lines, hover) | Two lines that glide on hover and cross when open. The hover move only happens on devices with a mouse or trackpad. |
| Twin cross (2 lines, spring) | Two lines 10px apart cross into an X on a spring that overshoots slightly. The gap stays 10px at any width. |
Swirl, Circle and Loop draw outside the box of the closed icon while they move, as the originals do. Leave a little room around the button.
How it behaves#
- Bricks' own toggle script opens and closes the menu and marks the button as active. The icon animates from that, so it also turns back when the Offcanvas closes from its backdrop, the Esc key or a link.
- It is a real
<button>: it can be reached with Tab and pressed with Enter or Space. Bricks keepsaria-expandedup to date, and the drawn icon is hidden from screen readers, so they hear the aria-label only. - The icon is an SVG written by the server, so it is sharp at any size and is there before any script runs.
- On a touch screen there is nothing to hover, so tapping simply opens the menu and plays the animation.
Reduced motion and without JavaScript#
For a visitor who has asked for reduced motion, the icon jumps straight to its open or closed shape, with no movement in between.
Without JavaScript the icon still shows. Opening the menu is Bricks' toggle script, exactly as with the native Toggle.
Without the plugin, a Toggle that uses the control group shows Bricks' own bars again and keeps working. The Hamburger element needs the plugin to render.