# Hamburger — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/hamburger

Category: Foundations

Animated hamburger menu icon that toggles to an X. Supports customizable colors, stroke width, state binding, and callbacks.

Public component import: `Hamburger`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Hamburger, Button, create_button_manager } from "sveltekit-ui"

  let is_open = $state(false)
  const overview_button = create_button_manager({
    text: "Overview",
    href: "#overview",
    type: "plain",
    on_click: () => { is_open = false },
  })
</script>

<Hamburger val={is_open} on_change={(value) => { is_open = value }} />
{#if is_open}
  <nav aria-label="Example menu"><Button manager={overview_button} /></nav>
{/if}
<section id="overview"><h2>Overview</h2><p>Toggle the menu above.</p></section>
```

## Properties

### `val`

- type: boolean
- default: false
- description: Represents the current state of the hamburger icon. `false` for hamburger, `true` for X.

### `is_bind_val`

- type: boolean
- default: false
- description: If `true`, the component manages its own `val` state internally. If `false`, the state is controlled externally.

### `color_base`

- type: CSS color
- default: var(--g14-t)
- description: Base color of the hamburger lines.

### `color_hover`

- type: CSS color
- default: var(--primary-t)
- description: Color of the hamburger lines when hovered.

### `sw`

- type: number
- default: 30
- description: Stroke width of the hamburger lines.

### `on_change`

- type: function
- default: null
- description: Callback function triggered when the hamburger icon is toggled. Receives the new `val` state as an argument.
