Skip to content

Styling

Components use Shadow DOM with ::part() selectors and BEM class names for styling flexibility.

Quick Start

Import the optional stylesheet for reasonable defaults:

js
import 'keybinds/styles/palette.css'

Custom Styles with ::part()

Target shadow DOM elements using CSS ::part():

css
command-palette::part(dialog) {
  background: #fff;
  border-radius: 12px;
}

command-palette::part(input) {
  font-size: 18px;
}

command-palette::part(item-active) {
  background: #0066cc;
  color: white;
}

Command Palette Parts

PartDescription
paletteRoot container
backdropOverlay behind dialog
dialogMain dialog box
inputSearch input field
listResults list (<ul>)
itemIndividual result (<li>)
item-activeCurrently selected item
item-disabledInactive command (failing when)
item-labelCommand label text
item-categoryCategory badge
item-keyKeyboard shortcut (<kbd>)
empty"No results" message

Cheatsheet Parts

PartDescription
cheatsheetRoot container
backdropOverlay behind dialog
dialogMain dialog box
groupCategory group container
group-titleCategory heading
listCommands list (<ul>)
itemIndividual command (<li>)
item-disabledInactive command
item-labelCommand label text
item-keysContainer for key badges
item-keyIndividual key (<kbd>)

Settings Parts

PartDescription
settingsRoot container
backdropOverlay behind dialog
dialogMain dialog box
headerHeader container
titleTitle text
reset-allReset All button
groupCategory group container
group-titleCategory heading
listCommands list (<ul>)
itemIndividual command (<li>)
item-labelCommand label text
item-bindingsContainer for all bindings
item-resetPer-command reset button
bindingIndividual binding span
binding-recordingBinding in recording state
binding-keysKey display container
binding-keyIndividual key (<kbd>)
binding-removeRemove (×) button
item-addAdd binding container
add-keyAdd Key button
add-mouseAdd Mouse button
recording-overlayRecording prompt text
conflictConflict warning message
conflict-acceptReplace button
conflict-cancelCancel button

Context Menu Parts

PartDescription
context-menuRoot container
backdropOverlay behind menu (covers viewport)
listMenu list (<ul>)
itemIndividual menu item (<li>)
item-activeCurrently highlighted item
item-disabledInactive command (failing when)
separatorCategory separator between groups
item-labelCommand label text
item-keysContainer for shortcut keys
item-keyIndividual key (<kbd>)

BEM Classes

Inside shadow DOM, elements have BEM class names matching their parts:

.palette
.palette__backdrop
.palette__dialog
.palette__input
.palette__list
.palette__item
.palette__item--active
.palette__item--disabled
...

These are useful if you're styling via JavaScript or inspecting elements.

Example: Light Theme

css
command-palette::part(backdrop) {
  background: rgba(0, 0, 0, 0.3);
}

command-palette::part(dialog) {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

command-palette::part(input) {
  color: #333;
  border-bottom: 1px solid #e0e0e0;
}

command-palette::part(item) {
  color: #333;
}

command-palette::part(item-active) {
  background: #f0f0f0;
}

command-palette::part(item-key) {
  background: #f5f5f5;
  border-color: #ddd;
  color: #666;
}

Example: Glassmorphic

css
command-palette::part(dialog) {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

Positioning

Override default positioning:

css
/* Center vertically */
command-palette::part(dialog) {
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Bottom sheet on mobile */
@media (max-width: 600px) {
  command-palette::part(dialog) {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: none;
    border-radius: 12px 12px 0 0;
  }
}