cmdk-svelte
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

⌘K for Svelte

This is an implementation of Paco's cmdk for Svelte.

It is not complete, it is not perfect, but it's functional.

Install

npm install cmdk-svelte

Use

<script>
	import { Command } from 'cmdk-svelte';

	let open = false;
	let value = '';
</script>

<svelte:window
	on:keydown={(e) => {
		if (e.metaKey && e.key == 'k') {
			open = !open;
		}
		if (e.key == 'Escape') {
			open = false;
		}
	}}
	on:pointerdown={() => (open = false)}
/>

<Command.Dialog {open}>
	<Command.Overlay />
	<Command.Content>
		<Command.Input bind:value />
		<Command.List>
			<Command.Empty>No results found.</Command.Empty>
			<Command.Group heading="Projects">
				<Command.Item onSelect={()=>{}}>Search Projects...</Command.Item>
				<Command.Item>...</Command.Item>
			</Command.Group>
		</Command.List>
	</Command.Content>
</Command.Dialog>

Readme

Keywords

none

Package Sidebar

Install

npm i cmdk-svelte

Weekly Downloads

2

Version

0.0.1

License

none

Unpacked Size

25.5 kB

Total Files

24

Last publish

Collaborators

  • spioune