Custom visuals and reusable components in Evidence

Custom visuals and reusable components in Evidence

Build custom visuals with HTML, connect them to your reports, and reuse them across your Evidence project.

The ability to vibe code custom visuals, apps, and interfaces has become an essential requirement of BI deployments over the last six months.

BI vendors have rushed to bolt these experiences onto their existing platforms. Typically they take one of two approaches: hobble the capabilities of LLMs by restricting them to a custom visualization language, or offer a separate “generative apps” experience that’s disjointed from the rest of the platform.

Evidence’s roots are very different from conventional BI tools. As a result, we’ve offered rich custom component functionality and have been refining it for several years. We’ve learned a few things about what to look for in a custom component system.

There are three key properties you should look for: the flexibility to build anything, the ability to use it anywhere in the native platform, and the ability to abstract what you’ve built into reusable components.

Let’s get into how we achieve these goals in Evidence.

Build anything

Our approach is built around a single (humbly named) component, {% html %}.

Despite its name, the HTML component runs HTML, sandboxed JavaScript, and CSS. Anything you can (safely) run in the browser can run in there.

You can vibe code a custom Gantt chart with overlay details like this. Or a metrics tree. Or any number of specialized visualizations that wouldn’t make sense to include in a standard charting library.

A lot of vendors take a wrong turn here. Instead of offering the full web platform, they offer a narrow charting DSL like Vega-Lite or (woof) bare svg. Coding agents can one shot any front end code you need.

Use it anywhere

There is no separate “generative apps” flow in Evidence. You can invoke the HTML component on any page and use it to vibe code whatever custom visualization or UI you need in that location.

You can use it to create full-page applications, but for the most part teams use it to inline custom visuals alongside native Evidence components.

In addition to HTML, JavaScript, and CSS, the component comes with the Evidence SDK, which your agent can use to interact with the rest of your Evidence project.

HTML components can act as filters for native Evidence visuals. Native filters can flow seamlessly into your custom charts. You can leverage the Evidence query engine and semantic layer when constructing your visualization.

You can reference the active theme’s color palette and light/dark mode, so your custom visuals can look and feel like native Evidence components and respond to changes in your theme.

You can retrieve information about the current user, including which pages they have access to, and use it to control the content you render. You can trigger an Excel export on click.

We’ve recently added evidence.pages() to the SDK to make building access-aware navigation easier. It returns the pages available to the current user, so a custom homepage or navigation component can automatically reflect their permissions.

The point is that you don’t need to generate an entirely separate application just because you want a custom input, chart, or navigation experience on one of your dashboards.

Make it reusable

Evidence includes a custom component system that lets you parameterize and abstract any block of Evidence code into a reusable component. That can be a block of Markdown, a custom SQL query, a native visualization, and of course, the HTML tag.

The first pass of a custom visual usually gets written right in the page where it’s needed. But over time, two things tend to happen.

First, you don’t really want to look at the code anymore.

It’s one thing to check some critical SQL. It’s another thing to skim past 300 lines of LLM-generated JavaScript. That code is fine to see in a diff once, but you don’t want to scroll past it every time you edit the report.

Second, you want to parameterize and reuse it.

That great navigation header you built for the finance team, with the download-Excel-spreadsheets button? You want it on every page in the finance folder, with the relevant downloads for each page.

So you move the implementation into a custom component.

A component can combine SQL, native Evidence elements, and custom HTML in a single definition.

For example, a reusable financial summary component might look like this:

components/financial_summary.md

---
type: component
attributes:
  unit:
    type: string
    required: true
---

```sql performance
select
  account,
  sum(actual) as actual,
  sum(budget) as budget
from finance.monthly_results
where business_unit = '{{ $unit }}'
group by account
```

{% bar_chart
  data="performance"
  x="account"
  y="actual"
/%}

{% html %}
  ...a bunch of frontend code no one should read...
{% /html %}

And in your actual report, you just invoke it:

{% financial_summary unit="North" /%}

{% financial_summary unit="West" /%}

That’s it. Your report is readable again.

You can review the SQL and implementation separately, make changes in one place, and have the same component used across dozens of reports.

Your coding agents can also invoke that existing component instead of generating the same 300 lines of JavaScript from scratch every time.

What are teams actually building?

We’ve all seen the vendor demos on LinkedIn.

You can build Mario Kart on your governed metrics! You can finally do drop caps! You can make the file explorer from Jurassic Park about your business data!

But these aren’t the things we see customers building in practice. The real life use cases are much more boring, and a lot more useful.

1. Custom homepages and content collections

Almost every team builds some sort of custom overview page for their organization or departments, blending metrics with the information architecture of their project.

Sometimes these are metrics trees, but often they’re just branded links to department homepages. Each one ends up uniquely reflecting the character and strategy of the organization building it.

Custom homepage with a hospital network operations overview, headline metrics, and service-line cards linking to department reports

2. Financial tables

The built-in table visualization in your BI tool just never hits right if you’re presenting the balance sheet.

It’s almost always easier to vibe code the exact set of tables you need than to convince your CFO to live with the one you’ve got.

Hierarchical formatting, indentation, subtotals, variance columns, and all the other details that make a financial report look like a financial report.

Operating statement comparing actuals to budget, with indented line items, subtotals, and variance columns

3. Scenario planning and complex inputs

A table of assumptions that can be adjusted and reset. A fly-out with distributions over a slider. A custom input control that updates the rest of the dashboard.

These are small, specific interactions that make reports considerably more useful, but are difficult to build with a fixed library of BI components.

RN staffing plan with adjustable assumption sliders driving a forecast chart

Getting started with custom visuals in Evidence

The easiest way to get started is to open an existing Evidence page and ask your coding agent to build something using the HTML component.

Give it a screenshot of a visualization you’d like to reproduce, or describe a custom interaction you’ve always wanted on one of your reports.

Have your agent connect it to your existing queries, filters, and theme using the Evidence SDK. Once you’re happy with it, you can ask your agent to abstract it into a reusable component for the rest of your team.

Further reading