Skip to Content

Guides

Make the date filter match your app

Match the date filter's corners, text and selected colors to your app in light and dark mode.

Do this with your agent

embed-appearance

Help me with this Databrain task: Make the date filter match your app. Review my current appearance first. Show the smallest change and keep the other settings in place. Ask before applying changes.

Style the date filter with square corners and a colored bar on the selected preset.

Before you start

  • Your dashboard has a date filter.
  • Named date filter parts and preset styling require the plugin release that ships with this docs update ({{PLUGIN_VERSION}} or later).
  • Upgrade before you replace any existing class rules, flags or text keys. Older plugins ignore the new names.

Steps

  1. Set dashboard.filterBar in admin-theme-options to show the range in words. The filter name sits in the field border.

    {
      "dashboard": {
        "filterBar": { "labelPlacement": "inside", "dateRangeLabel": "on" }
      }
    }
  2. Add the CSS to your page. The scoped host selector reaches the popover in both embed designs.

    :root {
      --app-date-border: #8a97a6;
      --app-date-accent: #1f5fa8;
      --app-date-text: #1d2733;
      --app-date-hover: #eef3fa;
      --app-date-selected: #d6e4f5;
      --app-date-selected-text: #1d2733;
      --app-date-day-text: #ffffff;
    }
    
    dbn-dashboard::part(date-filter) {
      border-radius: 2px;
      border-color: var(--app-date-border);
    }
    
    dbn-dashboard::part(date-filter--open) {
      border-color: #1f5fa8;
      outline: 1px solid #1f5fa8;
      outline-offset: 0;
    }
    
    :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-menu) {
      border-radius: 2px;
    }
    
    :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-preset) {
      border-radius: 0;
      padding: 8px 12px;
      font-size: 14px;
      line-height: 20px;
      color: var(--app-date-text);
    }
    
    :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-preset):hover {
      background: var(--app-date-hover);
    }
    
    :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-preset--selected),
    :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-preset--selected):hover {
      background: linear-gradient(to right, var(--app-date-accent) 0 3px, var(--app-date-selected) 3px);
      color: var(--app-date-selected-text);
    }
    
    :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-day--selected) {
      background: var(--app-date-accent);
      color: var(--app-date-day-text);
      border-radius: 2px;
    }
  3. Add your dark colors under the class your app uses for dark mode. This example uses html.dark.

    html.dark {
      --app-date-border: #3d4b5c;
      --app-date-accent: #6ea8ff;
      --app-date-text: #e3e9f0;
      --app-date-hover: #1c2836;
      --app-date-selected: #1e3a5f;
      --app-date-selected-text: #ffffff;
      --app-date-day-text: #0b1420;
    }

Open the filter and hover over a preset. The selected row keeps its 3px bar on hover. Choose a preset and select Apply. The control shows the range in words. Its tooltip shows the exact dates.

What the theme sets

The filter button keeps its theme fill, text color and font when you set them in the theme. The picker uses internal CSS custom properties such as --popover for its surface and --popover-foreground for its text. The trigger uses --field-surface. Use theme fields or the parts below for overrides. The --app-date-* properties in the example belong to your page.

What you can style

PartWhat the viewer seesStatesStyle withThe embed keeps
date-filterThe date filter button that shows the chosen range, in the filter bar or on a card.open, disabled, invaliddbn-dashboard::part(date-filter), dbn-metric::part(date-filter)color, background, background-color, font-family, when the theme sets them
date-filter-menuThe date picker that opens from the date filter: presets and calendar.none:is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-menu)nothing
date-filter-presetOne preset in the date picker, for example “Last 7 days” or “Custom”.selected, disabled, active:is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-preset)nothing
date-filter-dayOne day in the date picker calendar.selected, disabled, active:is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-day)nothing
date-filter-valueThe words that say the chosen range, shown when the theme turns the date range label on.nonedbn-dashboard::part(date-filter-value), dbn-metric::part(date-filter-value)nothing

Parts and states lists the CSS each part takes. To remove search or specific presets, use Hide options.

Next, test the date filter with Playwright.