Components
Menu
TicFrame menus are semantic action and navigation lists with roving focus, selectable states, submenus, context menus, and responsive mega-menu behavior. They use only tf-* classes and framework-owned JavaScript.
Menus initialize automatically through
TicFrame.init(). Use buttons for actions, links for navigation, and UID-only Ticons classes when an icon is decorative.How It Works
Start with .tf-menu and .tf-menu-item. TicFrame applies role="menu", item roles, roving tabindex, orientation-aware arrow keys, disabled-item skipping, selected state, and framework events.
Keyboard model
Arrow keys move between enabled items. Home and End jump to the edges. Enter or Space activates checkable items and opens submenus.
Responsive model
Logical spacing, RTL-aware arrow direction, dark-mode tokens, scrollable panels, and mobile submenu stacking ship from TicFrame.
Accessibility
| Requirement | TicFrame behavior or guidance |
|---|---|
| Name | Every menu needs an accessible name through visible context or aria-label. |
| Roles | TicFrame adds role="menu" and role="menuitem" when omitted. Checkable items keep authored menuitemcheckbox or menuitemradio. |
| Keyboard | Arrow keys move focus. Home and End jump. Enter and Space activate checkable items and submenu triggers. |
| Dismissal | Submenus, context menus, and mega menus close on Escape and outside click. Focus returns to the trigger when closed from the keyboard. |
| Disabled state | Use native disabled on buttons or aria-disabled="true" when the item cannot be disabled natively. |
| RTL | Horizontal arrow movement and submenu arrows mirror automatically from document direction. |
API Reference
Classes
| Class | Purpose |
|---|---|
tf-menu, tf-menu-item | Required menu root and interactive item. |
tf-menu-horizontal, tf-menu-vertical, tf-menu-compact | Orientation and density variants. |
tf-menu-item-content, tf-menu-item-title, tf-menu-item-description, tf-menu-item-icon | Rich item anatomy. |
tf-menu-heading, tf-menu-divider, tf-menu-badge | Grouping and metadata helpers. |
tf-submenu, tf-submenu-trigger, tf-submenu-panel | Nested and multi-level menu surfaces. |
tf-context-menu, tf-command-menu, tf-menu-sidebar, tf-menu-drawer, tf-menu-tabs, tf-menu-scrollable | Specialized menu surfaces. |
tf-mega-menu, tf-mega-trigger, tf-mega-panel, tf-mega-grid, tf-mega-column, tf-mega-feature, tf-mega-cta, tf-mega-full | Mega-menu layout and content primitives. |
Attributes
| Attribute | Values | Description |
|---|---|---|
data-tf-menu-orientation | vertical, horizontal | Overrides automatic orientation detection. |
data-tf-menu-submenu | Selector or controlled id | Connects a menu item to its submenu panel. |
data-tf-menu-group | String | Groups radio menu items so only one can be checked. |
data-tf-context-menu | Menu selector | Attaches a context menu to a target region. |
data-tf-mega-menu | Presence | Marks a custom mega-menu root when the class is not present. |
data-tf-mega-trigger | Presence | Marks the mega-menu disclosure trigger. |
data-tf-mega-mode | click, hover, both | Chooses desktop opening behavior. Keyboard support is always enabled. |
Methods and events
| Method or event | Purpose |
|---|---|
TicFrame.Menu.open(target) | Opens a hidden menu or panel and marks it data-state="open". |
TicFrame.Menu.close(target) | Hides a menu or panel and marks it data-state="closed". |
TicFrame.Menu.toggle(target) | Toggles hidden/open state. |
TicFrame.Menu.highlight(menu, itemOrIndex) | Moves roving focus to an item or enabled item index. |
tf:menu:highlight, tf:menu:select, tf:menu:change | Fire when focus, activation, or check state changes. |
tf:context-menu:open, tf:context-menu:close, tf:mega-menu:open, tf:mega-menu:close | Fire from the corresponding disclosure surfaces. |
JavaScript
const menu = document.querySelector("#project-menu");
TicFrame.Menu.open(menu);
TicFrame.Menu.highlight(menu, 1);
TicFrame.Menu.close(menu);
Tokens and Troubleshooting
| Token or issue | Resolution |
|---|---|
--tf-menu-min-inline-size | Controls menu width. Override through a theme or component scope, not website CSS. |
--tf-menu-max-block-size | Used by tf-menu-scrollable for tall menus. |
--tf-menu-item-padding-* | Controls menu item spacing and inherits density choices. |
--tf-mega-panel-inline-size | Controls mega panel width. |
| Menu appears in the TOC | Keep preview headings inside tf-doc-example or add data-tf-toc-ignore. |
| Submenu does not open | Confirm the trigger has data-tf-menu-submenu and the target panel id exists. |
| Screen reader does not announce a menu purpose | Add aria-label or wrap the menu in a labelled navigation landmark. |