Getting Started
Components
- Advanced Toast
- ArrowButton
- Arrows
- Avatar
- Backdrop
- Basic Toast
- Breadcrumb
- Button
- CardBackground
- Card
- ChatButton
- Checkbox
- Checkboxes
- Chip
- ChoiceExpander
- Clickable
- Date Field
- Dropdown
- ElasticHeight
- ExpandableCard
- Filter
- FormCheckbox
- Form Control
- Form Label
- HamburgerIcon
- Heading
- Image
- Link
- Loader
- Number Field
- Pagination
- Password
- Phone Field
- Popin
- Portal
- Prose
- Radio Group
- Radio
- Range
- Select
- SidebarLayout
- Spinner
- Switch
- Tabs
- Tag
- TextField
- ValidationMessage
'use client';
import { useState } from 'react';
import { HamburgerIcon } from '@/ui/HamburgerIcon';
export function HamburgerIconDemo() {
const [isActive, setIsActive] = useState(false);
return (
<button
onClick={() => setIsActive(!isActive)}
className="p-4 rounded hover:bg-gray-100"
aria-label={isActive ? 'Close menu' : 'Open menu'}
>
<HamburgerIcon isActive={isActive} />
</button>
);
}
Installation
npx shadcn@latest add https://develop.trident-ui.pro.clubmed/r/hamburger-icon.json
Usage
import { useState } from 'react';
import { HamburgerIcon } from '@/docs/lib/ui/hamburger-icon';
export function Component() {
const [isMenuOpen, setIsMenuOpen] = useState(false);
return (
<button
onClick={() => setIsMenuOpen(!isMenuOpen)}
aria-label={isMenuOpen ? 'Close menu' : 'Open menu'}
>
<HamburgerIcon isActive={isMenuOpen} />
</button>
);
}API Reference
HamburgerIcon
| Prop | Type | Default | Description |
|---|---|---|---|
isActive | boolean | false | Controls the icon's state. When true, displays an "X" (close icon). When false, displays the hamburger menu icon. |
className | string | undefined | Additional CSS classes to apply to the container span element. Merged with default styles. |
| ... | ComponentPropsWithoutRef<"span"> | - | All standard HTML span element attributes are supported (e.g., id, onClick, data-*, aria-*). |
Notes
- Animated Transitions: The icon smoothly animates between hamburger and X states with a 500ms transition duration using CSS transforms
- Color Control: Uses
currentColorfor the icon color, so it inherits the text color from its parent element - Fixed Size: The icon has a fixed size of 24px × 24px (w-24 h-24 in Tailwind) with three lines that are 2px thick
- Cursor Pointer: The icon has
cursor-pointerclass applied by default, indicating it's meant to be clickable - Data Attributes: Sets
data-name="HamburgerIcon"anddata-testidbased on theisActivestate for testing purposes - CSS-Only Animation: The animation is purely CSS-based using pseudo-elements (::before, ::after) and the middle line, providing smooth performance
- Accessibility: Should be wrapped in a button element with appropriate
aria-labelthat describes the current state (e.g., "Open menu" or "Close menu")