4.0.5 • Published 11 months ago

ceilbit-hamburgers v4.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

🍔 Svelte Hamburgers

The ease to use Hamburger menu component for Svelte! Fully customisable with an extensive set of options, powered by a modified version of hamburgers.css.

Example of how to use svelte-hamburgers, view the repl here npm.io

Install

We will save it as a dev dependancy with -D

npm i svelte-hamburgers -D

How to use?

<script>
    import { Hamburger } from 'svelte-hamburgers';

    let open;
</script>

<Hamburger bind:open />

The open variable can be then used to handle your menu, for example:

{#if open}
    <!-- show menu -->
{/if}

Migrating

If you are migrating from 3.x.x to 4.x.x heres what you need to know:

  • CSS is now included! This means no more importing the css you need, you can remove the cdn tags you had before

  • The Hamburger component is a named import:

    <script>
        // Old way
        import Hamburger from 'svelte-hamburgers';
    
        // New way
        import { Hamburger } from 'svelte-hamburgers';
    </script>

Properties

You can use these to customise the hamburger, just provide them as props to the burger component, for example <Hamburger --color="white" />

PropertyTypeDefaultDescription
typestringspinThe type of burger you want, you can see the types here, it should be lowercase.
--colorstringblackThe color of the burger.
--active-colorstringvalue of --colorThe color of the burger when active.
--paddingstring15pxThe padding.
--layer-widthstring30pxThe width of the burger.
--layer-heightstring2pxThe height of the burger.
--layer-spacingstring6pxThe spacing between layers of the burger.
--border-radiusstring4pxThe border radius of each burger part.
--hover-opacitynumber0.7The opacity amount on hover.
--hover-opacity-activenumbervalue of --hover-opacityThe opacity amount of hover when active.

Support