Skip to content

MenuButton

Animated hamburger menu button that toggles between a three-line "burger" icon and an X (close) icon with a smooth CSS transition. Supports controlled and uncontrolled state.

Also known as: hamburger button, burger menu, nav toggle

View in Storybook

When to use

  • Toggling mobile or sidebar navigation menus.
  • Any context where a compact open/close trigger is needed.

Import

tsx
import { MenuButton } from '@vacano/ui'

Usage

tsx
<MenuButton />

Controlled

tsx
const [open, setOpen] = useState(false)

<MenuButton open={open} onOpenChange={setOpen} />

Sizes

tsx
<MenuButton size="compact" />
<MenuButton size="default" />

Disabled

tsx
<MenuButton disabled />

Props

PropTypeDefaultDescription
openboolean-Controlled open state. When provided, component becomes controlled.
defaultOpenbooleanfalseInitial open state for uncontrolled usage
onOpenChange(open: boolean) => void-Callback fired when the open state changes
size'compact' | 'default''default'Button size
disabledbooleanfalseDisables the button and prevents interaction
classNamestring-CSS class name for the root button element
classnamesMenuButtonClassNames-Custom class names for sub-elements
refRef<HTMLButtonElement>-Ref forwarded to the root button element
data-test-idstring-Test identifier attribute

The component also accepts all standard HTMLButtonElement attributes (except children and className which are overridden/excluded by the component).

KeyDescription
lineEach of the three animated lines

Released under the MIT License.