Skip to Content

Guides

Move from internal class names to parts

Replace CSS and test selectors on internal class names, old flags and old message keys after you upgrade to the plugin release that adds named parts.

Do this with your agent

embed-appearance

Help me with this Databrain task: Move from internal class names to parts. Review my current appearance first. Show the smallest change and keep the other settings in place. Ask before applying changes.

Use named parts for styles and tests that survive changes to the embed markup.

Before you start

  • Install @databrainhq/plugin at the plugin release that ships with this docs update ({{PLUGIN_VERSION}} or later). This release adds named parts, hide and the new text keys.
  • Upgrade first. On older plugins the new CSS selectors match nothing, and the new hide and text keys have no effect.
  • Dark mode needs plugin 0.17.0 or later. Update to {{PLUGIN_VERSION}} or later to use derived brand colors in dark mode. Select the built-in Brand chart palette.
  • List the CSS rules and test selectors on your page that use class names from inside the embed, such as ._bn-popover_hy292_46.

Steps

  1. Replace each class name rule with a part rule. Use the table below for the most common ones, and Parts and states for the rest.
  2. Replace each test selector with [part~="name"].
  3. Review Old flags and message keys. Use the new names where they preserve the behavior you need.

Before and after

Before, a test and a style rule that break on the next release:

page.locator('._bn-popover_x7k2_46');           // a build hash in the class name
/* CSS added inside the embed's shadow root, on internal class names */
._bn-card_9fa1_12 { box-shadow: none; }

After, the same intent on names that stay:

page.locator('[part~="date-filter-menu"]');
dbn-dashboard::part(card) { box-shadow: none; }

Most common class names

Use these replacements after you upgrade.

You usedRegionStyle withSelect in tests
A hashed name such as ._popover_decz1_14 or ._menu_decz1_40The date picker that opens from the date filter:is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-menu)[part~="date-filter-menu"]
.dbn-card-element or .dbn-metric-card-containerA card. When the theme sets its corner radius and padding, those come from the theme.dbn-dashboard::part(card)[part~="card"]
.dbn-metric-card-titleThe card namedbn-dashboard::part(card-title)[part~="card-title"]
.dbn-selectBox, or [data-testid="datepicker-btn"] for the date filterA filter controldbn-dashboard::part(filter), dbn-dashboard::part(date-filter)[part~="filter"], [part~="date-filter"]
.cta-primaryThe main action button, for example Apply:is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(button-primary)[part~="button-primary"]

The date picker and Apply open in the popover layer, so their rules start with the host set.

Some regions were never reachable with CSS on class names. Use the theme for these:

You triedRegionUse instead
CSS on the axis name, such as “Revenue” beside an axisAxis titles. The chart draws them on a canvas.chart.axis.titleStyle in the theme. See Grid lines, tick marks and axis titles.
CSS on chart grid lines or tick marksLines on the chart canvaschart.axis.gridLines and chart.axis.tickLines in the theme

Old flags and message keys

The old flags and the four old custom-messages aliases still work. Check the scope before switching.

You setNew optionWhat to check
globalFilterOptions[name].isHideSearchhide='{ "search": true }'Hides search in every filter. Keep the old flag to hide it in one filter.
isHideChartSettingshide='{ "chartSettings": true }'-
isHideTablePreviewhide='{ "tablePreview": true }'-
disableDownloadPnghide='{ "download": true }'Also hides dashboard ZIP and PDF, CSV, and underlying-data exports. Keep the old flag to hide PNG only.
disableFullscreenhide='{ "fullScreen": true }'Also turns enableTitleClickFullscreen off
options.disableLayoutCustomizationhide='{ "customizeLayout": true }'-
options.disableManageMetricshide='{ "manageMetrics": true }'-
disableUnderlyingData (options.disableUnderlyingData on the dashboard)hide='{ "underlyingData": true }'-
options.hideDashboardNamehide='{ "dashboardName": true }'-
isDisableCardTitlehide='{ "cardTitle": true }'-
hideDashboardFiltershide='{ "filters": ["..."] }'Keeps defaults and restored selections. Keep the old flag to remove a filter and its default.
hideDatePickerOptionshide='{ "datePresets": ["..."] }'-
custom-messages key emptycustom-messages key empty.title-
custom-messages key noDatacustom-messages key empty.title-
custom-messages key errorcustom-messages key error.title-
custom-messages key retrycustom-messages key error.retry-
  • Keep disableDownloadPng to hide PNG only. hide.download also hides dashboard ZIP and PDF and exports from underlying-data dialogs. The guest token still controls server access.
  • Keep hideDashboardFilters to remove filters and their defaults. Use hide.filters to hide controls while keeping defaults and restored selections.
  • Keep globalFilterOptions[name].isHideSearch to hide search in one filter. hide.search hides search in all filter menus.
  • Keep disableFullscreen with enableTitleClickFullscreen if viewers should open full screen only by selecting the title. hide.fullScreen removes both ways to open it.
  • hideDatePickerOptions hides presets in the date pickers on cards. hide.datePresets also hides them in the dashboard date filter.
  • For hide, a control is hidden when the old flag or the hide key hides it. "key": false never shows a control an old flag hid.
  • For text keys, when you set both the old key and the new key, the new key wins.

What changes in the current plugin

These changes apply after you upgrade the plugin, except for the Trino service fix.

AreaOlder releasesCurrent release
Date filter with your datePresetOptions listOnly your presetsYour presets and a Custom range at the end. Set includeCustomDateRange: false to keep only yours. See Filter state.
defaultOption as { timeGrainValue: "<label>" }The filter showed “Select an option”The filter opens on that preset
Hour presetsFull UTC hours before the current hourThe same. Add timeZone: "UTC" to run to the current UTC minute. See Hour presets.
Week grouping on TrinoA backend without the WEEK fix can fail with mismatched input 'DAY', including self-hosted 1.2.36Check your Databrain backend release notes for the fix. Until then, use a custom SQL dimension with date_trunc('week', your_column).

Next, test the parts with Playwright.