Pens

Sticky Blur App Bar with Global Search

UI Component bởi acmatvjrus
Mở Studio
<div class="appbar-wrapper">
  <header class="app-bar">
    <div class="appbar-left">
      <div class="workspace-pill">
        <div class="ws-avatar">N</div>
        <span class="ws-name">Novagon Workspace</span>
        <span class="ws-chevron">▾</span>
      </div>
    </div>
    
    <div class="global-search-bar">
      <svg class="search-icon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
        <circle cx="11" cy="11" r="8"></circle>
        <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
      </svg>
      <input type="text" placeholder="Tìm tác vụ, tài liệu hoặc thành viên...">
      <kbd class="kbd-hint">⌘K</kbd>
    </div>
    
    <div class="appbar-right">
      <button class="icon-action-btn" title="Thông báo">
        <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2">
          <path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path>
          <path d="M13.73 21a2 2 0 0 1-3.46 0"></path>
        </svg>
        <span class="notify-dot"></span>
      </button>
      <button class="icon-action-btn" title="Trợ giúp">
        <svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2">
          <circle cx="12" cy="12" r="10"></circle>
          <path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"></path>
          <line x1="12" y1="17" x2="12.01" y2="17"></line>
        </svg>
      </button>
      <div class="user-profile">
        <img src="https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=100&auto=format&fit=crop&q=80" alt="Avatar" class="profile-img">
      </div>
    </div>
  </header>
</div>
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
}
.app-bar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.appbar-left {
  display: flex;
  align-items: center;
}
.workspace-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.workspace-pill:hover { background: #f1f5f9; }
.ws-avatar {
  width: 22px;
  height: 22px;
  background: #10a37a;
  color: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.ws-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
}
.ws-chevron { color: #94a3b8; font-size: 0.8rem; }
.global-search-bar {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 12px;
  color: #94a3b8;
}
.global-search-bar input {
  width: 100%;
  padding: 8px 60px 8px 36px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #0f172a;
  outline: none;
  transition: all 0.2s;
}
.global-search-bar input:focus {
  background: #fff;
  border-color: #10a37a;
  box-shadow: 0 0 0 3px rgba(16, 163, 122, 0.15);
}
.kbd-hint {
  position: absolute;
  right: 10px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
}
.appbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.icon-action-btn {
  background: none;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
}
.icon-action-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.notify-dot {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 7px;
  height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
}
.user-profile {
  margin-left: 6px;
  cursor: pointer;
}
.profile-img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #10a37a;
}
@media (max-width: 768px) {
  .global-search-bar { display: none; }
}
// Global Keyboard Shortcut (CMD+K / CTRL+K)
window.addEventListener("keydown", (e) => {
  if ((e.metaKey || e.ctrlKey) && e.key === "k") {
    e.preventDefault();
    document.querySelector(".global-search-bar input")?.focus();
  }
});
Đã sao chép vào bộ nhớ tạm!