Use a hamburger button to toggle a menu or other content. The button can be styled with global
classes such as Tailwind utility classes and other configuration options. Bind the active
prop to
a boolean value to control the button state. Clicking the button will toggle the state of active
.
<script>
import { Hamburger } from '$lib/ui';
let isMenuOpen = $state(false);
</script>
<Hamburger bind:active={isMenuOpen} />
<p>isMenuOpen: {isMenuOpen}</p>
isMenuOpen: false
Name | Type | Default | Description |
---|---|---|---|
active | Boolean | false | Typically used with bind:active to bind the active state to parent component |
Name | Type | Default | Description |
---|---|---|---|
--ui-hamburger-width | Numeric | 30px | Overall width of Hamburger component |
--ui-hamburger-height | Numeric | --ui-hamburger-width * .75 | Overall height of Hamburger component |
--ui-hamburger-padding | Numeric | --ui-hamburger-width * .3 | Padding and negative margin value (for larger clickable area) |
--ui-hamburger-background | Color | transparent | Background color of Hamburger |
--ui-hamburger-border | Border shorthand | none | CSS shorthand for border width/style/color |
--ui-hamburger-border-radius | Numeric | --ui-border-radius or 3px | Border radius Hamburger component |
--ui-hamburger-line-color | Color | --ui-dark or #222 | Color of Hamburger lines |
--ui-hamburger-line-thickness | Numeric | 2px | Thickness (height) of Hamburger lines |
--ui-hamburger-line-radius | Numeric | 2px | Border radius of Hamburger lines |
--ui-hamburger-spins-number | Integer (odd) | 5 | Number of spins on animation. Must be an odd number! |
--ui-hamburger-spins-duration | Time (s or ms ) | 150ms | Duration of spin animation |