-
Notifications
You must be signed in to change notification settings - Fork 13
feat: menubar component #689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rohanchkrabrty
wants to merge
1
commit into
main
Choose a base branch
from
feat-menubar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| 'use client'; | ||
|
|
||
| import { Flex, Menu, Menubar } from '@raystack/apsara'; | ||
| import PlaygroundLayout from './playground-layout'; | ||
|
|
||
| export function MenubarExamples() { | ||
| return ( | ||
| <PlaygroundLayout title='Menubar'> | ||
| <Flex direction='column' gap='large'> | ||
| <Menubar> | ||
| <Menu> | ||
| <Menu.Trigger>File</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>New Tab</Menu.Item> | ||
| <Menu.Item>New Window</Menu.Item> | ||
| <Menu.Separator /> | ||
| <Menu.Item>Print</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu> | ||
| <Menu.Trigger>Edit</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>Undo</Menu.Item> | ||
| <Menu.Item>Redo</Menu.Item> | ||
| <Menu.Separator /> | ||
| <Menu.Item>Cut</Menu.Item> | ||
| <Menu.Item>Copy</Menu.Item> | ||
| <Menu.Item>Paste</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu> | ||
| <Menu.Trigger>View</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>Zoom In</Menu.Item> | ||
| <Menu.Item>Zoom Out</Menu.Item> | ||
| <Menu.Separator /> | ||
| <Menu.Item>Fullscreen</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| </Menubar> | ||
| </Flex> | ||
| </PlaygroundLayout> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| 'use client'; | ||
|
|
||
| export const preview = { | ||
| type: 'code', | ||
| code: ` | ||
| <Menubar> | ||
| <Menu> | ||
| <Menu.Trigger>File</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>New Tab</Menu.Item> | ||
| <Menu.Item>New Window</Menu.Item> | ||
| <Menu.Separator /> | ||
| <Menu.Submenu> | ||
| <Menu.SubmenuTrigger>Share</Menu.SubmenuTrigger> | ||
| <Menu.SubmenuContent> | ||
| <Menu.Item>Email Link</Menu.Item> | ||
| <Menu.Item>Messages</Menu.Item> | ||
| </Menu.SubmenuContent> | ||
| </Menu.Submenu> | ||
| <Menu.Separator /> | ||
| <Menu.Item>Print</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu> | ||
| <Menu.Trigger>Edit Action</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>Undo Action</Menu.Item> | ||
| <Menu.Item>Redo Action</Menu.Item> | ||
| <Menu.Separator /> | ||
| <Menu.Item>Cut</Menu.Item> | ||
| <Menu.Item>Copy</Menu.Item> | ||
| <Menu.Item>Paste</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu> | ||
| <Menu.Trigger>View</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>Zoom In</Menu.Item> | ||
| <Menu.Item>Zoom Out</Menu.Item> | ||
| <Menu.Separator /> | ||
| <Menu.Item>Fullscreen</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| </Menubar>` | ||
| }; | ||
|
|
||
| export const verticalDemo = { | ||
| type: 'code', | ||
| code: ` | ||
| <Menubar orientation="vertical"> | ||
| <Menu> | ||
| <Menu.Trigger>File</Menu.Trigger> | ||
| <Menu.Content side="right"> | ||
| <Menu.Item>New</Menu.Item> | ||
| <Menu.Item>Open</Menu.Item> | ||
| <Menu.Item>Save</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu> | ||
| <Menu.Trigger>Edit</Menu.Trigger> | ||
| <Menu.Content side="right"> | ||
| <Menu.Item>Undo</Menu.Item> | ||
| <Menu.Item>Redo</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| </Menubar>` | ||
| }; | ||
|
|
||
| export const autocompleteDemo = { | ||
| type: 'code', | ||
| code: ` | ||
| <Menubar> | ||
| <Menu> | ||
| <Menu.Trigger>Settings</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>Preferences</Menu.Item> | ||
| <Menu.Item>Themes</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu autocomplete> | ||
| <Menu.Trigger>Actions</Menu.Trigger> | ||
| <Menu.Content searchPlaceholder="Search actions..."> | ||
| <Menu.Group> | ||
| <Menu.Label>General</Menu.Label> | ||
| <Menu.Item>Assign member...</Menu.Item> | ||
| <Menu.Item>Subscribe...</Menu.Item> | ||
| <Menu.Item>Rename...</Menu.Item> | ||
| </Menu.Group> | ||
| <Menu.Separator /> | ||
| <Menu.Group> | ||
| <Menu.Label>Editing</Menu.Label> | ||
| <Menu.Item>Copy</Menu.Item> | ||
| <Menu.Item value="remove">Delete...</Menu.Item> | ||
| </Menu.Group> | ||
| </Menu.Content> | ||
| </Menu> | ||
| </Menubar>` | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --- | ||
| title: Menubar | ||
| description: A horizontal menu bar providing commands and options for your application, typically used at the top of a window. | ||
| source: packages/raystack/components/menubar | ||
| tag: new | ||
| --- | ||
|
|
||
| import { preview, verticalDemo, autocompleteDemo } from "./demo.ts"; | ||
|
|
||
| <Demo data={preview} /> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```tsx | ||
| import { Menu, Menubar } from '@raystack/apsara' | ||
|
|
||
| <Menubar> | ||
| <Menu> | ||
| <Menu.Trigger>File</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>New</Menu.Item> | ||
| <Menu.Item>Open</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| <Menu> | ||
| <Menu.Trigger>Edit</Menu.Trigger> | ||
| <Menu.Content> | ||
| <Menu.Item>Undo</Menu.Item> | ||
| <Menu.Item>Redo</Menu.Item> | ||
| </Menu.Content> | ||
| </Menu> | ||
| </Menubar> | ||
| ``` | ||
|
|
||
| The `Menubar` component wraps multiple `Menu` instances. Menu triggers are automatically styled when inside a Menubar. If you pass a `render` prop to `Menu.Trigger`, the default menubar trigger styling is skipped, allowing full custom rendering. | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### Root | ||
|
|
||
| The container element for the menubar. | ||
|
|
||
| <auto-type-table path="./props.ts" name="MenubarProps" /> | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Vertical | ||
|
|
||
| Use the `orientation` prop to render a vertical menubar. | ||
|
|
||
| <Demo data={verticalDemo} /> | ||
|
|
||
| ### Autocomplete | ||
|
|
||
| Use the `autocomplete` prop on `Menu` to enable search filtering within a menubar menu. | ||
|
|
||
| <Demo data={autocompleteDemo} /> | ||
|
|
||
| ## Accessibility | ||
|
|
||
| - Uses `role="menubar"` for proper ARIA semantics | ||
| - Supports keyboard navigation between menu triggers using arrow keys | ||
| - `loopFocus` cycles focus from last to first trigger (enabled by default) | ||
| - Each menu trigger opens its dropdown on click or Enter/Space |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { ReactElement } from 'react'; | ||
|
|
||
| export interface MenubarProps { | ||
| /** | ||
| * Whether the menubar is modal. | ||
| * @defaultValue true | ||
| */ | ||
| modal?: boolean; | ||
|
|
||
| /** | ||
| * Whether the whole menubar is disabled. | ||
| * @defaultValue false | ||
| */ | ||
| disabled?: boolean; | ||
|
|
||
| /** | ||
| * The orientation of the menubar. | ||
| * @defaultValue "horizontal" | ||
| */ | ||
| orientation?: 'horizontal' | 'vertical'; | ||
|
|
||
| /** | ||
| * Whether to loop keyboard focus back to the first item when the end of the list is reached. | ||
| * @defaultValue true | ||
| */ | ||
| loopFocus?: boolean; | ||
|
|
||
| /** Additional CSS class names */ | ||
| className?: string; | ||
|
|
||
| /** Replaces the rendered element with a custom one via Base UI's render prop pattern */ | ||
| render?: ReactElement; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
@base-ui/react Menubar component props API💡 Result:
@base-ui/react/menubarexports a single<Menubar />root component. Its props API is: (base-ui.com)loopFocus?: boolean(default:true) — Loop arrow-key focus from last item back to first.modal?: boolean(default:true) — Whether the menubar is modal.disabled?: boolean(default:false) — Disables the whole menubar.orientation?: 'horizontal' | 'vertical'(default:'horizontal') — Menubar orientation.className?: string | ((state: Menubar.State) => string | undefined)— Static or state-based class.style?: React.CSSProperties | ((state: Menubar.State) => React.CSSProperties | undefined)— Static or state-based inline styles.render?: ReactElement | ((props: HTMLProps, state: Menubar.State) => ReactElement)— Replace/compose the underlying element.Citations:
Add missing
styleprop and complete type signatures forclassNameandrender.The documented props are incomplete.
@base-ui/react's Menubar supports:classNameandrenderwith function overloads for state-based dynamic values:className?: string | ((state: Menubar.State) => string | undefined)andrender?: ReactElement | ((props: HTMLProps, state: Menubar.State) => ReactElement)styleprop (completely missing from documentation):style?: React.CSSProperties | ((state: Menubar.State) => React.CSSProperties | undefined)🤖 Prompt for AI Agents