• Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language Svelte
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dead simple command palette for svelte

Svelte Command Palette

Increase your productivity exponentially. 🚀🚀

Get started with command-palette with 2.1Kb Minified and ~700B Gzipped + Minified

Demo

svelte-command-palette

Features

  • Fuzzy search powered by fuse.js
  • Run actions conditionally
  • Super simple API, just define your actions and it just works!
  • Advanced conditional actions - decide whether to run your action based on the current state of your command palette
  • Access to paletteStore , update your update palette store from anywhere to make updates to your command-palette.
  • Keyboard shortcuts - define keyboard shortcuts for your actions!

and more

Installation

Install svelte-command-palette with npm

  npm install svelte-command-palette

Usage/Examples

<script>
    import CommandPalette, { defineActions, createStoreMethods } from 'svelte-command-palette'

    // define actions using the defineActions API

    const paletteMethods = createStoreMethods();

    const actions = defineActions([
        {
            title: "Open Svelte Command Palette on github",
            subTitle: "This opens github in a new tab!",
            onRun: ({ action, storeProps, storeMethods }) => {
                window.open("https://github.com/rohitpotato/svelte-command-palette")
            },
            shortcut: "Space k"
        }
    ])
</script>

// render your command palette at the root of your application, say _layout.svelte

<button on:click={() => paletteMethods.openPalette()}>Open Command Palette</button>

<CommandPalette commands={actions}>

API

Component Styling API

The <CommandPalette /> component accepts the following optional properties for styling:

Property Type Default Description
unstyled boolean false When true, the default styles are not applied to the modal elements.
placeholder string "Search for actions" Placeholder for the command palette input
overlayClass string | null null Class name for the palette overlay.
paletteWrapperInnerClass string | null null Class name for the cmd palette wrapper element.
inputClass string | null null Class name for the cmd palette input.
resultsContainerClass string | null null Class name for the results container.
resultContainerClass string | null null Class name for the result item container.
optionSelectedClass string | null null Class name for the currently selected result item.
titleClass string | null null Class name for the result title.
subtitleClass string | null null Class name for the result subtitle.
descriptionClass string | null null Class name for the result description.
keyboardButtonClass string | null null Class name for the keyboard shortcuts.
overlayStyle Record<string, string | number> {} Style properties of the overlay.
paletteWrapperInnerStyle Record<string, string | number> {} Style properties of the command palette wrapper element.
inputStyle Record<string, string | number> {} Style properties of cmd palette input.
resultsContainerStyle Record<string, string | number> {} Style properties of results container.
resultContainerStyle Record<string, string | number> {} Style properties result item container.
titleStyle Record<string, string | number> {} Style properties for result item title.
subtitleStyle Record<string, string | number> {} Style properties for result item subtitle.
descriptionStyle Record<string, string | number> {} Style properties for result item description.
optionSelectedStyle Record<string, string | number> {} Style properties selected result item.
keyboardButtonStyle Record<string, string | number> {} Style properties for the keyboard shortcut.

Action API

	actionId?: ActionId;
	canActionRun?: (args: onRunParams) => boolean;
	title: string;
	description?: string;
	subTitle?: string;
	onRun?: (args: onRunParams) => void;
	keywords?: Array<string>;
	shortcut?: string;

Store Methods

Get palette methods from createStoreMethods.

import { createStoreMethods } from 'svelte-command-palette`

const methods = createStoreMethods();

method.openPalette();

API

    togglePalette: () => void;
    getAllCalledActions: () => ActionId[];
    storeCalledAction: (id: ActionId) => void;
    revertLastAction: (id: ActionId) => void;
    resetActionLog: () => void;
    openPalette: () => void;
    closePalette: () => void;
    resetPaletteStore: () => void;

More Repositories

1

svelte-switcher

An accessible, fully customisable, mobile friendly toggle component for svelte-apps.
HTML
26
star
2

spotify-unbiased-shuffle

A tool for unbiased shuffling for Spotify playlists, combine multiple playlists and shuffle them all
JavaScript
26
star
3

react-native-chat-app

A react native chat application built using firebase and react-native-gifted-chat.
JavaScript
17
star
4

node-socket-chatApp

JavaScript
12
star
5

implement-react-hooks

A simplified implementation of two of the most important react hooks - useState and useEffect. Original link for the article: https://medium.com/swlh/learn-by-implementing-reacts-usestate-and-useeffect-a-simplified-overview-ea8126705a88
JavaScript
11
star
6

laravel_youtube-vimeo-clone

This is a youtube/vimeo clone made using laravel and vueJs 2.0. Uses FFMpeg laravel package for video encoding and uploading to Amazon s3. FFMPeg Laravel Uses the disqus engine for commenting. Features involve: Search using Algolia, Notifications for Users, Video up/down voting, Multiple Channel Support. (Currently not available), Trending Videos using Redis and much more...
PHP
8
star
7

easy-search

Get specific results from Google by limiting sites, files, dates and more.
JavaScript
5
star
8

webpack-react-boilerplate

A react app boilerplate using Webpack 5.
JavaScript
2
star
9

node-siteMonitor

An uptime monitor for http/https websites over the internet.
JavaScript
2
star
10

MERN-BLOG

A simple blogging application built it's api built with Node.js and front-end with React JS. Also uses mongodb as a database.
PHP
1
star
11

react-githubfinder

JavaScript
1
star
12

vanilla-js-projects

HTML
1
star
13

node-socialNetwork

Small scale social network with google OAuth passport authentication.
HTML
1
star
14

laravel-distract

Pulls popular topics from your favorite websites on a single page application without the hassle of browsing elsewhere!
PHP
1
star
15

laravelforumv2

An updated version of the previous repository with features like Notifications, Mentioning Msers, Subscribing to threads, Upvoting replies, Spam protection, and Redis for displaying trending threads!
JavaScript
1
star
16

laravel-urlshort-vueclient

JavaScript
1
star
17

vanillajs-miniprojects

Few mini projects i have built to practice my vanilla js skills.
JavaScript
1
star
18

laravel-urlshort-api

PHP
1
star
19

node-fifaNotifier

JavaScript
1
star
20

node-terminalMusic

JavaScript
1
star
21

spotify-redone-react

Yet another Spotify Client but this time built with react-query, zustand and tailwind css :)
JavaScript
1
star
22

instascraper_py

Instagram image and caption scraper using Python
Python
1
star
23

my-website

My website built with NextJS and data managed by cloudflare KV.
TypeScript
1
star
24

react-horizontal-scroller

A horizontal scroll utility for react applications.
TypeScript
1
star
25

portfolio-cloudflare-worker

A cloudflare worker with KV to manage portfolio site config
TypeScript
1
star