Command palette.
https://luna.liriliri.io/?path=/story/command-palette
Add the following script and style to your page.
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/luna-command-palette/luna-command-palette.css" />
<script src="//cdn.jsdelivr.net/npm/luna-command-palette/luna-command-palette.js"></script>
You can also get it on npm.
npm install luna-command-palette --save
import 'luna-command-palette/luna-command-palette.css'
import LunaCommandPalette from 'luna-command-palette'
const container = document.getElementById('container')
const commandPalette = new LunaCommandPalette(container, {
placeholder: 'Type a command',
shortcut: 'Ctrl+P',
commands: [
{
title: 'Reload Page',
shortcut: 'Ctrl+R',
handler(e) {
if (e && e.preventDefault) {
e.preventDefault()
}
location.reload()
}
}
]
})
commandPalette.show()
- commands(ICommand[]): Commands to show.
- placeholder(string): Search input placeholder.
- shortcut(string): Keyboard shortcut for opening the command palette.
Hide command palette.
Show command palette.
- title(string): Command title.