title: Halo 搜索
description: 一款未来感十足的搜索输入组件，拥有多重发光环与细腻的动态光晕，为界面带来炫彩、沉浸式体验。
---

```vue
<template>
  <div class="w-full flex flex-col items-center justify-center h-96 relative z-0">
    <HaloSearch />

    <span class="mt-24 text-muted-foreground font-light">
      Try hovering over component and typing in it.
    </span>
  </div>
</template>

```

## API

| 属性名  | 类型     | 默认值 | 描述                    |
| ------- | -------- | ------ | ----------------------- |
| `class` | `string` | `""`   | 根容器的附加 CSS 类名。 |

## 安装

除 Vue 3 和你的图标系统（用于搜索图标）外，无需额外依赖。

## CLI 安装

```vue
<InstallationCli component-id="halo-search" />
```

## 手动安装

复制并粘贴以下代码

```vue
<template>
  <div
    id="halo-search"
    :class="props.class"
  >
    <div class="aurora-glow"></div>
    <div class="outer-ring"></div>
    <div class="outer-ring"></div>
    <div class="outer-ring"></div>

    <div class="inner-glow"></div>

    <div class="main-border"></div>

    <div id="search-wrapper">
      <input
        placeholder="Search..."
        type="text"
        name="text"
        class="search-field"
      />
      <div id="text-mask"></div>
      <div class="search-btn-border"></div>
      <span
        :class="[
          'absolute top-2 right-2 flex items-center justify-center z-[2] max-h-10 max-w-10 size-full isolate overflow-hidden rounded-lg border border-transparent border-solid',
        ]"
        style="background: linear-gradient(180deg, #161329, black, #1d1b4b)"
      >
        <Icon
          name="lucide:search"
          size="24"
        />
      </span>
    </div>
  </div>
</template>

<script lang="ts" setup>
import type { HTMLAttributes } from "vue";

interface Props {
  class?: HTMLAttributes["class"];
}

const props = defineProps<Props>();
</script>

<style scoped>
#halo-search {
  display: flex;
  align-items: center;
  justify-content: center;
}

#search-wrapper {
  position: relative;
}

.grid {
  height: 800px;
  width: 800px;
  background-image:
    linear-gradient(to right, #0f0f10 1px, transparent 1px),
    linear-gradient(to bottom, #0f0f10 1px, transparent 1px);
  background-size: 1rem 1rem;
  background-position: center center;
  position: absolute;
  z-index: -1;
  filter: blur(1px);
}

.search-field {
  background-color: #010201;
  border: none;
  width: 301px;
  height: 56px;
  border-radius: 10px;
  color: white;
  padding-right: 60px;
  padding-left: 16px;
  font-size: 18px;
}

.search-field::placeholder {
  color: #c0b9c0;
}

.search-field:focus {
  outline: none;
}

.inner-glow,
.main-border,
.outer-ring,
.aurora-glow {
  max-height: 70px;
  max-width: 314px;
  height: 100%;
  width: 100%;
  position: absolute;
  overflow: hidden;
  z-index: -1;
  border-radius: 12px;
  filter: blur(3px);
}

.inner-glow {
  max-height: 63px;
  max-width: 307px;
  border-radius: 10px;
  filter: blur(2px);
}

.inner-glow::before {
  content: "";
  z-index: -2;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(83deg);
  position: absolute;
  width: 600px;
  height: 600px;
  background-repeat: no-repeat;
  background-position: 0 0;
  filter: brightness(1.4);
  background-image: conic-gradient(
    rgba(0, 0, 0, 0) 0%,
    #a099d8,
    rgba(0, 0, 0, 0) 8%,
    rgba(0, 0, 0, 0) 50%,
    #dfa2da,
    rgba(0, 0, 0, 0) 58%
  );
  transition: all 2s;
}

.main-border {
  max-height: 59px;
  max-width: 303px;
  border-radius: 11px;
  filter: blur(0.5px);
}

.main-border::before {
  content: "";
  z-index: -2;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(70deg);
  position: absolute;
  width: 600px;
  height: 600px;
  filter: brightness(1.3);
  background-repeat: no-repeat;
  background-position: 0 0;
  background-image: conic-gradient(
    #1c191c,
    #402fb5 5%,
    #1c191c 14%,
    #1c191c 50%,
    #cf30aa 60%,
    #1c191c 64%
  );
  transition: all 2s;
}

.outer-ring {
  max-height: 65px;
  max-width: 312px;
}

.outer-ring::before {
  content: "";
  z-index: -2;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(82deg);
  position: absolute;
  width: 600px;
  height: 600px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-image: conic-gradient(
    rgba(0, 0, 0, 0),
    #18116a,
    rgba(0, 0, 0, 0) 10%,
    rgba(0, 0, 0, 0) 50%,
    #6e1b60,
    rgba(0, 0, 0, 0) 60%
  );
  transition: all 2s;
}

.aurora-glow {
  overflow: hidden;
  filter: blur(30px);
  opacity: 0.4;
  max-height: 130px;
  max-width: 354px;
}

.aurora-glow:before {
  content: "";
  z-index: -2;
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(60deg);
  position: absolute;
  width: 999px;
  height: 999px;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-image: conic-gradient(#000, #402fb5 5%, #000 38%, #000 50%, #cf30aa 60%, #000 87%);
  transition: all 2s;
}

/* ===========================================
   INPUT OVERLAY & ACCENT EFFECTS
   =========================================== */

#text-mask {
  pointer-events: none;
  width: 100px;
  height: 20px;
  position: absolute;
  background: linear-gradient(90deg, transparent, black);
  top: 18px;
  left: 32px;
}

#accent-blur {
  pointer-events: none;
  width: 30px;
  height: 20px;
  position: absolute;
  background: #cf30aa;
  top: 10px;
  left: 5px;
  filter: blur(20px);
  opacity: 0.8;
  transition: all 2s;
}

.search-btn-border {
  height: 42px;
  width: 42px;
  position: absolute;
  overflow: hidden;
  top: 7px;
  right: 7px;
  border-radius: 12px;
}

.search-btn-border::before {
  content: "";
  text-align: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  position: absolute;
  width: 600px;
  height: 600px;
  background-repeat: no-repeat;
  background-position: 0 0;
  filter: brightness(1.35);
  background-image: conic-gradient(
    rgba(0, 0, 0, 0),
    #3d3a4f,
    rgba(0, 0, 0, 0) 50%,
    rgba(0, 0, 0, 0) 50%,
    #3d3a4f,
    rgba(0, 0, 0, 0) 100%
  );
  animation: rotate 4s linear infinite;
}

#halo-search:hover > .outer-ring::before {
  transform: translate(-50%, -50%) rotate(-98deg);
}

#halo-search:hover > .aurora-glow::before {
  transform: translate(-50%, -50%) rotate(-120deg);
}

#halo-search:hover > .inner-glow::before {
  transform: translate(-50%, -50%) rotate(-97deg);
}

#halo-search:hover > .main-border::before {
  transform: translate(-50%, -50%) rotate(-110deg);
}

#search-wrapper:hover > #accent-blur {
  opacity: 0;
}

#halo-search:focus-within > .outer-ring::before {
  transform: translate(-50%, -50%) rotate(442deg);
  transition: all 4s;
}

#halo-search:focus-within > .aurora-glow::before {
  transform: translate(-50%, -50%) rotate(420deg);
  transition: all 4s;
}

#halo-search:focus-within > .inner-glow::before {
  transform: translate(-50%, -50%) rotate(443deg);
  transition: all 4s;
}

#halo-search:focus-within > .main-border::before {
  transform: translate(-50%, -50%) rotate(430deg);
  transition: all 4s;
}

#search-wrapper:focus-within > #text-mask {
  display: none;
}

@keyframes rotate {
  100% {
    transform: translate(-50%, -50%) rotate(450deg);
  }
}

@keyframes leftright {
  0% {
    transform: translate(0px, 0px);
    opacity: 1;
  }
  49% {
    transform: translate(250px, 0px);
    opacity: 0;
  }
  80% {
    transform: translate(-40px, 0px);
    opacity: 0;
  }
  100% {
    transform: translate(0px, 0px);
    opacity: 1;
  }
}
</style>

```

## 特色功能

- **发光环**：多层锥形渐变环，带有流畅的旋转动画。
- **极光光晕**：大面积模糊渐变背景，营造环境光晕效果。
- **内外光效**：细腻模糊覆盖层，增强深度与聚焦感。
- **动画搜索按钮**：渐变圆环和无限旋转的搜索图标高光。
- **响应式输入框**：干净、暗色主题的搜索输入，支持自定义占位符样式。
- **交互状态**：悬停和聚焦时，环形旋转与光晕强度动态反馈。
- **作用域样式**：封装 CSS，保证样式隔离和平滑过渡。

## 使用场景

- 可作为仪表盘、音乐/视频应用、创意作品集等的炫酷搜索栏。
- 集成到落地页，为用户留下带动画的深刻第一印象。
- 结合深色或弱光主题界面，放大光环特效的视觉冲击。
- 在 CSS 中自定义光晕色彩与动画时长，适配品牌色或节日氛围。
- 可扩展支持键盘导航、搜索自动补全，提升可访问性。

## 致谢

- 设计灵感源自未来主义 UI 概念和现代网页/应用中流行的环境光效。
- 灵感部分来自 UiVerse Search input challenge。