Skip to content

feat(CommandPalette): handle children in items #4226

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

Merged
merged 37 commits into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
176ad4e
feat(CommandPalette): handle subcommands
HugoRCD May 26, 2025
be1ea9d
Merge remote-tracking branch 'origin/v3' into feat/command-palette-su…
HugoRCD May 26, 2025
36a942d
up
HugoRCD May 26, 2025
18818aa
up
HugoRCD May 26, 2025
7cd7fd4
up
HugoRCD May 26, 2025
ea83d0c
up
HugoRCD May 26, 2025
2b22ad6
up
HugoRCD May 27, 2025
0c28b46
up
HugoRCD May 27, 2025
69f1f1b
Merge remote-tracking branch 'origin/v3' into feat/command-palette-su…
HugoRCD May 27, 2025
b99c2d3
up
HugoRCD May 27, 2025
ef33057
up
benjamincanac May 27, 2025
57da5f9
up
HugoRCD May 27, 2025
a718130
remove breadcrumb
HugoRCD May 27, 2025
e6b7c18
up
HugoRCD May 27, 2025
78ff4fa
up
HugoRCD May 27, 2025
22ea201
remove root locale
HugoRCD May 27, 2025
ed232f5
Merge branch 'v3' into feat/command-palette-submenu
benjamincanac May 28, 2025
851b585
reapply ignoreFilter
HugoRCD May 28, 2025
da0e6c7
Merge remote-tracking branch 'origin/v3' into feat/command-palette-su…
HugoRCD May 28, 2025
1d504ac
up
HugoRCD May 28, 2025
ae1c245
up
HugoRCD May 28, 2025
b2d2c4f
up
HugoRCD May 28, 2025
76d2640
Merge branch 'v3' into feat/command-palette-submenu
benjamincanac May 30, 2025
ceccd70
up
benjamincanac May 30, 2025
48ab76c
up
benjamincanac May 30, 2025
2c1ca3c
Merge branch 'v3' into feat/command-palette-submenu
HugoRCD Jun 3, 2025
3b774c2
Merge branch 'v3' into feat/command-palette-submenu
HugoRCD Jun 11, 2025
bdc75a2
up
HugoRCD Jun 11, 2025
67fb1cb
Merge branch 'v3' into feat/command-palette-submenu
HugoRCD Jun 11, 2025
fc6cb32
Merge branch 'v3' into feat/command-palette-submenu
benjamincanac Jun 12, 2025
323bedb
up
benjamincanac Jun 12, 2025
438eb91
up
HugoRCD Jun 12, 2025
fe6c242
up
benjamincanac Jun 13, 2025
a3c9cb3
up
benjamincanac Jun 13, 2025
7d0105c
up
benjamincanac Jun 13, 2025
74bba59
up
benjamincanac Jun 13, 2025
2dc77b0
up
benjamincanac Jun 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<script setup lang="ts">
const toast = useToast()

const groups = [{
id: 'actions',
label: 'Actions',
items: [{
label: 'Create new',
icon: 'i-lucide-plus',
children: [{
label: 'New file',
icon: 'i-lucide-file-plus',
suffix: 'Create a new file in the current directory',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'New file created!' })
},
kbds: ['meta', 'N']
}, {
label: 'New folder',
icon: 'i-lucide-folder-plus',
suffix: 'Create a new folder in the current directory',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'New folder created!' })
},
kbds: ['meta', 'F']
}, {
label: 'New project',
icon: 'i-lucide-folder-git',
suffix: 'Create a new project from a template',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'New project created!' })
},
kbds: ['meta', 'P']
}]
}, {
label: 'Share',
icon: 'i-lucide-share',
children: [{
label: 'Copy link',
icon: 'i-lucide-link',
suffix: 'Copy a link to the current item',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Link copied to clipboard!' })
},
kbds: ['meta', 'L']
}, {
label: 'Share via email',
icon: 'i-lucide-mail',
suffix: 'Share the current item via email',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Share via email dialog opened!' })
}
}, {
label: 'Share on social',
icon: 'i-lucide-share-2',
suffix: 'Share the current item on social media',
children: [{
label: 'Twitter',
icon: 'i-simple-icons-twitter',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Shared on Twitter!' })
}
}, {
label: 'LinkedIn',
icon: 'i-simple-icons-linkedin',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Shared on LinkedIn!' })
}
}, {
label: 'Facebook',
icon: 'i-simple-icons-facebook',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Shared on Facebook!' })
}
}]
}]
}, {
label: 'Settings',
icon: 'i-lucide-settings',
children: [{
label: 'General',
icon: 'i-lucide-sliders',
suffix: 'Configure general settings',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'General settings opened!' })
}
}, {
label: 'Appearance',
icon: 'i-lucide-palette',
suffix: 'Customize the appearance',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Appearance settings opened!' })
}
}, {
label: 'Security',
icon: 'i-lucide-shield',
suffix: 'Manage security settings',
onSelect(e: Event) {
e.preventDefault()
toast.add({ title: 'Security settings opened!' })
}
}]
}]
}]
</script>

<template>
<UCommandPalette :groups="groups" class="flex-1" />
</template>
21 changes: 21 additions & 0 deletions docs/content/3.components/command-palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,27 @@ props:
You can also use the `#item`, `#item-leading`, `#item-label` and `#item-trailing` slots to customize all items.
::

### With submenus

You can create nested menus by using the `children` property on items. When an item has children, it will display a chevron icon and allow navigation into a submenu.

::component-example
---
collapse: true
name: 'command-palette-submenu-example'
class: '!p-0'
props:
autofocus: false
---
::

::note
When navigating into a submenu:
- The search term is reset
- A back button appears in the input
- You can go back to the previous group using the :kbd{value="esc"} key or using the :kbd{value="meta"} + :kbd{value="backspace"} shortcut.
::

## API

### Props
Expand Down
45 changes: 45 additions & 0 deletions playground/app/pages/components/command-palette.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,51 @@ const groups = computed(() => [{
toast.add({ title: 'Label added!' })
},
kbds: ['meta', 'L']
}, {
label: 'More actions',
placeholder: 'Search actions...',
children: [{
label: 'Create new file',
suffix: 'Create a new file in the current directory or workspace.',
icon: 'i-lucide-file-plus',
onSelect(e: Event) {
e.preventDefault()

toast.add({ title: 'New file added!' })
}
}, {
label: 'Create new folder',
suffix: 'Create a new folder in the current directory or workspace.',
icon: 'i-lucide-folder-plus',
onSelect(e: Event) {
e.preventDefault()

toast.add({ title: 'New folder added!' })
}
}, {
label: 'Share',
placeholder: 'Search share options...',
icon: 'i-lucide-share',
children: [{
label: 'Share with everyone',
suffix: 'Share with everyone in the current directory or workspace.',
icon: 'i-lucide-share',
onSelect(e: Event) {
e.preventDefault()

toast.add({ title: 'Shared with everyone!' })
}
}, {
label: 'Share with team',
suffix: 'Share with the team in the current directory or workspace.',
icon: 'i-lucide-users',
onSelect(e: Event) {
e.preventDefault()

toast.add({ title: 'Shared with team!' })
}
}]
}]
}]
}])

Expand Down
Loading