ChatShimmer

GitLab
Exiba um efeito de animação shimmer no texto.

Uso

O componente ChatShimmer renderiza um elemento com um gradiente shimmer animado sobre o texto, comumente usado para indicar estados de streaming ou carregamento em interfaces de chat.

Este componente é usado automaticamente pelos componentes ChatTool e ChatReasoning durante o streaming.

Texto

Use a prop text para definir o texto do shimmer.

Thinking...
<template>
  <NChatShimmer text="Thinking..." />
</template>

Duração

Use a prop duration para controlar a velocidade da animação em segundos.

Thinking...
<template>
  <NChatShimmer text="Thinking..." :duration="4" />
</template>

Espalhamento

Use a prop spread para controlar a largura do destaque do shimmer. O spread real é calculado como text.length * spread em pixels.

Thinking...
<template>
  <NChatShimmer text="Thinking..." :spread="5" />
</template>

Exemplos

Confira a página de visão geral do Chat para instruções de instalação, configuração do servidor e exemplos de uso.

API

Props

Prop Default Type
as'span'any

The element or component this component should render as.

textstring

The text to display with the shimmer effect.

duration2 number

The duration of the shimmer animation in seconds.

spread2 number

The spread multiplier for the shimmer highlight. The actual spread is computed as text.length * spread in pixels.

ui {}

Tema

app.config.ts
export default defineAppConfig({
  ui: {
    chatShimmer: {
      base: 'text-transparent bg-clip-text bg-no-repeat bg-size-[calc(200%+var(--spread)*2+2px)_100%,auto] bg-[image:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--ui-text-highlighted),#0000_calc(50%+var(--spread))),linear-gradient(var(--ui-text-muted),var(--ui-text-muted))] animate-[shimmer_var(--duration)_linear_infinite] rtl:animate-[shimmer-rtl_var(--duration)_linear_infinite] will-change-[background-position]'
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nitro/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        chatShimmer: {
          base: 'text-transparent bg-clip-text bg-no-repeat bg-size-[calc(200%+var(--spread)*2+2px)_100%,auto] bg-[image:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--ui-text-highlighted),#0000_calc(50%+var(--spread))),linear-gradient(var(--ui-text-muted),var(--ui-text-muted))] animate-[shimmer_var(--duration)_linear_infinite] rtl:animate-[shimmer-rtl_var(--duration)_linear_infinite] will-change-[background-position]'
        }
      }
    })
  ]
})

Changelog

No recent changes