Question component reference

Reference for the metabase-question web component attributes, the StaticQuestion and InteractiveQuestion SDK props, and the InteractiveQuestion layout components.

Reference material for embedding a chart or a query editor: the attributes you can set on the <metabase-question> web component, the props you can pass to the SDK’s StaticQuestion and InteractiveQuestion components, and the namespaced components you can use to build your own layout.

For how to set all this up, check out Embed a chart and Embed the query builder.

Web component metabase-question attributes

These attributes apply to the <metabase-question> web component. For the SDK, see StaticQuestion props and InteractiveQuestion props.

Property Type Description
custom-context
string
Optional custom context string passed through to the guest token endpoint.
Optional
Available in Guest embed
drills
boolean
Whether to enable drill-through on the question.
Optional
Default true
Available in Pro/Enterprise
entity-types
string[]
Which entity types to show in the question’s data picker, e.g. ["model", "table"].
Optional
Possible values "model", "table"
Available in Pro/Enterprise and Guest embed
hidden-parameters
string[]
List of parameter names to hide from the question.
Optional
Available in Pro/Enterprise
initial-sql-parameters
object
Default values for SQL parameters, only applicable to native SQL questions, e.g. { "productId": "42" }.
Optional
Available in Pro/Enterprise and Guest embed
is-save-enabled
boolean
Whether the save button is enabled.
Optional
Default false
Available in Pro/Enterprise
question-id
string | number
The ID of the question to embed. Can be a regular ID or an entity ID. Use "new" to embed the query builder, or "new-native" to embed the SQL editor. Only for SSO embeds — guest embeds use token.
sql-parameters
object
Controlled SQL parameter values, e.g. { "productId": "42" }. Setting this attribute supersedes initial-sql-parameters as the seed and stays in sync with subsequent mutations. Pair with the sql-parameters-change DOM event to track edits.
Optional
Available in Pro/Enterprise and Guest embed
target-collection
string | number
The collection to save a question to. Values: regular ID, entity ID, "personal", "root".
Optional
Available in Pro/Enterprise
token
string
The token for guest embeds. Set automatically by the guest embed flow.
Optional
Available in Guest embed
with-alerts
boolean
Whether to show the alerts button.
Optional
Default false
Available in Pro/Enterprise
with-downloads
boolean
Whether to show download buttons for question results.
Optional
Default true on OSS/Starter, false on Pro/Enterprise
Available in Guest embed
with-title
boolean
Whether to show the question title in the embed.
Optional
Default true
Available in Guest embed

Depending on the framework you’re using, you may need to stringify attributes before passing them to the component. And if you surround an attribute’s value with double quotes, use single quotes inside it:

<metabase-question
  question-id="1"
  initial-sql-parameters="{ 'productId': '42' }"
  hidden-parameters="['productId']"
></metabase-question>

These examples use sequential IDs — the number in the item’s URL. On Pro and Enterprise plans, you can use entity IDs instead; they stay the same when you serialize content from one Metabase to another, like from staging to production.

React SDK StaticQuestion props

Modular embedding SDK is only available on Pro and Enterprise plans (both self-hosted and on Metabase Cloud).

StaticQuestion embeds a view-only chart.

