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-appearanceHelp 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/pluginat the plugin release that ships with this docs update ({{PLUGIN_VERSION}}or later). This release adds named parts,hideand 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
- 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.
- Replace each test selector with
[part~="name"]. - 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 used | Region | Style with | Select in tests |
|---|---|---|---|
A hashed name such as ._popover_decz1_14 or ._menu_decz1_40 | The 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-container | A card. When the theme sets its corner radius and padding, those come from the theme. | dbn-dashboard::part(card) | [part~="card"] |
.dbn-metric-card-title | The card name | dbn-dashboard::part(card-title) | [part~="card-title"] |
.dbn-selectBox, or [data-testid="datepicker-btn"] for the date filter | A filter control | dbn-dashboard::part(filter), dbn-dashboard::part(date-filter) | [part~="filter"], [part~="date-filter"] |
.cta-primary | The 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 tried | Region | Use instead |
|---|---|---|
| CSS on the axis name, such as “Revenue” beside an axis | Axis 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 marks | Lines on the chart canvas | chart.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 set | New option | What to check |
|---|---|---|
global | hide='{ "search": true }' | Hides search in every filter. Keep the old flag to hide it in one filter. |
isHideChartSettings | hide='{ "chartSettings": true }' | - |
isHideTablePreview | hide='{ "tablePreview": true }' | - |
disableDownloadPng | hide='{ "download": true }' | Also hides dashboard ZIP and PDF, CSV, and underlying-data exports. Keep the old flag to hide PNG only. |
disableFullscreen | hide='{ "fullScreen": true }' | Also turns enableTitleClickFullscreen off |
options.disableLayoutCustomization | hide='{ "customizeLayout": true }' | - |
options.disableManageMetrics | hide='{ "manageMetrics": true }' | - |
disableUnderlyingData (options.disableUnderlyingData on the dashboard) | hide='{ "underlyingData": true }' | - |
options.hideDashboardName | hide='{ "dashboardName": true }' | - |
isDisableCardTitle | hide='{ "cardTitle": true }' | - |
hideDashboardFilters | hide='{ "filters": ["..."] }' | Keeps defaults and restored selections. Keep the old flag to remove a filter and its default. |
hideDatePickerOptions | hide='{ "datePresets": ["..."] }' | - |
custom-messages key empty | custom-messages key empty.title | - |
custom-messages key noData | custom-messages key empty.title | - |
custom-messages key error | custom-messages key error.title | - |
custom-messages key retry | custom-messages key error.retry | - |
- Keep
disableDownloadPngto hide PNG only.hide.downloadalso hides dashboard ZIP and PDF and exports from underlying-data dialogs. The guest token still controls server access. - Keep
hideDashboardFiltersto remove filters and their defaults. Usehide.filtersto hide controls while keeping defaults and restored selections. - Keep
globalFilterOptions[name].isHideSearchto hide search in one filter.hide.searchhides search in all filter menus. - Keep
disableFullscreenwithenableTitleClickFullscreenif viewers should open full screen only by selecting the title.hide.fullScreenremoves both ways to open it. hideDatePickerOptionshides presets in the date pickers on cards.hide.datePresetsalso hides them in the dashboard date filter.- For
hide, a control is hidden when the old flag or thehidekey hides it."key": falsenever 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.
| Area | Older releases | Current release |
|---|---|---|
Date filter with your datePresetOptions list | Only your presets | Your 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 presets | Full UTC hours before the current hour | The same. Add timeZone: "UTC" to run to the current UTC minute. See Hour presets. |
| Week grouping on Trino | A backend without the WEEK fix can fail with mismatched input 'DAY', including self-hosted 1.2.36 | Check your Databrain backend release notes for the fix. Until then, use a custom SQL dimension with date_trunc('week', your_column). |