Skip to main content
Signature

Import

To ensure optimal bundle sizes, see Optimize build size.
Vue

See this widget in action

Preview this widget and its behavior.

About this widget

The ais-snippet widget displays attributes in a shorter form (a snippet). Snippeted attributes are also highlighted. It uses Algolia’s snippeting feature in combination with the ais-hits or ais-infinite-hits widgets. To determine which attributes should be snippeted, set them from the Algolia dashboard, the CLI, or with the API (using the attributesToSnippet parameter):
Vue
With attributesToSnippet, you can also set the snippet’s size to a specific number of words (it defaults to 10). For example, :attributesToSnippet="['description:5'].

Examples

Basic usage

Vue

Access a nested property

Given this record:
JSON
You can access the snippeted version by specifying the path separating levels with dots:
Vue

Props

string
required
The attribute of the record to snippet. For deeply nested objects, specify a dot-separated value like actor.bio.
Vue
object
required
The original hit object provided to the function. For this to work, the provided object must have a _snippetResult[attribute].value property.
Vue
string
default:"mark"
The name of the HTML element to wrap the highlighted parts of the string.
Vue
object
default:"{}"
The CSS classes you can override:
  • ais-Snippet. The root element of the widget.
Vue

HTML output

HTML
Last modified on July 22, 2026