Property Type Description
card
string | MetabaseCard
An ad-hoc question to render without saving it first. Either a MetabaseCard object, or a serialized card string copied from a question URL hash (/question#<base64> or the bare base64).
Optional
className
string
A custom class name to be added to the root element.
Optional
height
Height<string | number>
A number or string specifying a CSS size value that specifies the height of the component
Optional
hiddenParameters
string[]
A list of parameters to hide.
Optional
initialSqlParameters
Initial values for SQL parameters, slug-keyed. Applied once on mount; user widget edits afterwards are not reflected back to the host.
For each parameter:
- set to a value: that value is applied.
- set to null: strictly cleared, ignoring the parameter’s default.
- omitted (or set to undefined): falls back to the parameter’s default (or null if it has no default).
Optional
onSqlParametersChange
(payload: SqlParameterChangePayload) => void
Fires on SQL parameters change. The payload’s source distinguishes the initial state on load ('initial-state'), user edits in the UI ('manual-change'), and auto-updates ('auto-change').
Optional
query
A table-backed ad hoc query created with useMetabaseQueryObject.
Optional
questionId
The ID of the question.
This is either:
- the numerical ID when accessing a question link, i.e. http://localhost:3000/question/1-my-question where the ID is 1
- the string ID found in the entity_id key of the question object when using the API directly or using the SDK Collection Browser to return data
- new to show the notebook editor for creating new questions
- new-native to show the SQL editor for creating new native questions
Optional
sqlParameters
Controlled SQL parameter values, slug-keyed. On every render, this object replaces the question’s parameter values:
- a parameter set to a value uses that value.
- a parameter set to null is cleared, even if it has a default.
- a parameter omitted from the object (or set to undefined) uses its default (or null if it has no default).

Pair with onSqlParametersChange to stay in sync with user edits.
Optional
style
A custom style object to be added to the root element.
Optional
title
Determines whether the question title is displayed, and allows a custom title to be displayed instead of the default question title. Shown by default.
Optional
token
string | null
A valid JWT token for the guest embed.
Optional
width
Width<string | number>
A number or string specifying a CSS size value that specifies the width of the component
Optional
withAlerts
boolean
Enables the ability to set up alerts on the question.
Optional
withChartTypeSelector
boolean
Determines whether the chart type selector and corresponding settings button are shown. Only relevant when using the default layout.
Optional
withDownloads
boolean
Enables the ability to download results in the question.
Optional

React SDK InteractiveQuestion props

Interactive charts are only available on Pro and Enterprise plans (both self-hosted and on Metabase Cloud).

InteractiveQuestion embeds an interactive chart or a query editor.

Property Type Description
card
string | MetabaseCard
An ad-hoc question to render without saving it first. Either a MetabaseCard object, or a serialized card string copied from a question URL hash (/question#<base64> or the bare base64).
Optional
className
string
A custom class name to be added to the root element.
Optional
dataPicker
Controls the menu for selecting data sources in questions. You can opt for the full data picker by setting dataPicker = "staged".
Optional
entityTypes
An array that specifies which entity types are available in the data picker
Optional
height
Height<string | number>
A number or string specifying a CSS size value that specifies the height of the component
Optional
hiddenParameters
string[]
A list of parameters to hide.
Optional
initialCollection
The collection to preselect in the save modal’s collection picker. Unlike targetCollection, the picker remains visible and the user can choose a different collection. Ignored when targetCollection is set.
Optional
initialSqlParameters
Initial values for SQL parameters, slug-keyed. Applied once on mount; user widget edits afterwards are not reflected back to the host.
For each parameter:
- set to a value: that value is applied.
- set to null: strictly cleared, ignoring the parameter’s default.
- omitted (or set to undefined): falls back to the parameter’s default (or null if it has no default).
Optional
isSaveEnabled
boolean
Whether to show the save button.
Optional
onBeforeSave
(question: MetabaseQuestion | undefined, context: { isNewQuestion: boolean; }) => Promise<void>
A callback function that triggers before saving. Only relevant when isSaveEnabled = true
Optional
onNavigateBack
() => void
A callback function that triggers when a user clicks the back button.
Optional
onRun
(question: MetabaseQuestion | undefined) => void
A callback function that triggers when a question is updated, including when a user clicks the Visualize button in the question editor
Optional
onSave
(question: MetabaseQuestion, context: { dashboardTabId?: number; isNewQuestion: boolean; }) => void
A callback function that triggers when a user saves the question. Only relevant when isSaveEnabled = true
Optional
onSqlParametersChange
(payload: SqlParameterChangePayload) => void
Fires on SQL parameters change. The payload’s source distinguishes the initial state on load ('initial-state'), user edits in the UI ('manual-change'), and auto-updates ('auto-change').
Optional
onVisualizationChange
(display: | "object" | "table" | "bar" | "line" | "pie" | "scalar" | "row" | "area" | "combo" | "pivot" | "smartscalar" | "gauge" | "progress" | "funnel" | "map" | "scatter" | "boxplot" | "waterfall" | "sankey" | "treemap" | "list") => void
A callback function that triggers when the visualization type changes.
Optional
plugins
-
Optional
query
A table-backed ad hoc query created with useMetabaseQueryObject.
Optional
questionId
The ID of the question.
This is either:
- the numerical ID when accessing a question link, i.e. http://localhost:3000/question/1-my-question where the ID is 1
- the string ID found in the entity_id key of the question object when using the API directly or using the SDK Collection Browser to return data
- new to show the notebook editor for creating new questions
- new-native to show the SQL editor for creating new native questions
Optional
sqlParameters
Controlled SQL parameter values, slug-keyed. On every render, this object replaces the question’s parameter values:
- a parameter set to a value uses that value.
- a parameter set to null is cleared, even if it has a default.
- a parameter omitted from the object (or set to undefined) uses its default (or null if it has no default).

Pair with onSqlParametersChange to stay in sync with user edits.
Optional
style
A custom style object to be added to the root element.
Optional
targetCollection
The collection to save the question to. This will hide the collection picker from the save modal. Only applicable to interactive questions.
Optional
title
Determines whether the question title is displayed, and allows a custom title to be displayed instead of the default question title. Shown by default.
Optional
token
string | null
A valid JWT token for the guest embed.
Optional
width
Width<string | number>
A number or string specifying a CSS size value that specifies the width of the component
Optional
withAlerts
boolean
Enables the ability to set up alerts on the question.
Optional
withChartTypeSelector
boolean
Determines whether the chart type selector and corresponding settings button are shown. Only relevant when using the default layout.
Optional
withDownloads
boolean
Enables the ability to download results in the question.
Optional
withEditorButton
boolean
Determines whether the editor button is shown. Only relevant when using the default layout.
Optional

Customize the layout of an interactive chart

By default, InteractiveQuestion comes with a layout that lets people view the question, apply filters and aggregations, and use the query builder:

<InteractiveQuestion questionId={95} />

To build your own layout, use namespaced components inside InteractiveQuestion (like <InteractiveQuestion.Filter />):

<div
  className="App"
  style={{
    width: "100%",
    maxWidth: "1600px",
    height: "800px",
    margin: "0 auto",
  }}
>
  <MetabaseProvider authConfig={authConfig} theme={theme}>
    <InteractiveQuestion questionId={95}>
      <div
        style={{
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          justifyContent: "center",
          width: "100%",
        }}
      >
        <div style={{ display: "grid", placeItems: "center", width: "100%" }}>
          <InteractiveQuestion.Title />
          <InteractiveQuestion.ResetButton />
        </div>
        <div
          style={{
            display: "flex",
            alignItems: "center",
            justifyContent: "flex-start",
            overflow: "hidden",
            width: "100%",
          }}
        >
          <div style={{ width: "100%" }}>
            <InteractiveQuestion.QuestionVisualization />
          </div>
          <div style={{ display: "flex", flex: 1, overflow: "scroll" }}>
            <InteractiveQuestion.Summarize />
          </div>
        </div>
        <div
          style={{ display: "flex", flexDirection: "column", width: "100%" }}
        >
          <InteractiveQuestion.Filter />
        </div>
      </div>
    </InteractiveQuestion>
  </MetabaseProvider>
</div>

React SDK InteractiveQuestion components

These components are available via the InteractiveQuestion namespace (like <InteractiveQuestion.Filter />). Use them to customize the layout of an interactive question.

InteractiveQuestion.BackButton is deprecated. Use InteractiveQuestion.NavigationBackButton instead.

Further reading

Read docs for other versions of Metabase.