Mordoc

Search

Style the search bar in the header and the full-screen search modal it opens.

2 MIN READ

Search is one feature split across two files, because it's two different pieces of UI: the bar sitting in the header, and the full-screen modal it opens.

Text
┌───────────────────┐        ┌─────────────────────────────┐
│ 🔍 Search..   ⌘K │  --->  │ 🔍 [type to search...]  ✕  │
└───────────────────┘        ├─────────────────────────────┤
     Search Bar              │  Result title               │
                             │  matching excerpt…          │
                             │  Result title               │
                             │  matching excerpt…          │
                             └─────────────────────────────┘
                                     Search Modal
Text
config/styles/search-bar.css
TokenWhat it controls
--search-bar-widthWidth of the bar on desktop. Narrower by default at the 768px breakpoint than at 1024px and up.
--search-bar-heightHeight of the bar.
--search-bar-radiusCorner radius of the bar.
--search-bar-paddingHorizontal padding inside the bar.
--search-bar-gapGap between the icon, placeholder text, and keyboard shortcut hint.
--search-bar-font-sizeFont size of the placeholder text.
--search-bar-icon-sizeSize of the search icon.
--search-bar-bgBar background.
--search-bar-bg-hoverBar background on hover.
--search-bar-borderBar border color.
--search-bar-border-hoverBar border color on hover. Defaults to a translucent tint of --accent.
--search-bar-fgIcon and placeholder text color.
--search-bar-kbd-heightHeight of the ⌘K-style keyboard shortcut chip.
--search-bar-kbd-paddingHorizontal padding of the shortcut chip.
--search-bar-kbd-font-sizeFont size of the shortcut chip.
--search-bar-kbd-radiusCorner radius of the shortcut chip.
--search-bar-kbd-bgBackground of the shortcut chip.

Search Modal

Text
config/styles/search-modal.css
TokenWhat it controls
--modal-max-widthMaximum width of the modal panel.
--modal-overlay-bgBackdrop behind the modal.
--modal-bgModal panel background. Defaults to --color-bg.
--modal-borderModal panel border. Defaults to --color-border.
--modal-shadowDrop shadow under the modal panel.
--modal-radiusCorner radius of the modal panel.
--modal-input-sizeFont size of the search input.
--modal-result-radiusCorner radius of each result row.
--modal-result-hoverBackground of a result row on hover. Defaults to --color-bg-hover.
--modal-result-selectedBackground of the keyboard-selected result row.
--modal-kbd-radiusCorner radius of the small inline chips used for the Esc hint and matched keywords.

Example search-bar.css

A config/styles/search-bar.css that sets every token on this page, for both light and dark mode:

Css
:root {
  --search-bar-width: 256px;
  --search-bar-height: 36px;
  --search-bar-radius: 999px;
  --search-bar-padding: 12px;
  --search-bar-gap: 8px;
  --search-bar-font-size: 14px;
  --search-bar-icon-size: 16px;
  --search-bar-bg: rgba(245, 245, 245, 0.5);
  --search-bar-bg-hover: #f5f5f5;
  --search-bar-border: #e5e5e5;
  --search-bar-border-hover: color-mix(in oklch, #0d9488 30%, transparent);
  --search-bar-fg: #666666;
  --search-bar-kbd-height: 20px;
  --search-bar-kbd-padding: 6px;
  --search-bar-kbd-font-size: 10px;
  --search-bar-kbd-radius: 4px;
  --search-bar-kbd-bg: #ffffff;
}

.dark {
  --search-bar-bg: rgba(36, 36, 36, 0.5);
  --search-bar-bg-hover: #242424;
  --search-bar-border: #2e2e2e;
  --search-bar-fg: #9e9e9e;
  --search-bar-kbd-bg: #1a1a1a;
}

Example search-modal.css

A config/styles/search-modal.css that sets every token on this page, for both light and dark mode:

Css
:root {
  --modal-max-width: 640px;
  --modal-overlay-bg: rgba(0, 0, 0, 0.45);
  --modal-bg: #ffffff;
  --modal-border: #e5e5e5;
  --modal-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  --modal-radius: 16px;
  --modal-input-size: 16px;
  --modal-result-radius: 8px;
  --modal-result-hover: #f3f4f6;
  --modal-result-selected: #f0fdfa;
  --modal-kbd-radius: 4px;
}

.dark {
  --modal-overlay-bg: rgba(0, 0, 0, 0.65);
  --modal-bg: #161616;
  --modal-border: #2e2e2e;
  --modal-result-hover: #242424;
  --modal-result-selected: #0f2e2b;
}

Next step

© 2026 MordocPowered by Mordoc