Speed up widget development with Sitefinity MCP server. Learn more...

Filter widgets

When building pages in the Sitefinity WYSIWYG editor, you can control which widgets appear in the widget toolbox by using widget registry filters. Filters are client-side functions that run every time the toolbox is rendered in edit mode.

How widget filtering works

  • Filters are attached to your WidgetRegistry via its optional filters property.
  • Each filter is evaluated in the browser when the editor renders the toolbox.
  • The filter returns whether a widget should be shown.

Keep the default filters when customizing the registry

The SDK’s defaultWidgetRegistry includes built-in filters. If you create a custom registry, it’s recommended to merge:

  1. The default widgets with your custom widgets
  2. The default filters with your custom filters

Example:

Create a custom widget filter

Implement the filter function

Create a client-side TypeScript module (for example components/custom-filters/my-custom-filtering.ts) and add the use client directive at the top so it runs on the client.

The filter function should accept:

  • widgetMetadata – the widget’s metadata
  • args – context about the toolbox rendering

It should return a Promise<boolean>:

  • true → show the widget
  • false → hide the widget

Example:

Register the filter in the widget registry

Import your filter into your app’s registry file (commonly src/app/widget-registry.ts) and add it to the filters array.

Example:

Notes and best practices

  • Filters are executed for each widget when the toolbox is drawn, so keep them fast.
  • Always start filter modules with use client, because the widget toolbox runs in the browser.
  • Prefer additive filtering (hide only what you must), and keep the default filters unless you have a specific reason to replace them.
NEW TO SITEFINITY?

Want to learn more?

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?