Tutorials
Last updated on:
Dec 13, 2024

How to add real-time search to your Webflow CMS collections

BRIX Templates Logo
Author
BRIX Templates
How to add real-time search to your Webflow CMS collections
Table of contents

Adding real-time search functionality to your Webflow CMS collections can significantly improve user experience by helping visitors quickly find the content they need, without reloading the page. While Webflow doesn't offer built-in real-time search capabilities, we can implement this feature using Finsweet's Attributes scripts.

This solution provides instant search results as users type, filtering your CMS collection items in real-time without requiring page refreshes or complex backend setup.

We'll implement real-time search using two essential Finsweet scripts: the CMS Filter script for search functionality and the CMS Load script for proper pagination integration. This combination ensures smooth operation with Webflow's native features.

Implementation guide for Webflow dynamic search

Step 1: Add the required Finsweet scripts

The foundation of real-time search functionality relies on JavaScript scripts provided by Finsweet. These scripts extend Webflow's native capabilities by adding dynamic filtering and search features. They communicate directly with your CMS collections, enabling instant updates without page refreshes.

<!-- [Attributes by Finsweet] CMS Filter -->
<script async src="https://cdn.jsdelivr.net/npm/@finsweet/attributes-cmsfilter@1/cmsfilter.js"></script>

<!-- [Attributes by Finsweet] CMS Load -->
<script async src="https://cdn.jsdelivr.net/npm/@finsweet/attributes-cmsload@1/cmsload.js"></script>

Where to add these scripts depends on your implementation:

For page-specific implementation:

  1. Open Page Settings
  2. Navigate to Custom Code
  3. Add both scripts in the Head section
Add Finsweet attribute code to add real time search functionality to Webflow CMS

This means you're adding the search functionality to just one specific page. For example, if you have a blog page with a CMS collection that needs search capability, this is the option you'd choose.

For site-wide implementation:

  1. Open Project Settings
  2. Navigate to Custom Code
  3. Add both scripts in the Head section

This means the search functionality will be available across your entire website. Choose this option if you have multiple CMS collections that need search capabilities on different pages or if you plan to add more searchable collections in the future.

Step 2: Configure your CMS collection

Select your Collection List Wrapper and add these three custom attributes:

  1. First attribute:
    • Name: fs-cmsload-element
    • Value: list
    • Purpose: Tells Finsweet which element contains the collection items that need to be loaded dynamically
  2. Second attribute:
    • Name: fs-cmsfilter-element
    • Value: list
    • Purpose: Identifies this element as the container that will be filtered based on search input
  3. Third attribute:
    • Name: fs-cmsload-mode
    • Value: pagination
    • Purpose: Enables proper integration with Webflow's native pagination system
Setup Finsweet attributes to Webflow CMS collection

Step 3: Set up the search form

  1. Add a Form Block element to your page where you want the search bar to appear
  2. Add these custom attributes to the Form Block:
    • Name: fs-cmsfilter-element
    • Value: filters
Setup search bar for Webflow CMS collection

Inside the Form Block, add a Text Input field, and set up the search field and target elements:

First, configure your search input:

  • Add these custom attributes to the Text Input:
    • Name: fs-cmsfilter-field
    • Value: blog-post-title (or whatever identifier you choose)
Configure search functionality on Webflow CMS with Finsweet attributes

Then, mark the elements to be searched:

  1. In your CMS Collection List, select the element you want to search through (like your blog post title)
  2. Open its settings in the right sidebar
  3. Find the Custom Attributes section
  4. Add a new custom attribute:
    • Name: fs-cmsfilter-field
    • Value: blog-post-title (use the same identifier you used in the search input)
Configure search criteria for Finsweet search on Webflow

Note: The values must match exactly between your search input and the CMS element you're searching through. This creates the connection between what users type in the search box and which content gets filtered.

Step 4: Add an empty state message (optional)

When implementing search functionality, it's important to provide feedback when no results match the user's search query. This helps create a better user experience by clearly communicating the search status. Here's how to set it up:

  1. Add a div element inside your Collection List
  2. Style it as needed for your "no results found" message
  3. Add this custom attribute to the div:
    • Name: fs-cmsfilter-element
    • Value: empty
Setup no results found state for Webflow CMS search

This element will automatically show when the search returns no results and hide when results are available.

Testing your Webflow real-time search

Important: The search functionality won't work in the Webflow Designer preview. To test it:

  1. Publish your site to your Webflow staging environment (webflow.io)
  2. Test the search with various queries
  3. Verify that the results update in real-time as you type
  4. Check that the empty state message appears when no results are found
  5. If everything works as expected, publish to your live site

Common issues and solutions

  • If search results aren't updating: Verify that all custom attributes are spelled correctly
  • If you added pagination, and it isn't working: Ensure both Finsweet scripts are properly loaded
  • If the empty state isn't showing: Check that the custom attribute is correctly applied to your empty state element

If you need assistance implementing more advanced search functionality or want to create a custom solution for your specific needs, BRIX Templates' team of experts is available to help. We've developed hundreds of Webflow sites with various complexities and can help you achieve the exact functionality you're looking for.

Whether you need help with this specific implementation or are looking to develop a completely new site with advanced features, don't hesitate to reach out to our team for professional assistance.

BRIX Templates Logo
About BRIX Templates

At BRIX Templates we craft beautiful, modern and easy to use Webflow templates & UI Kits.

Explore our Webflow templates
Join the conversation
Join our monthly Webflow email newsletter!

Receive one monthly email newsletter with the best articles, resources, tutorials, and free cloneables from BRIX Templates!

Webflow Newsletter
Thanks for joining our Webflow email newsletter
Oops! Something went wrong while submitting the form.
BRIX Templates - Email Newsletter with Webflow ResourcesBRIX Templates - Email NewsletterBRIX Templates - Webflow Email Newsletter
How to pre-fill Webflow forms with URL parameters

How to pre-fill Webflow forms with URL parameters

Step-by-step guide to implementing URL parameter form pre-filling in Webflow using our ready-to-use script. No coding required.

Dec 17, 2024
How to add custom security headers to your Webflow site

How to add custom security headers to your Webflow site

Learn how to strengthen your Webflow site's security by adding custom headers. A complete guide covering implementation through Cloudflare.

Dec 17, 2024
How to add a real-time load more button to your Webflow CMS collection

How to add a real-time load more button to your Webflow CMS collection

Step-by-step tutorial showing how to implement a dynamic load more button for your Webflow CMS collections.

Dec 13, 2024