Enhance users’ experiences with using filters by adding visual indicators such as a color palette or images.
Visual facets let you enrich your filtering UI with visual indications such as category images, colors, or logos.
With visual facets, you can create better-looking layouts and search experiences.
Visual facets are typically more engaging than plain text facets, thus increasing user engagement and encouraging discovery.
var response = await client.SetSettingsAsync( "ALGOLIA_INDEX_NAME", new IndexSettings { AttributesForFaceting = new List { "color", "availableIn" }, });
In the refinementList widget of your InstantSearch implementation,
split your facet values on || to display the visual and attribute values.
You can implement visual facets by adding a mapping directly in your frontend app. This solution requires that you use a consistent naming scheme for your images and facet names.First, create your mapping functions.The following function takes the facet label of an image and returns the image with the .jpeg file extension tacked on. This is a rudimentary implementation: it requires your facets to use consistent image names.
The following function takes a color facet and returns either the color or “transparent” if nothing was passed. Again, this is a rudimentary implementation: it doesn’t return the hexadecimal color code but instead requires your facets to use valid CSS color keywords.
JavaScript
Report incorrect code
Copy
const getHexCodeFromColor = color => color ? color : 'transparent';
In your refinementList widget, use your mapping functions to transform each facet.