# Hamburger toggle

> Three bars morph into an X on press.

A shadcn/ui block from the [@flx](https://ui.flexnative.com) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/flx/button-15).

- Page, with a live preview: https://shadcn.exchange/r/flx/button-15
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/flx/button-15-light-8f54771d4803a750.png
- Registry item: https://ui.flexnative.com/r/button-15.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.flexnative.com/r/button-15.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `button`

## Files

### `registry/patterns/button/button-15.tsx`

```tsx
'use client'

import { useState } from 'react'

import { Button } from '@/components/ui/button'

export function Button15() {
  const [open, setOpen] = useState(false)

  return (
    <Button
      variant="outline"
      size="icon"
      aria-label={open ? 'Close menu' : 'Open menu'}
      aria-pressed={open}
      onClick={() => setOpen((v) => !v)}
      className="group/hamburger"
      data-state={open ? 'open' : 'closed'}
    >
      <span className="relative flex size-4 flex-col items-center justify-center">
        <span className="absolute h-0.5 w-4 -translate-y-1.5 rounded-full bg-current transition-transform duration-200 group-data-[state=open]/hamburger:translate-y-0 group-data-[state=open]/hamburger:rotate-45" />
        <span className="absolute h-0.5 w-4 rounded-full bg-current transition-opacity duration-200 group-data-[state=open]/hamburger:opacity-0" />
        <span className="absolute h-0.5 w-4 translate-y-1.5 rounded-full bg-current transition-transform duration-200 group-data-[state=open]/hamburger:translate-y-0 group-data-[state=open]/hamburger:-rotate-45" />
      </span>
    </Button>
  )
}
```
