Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

6.1 KB
Raw Blame

title: Question component reference summary: "Reference for the metabase-question web component attributes, the StaticQuestion and InteractiveQuestion SDK props, and the InteractiveQuestion layout components."

Question component reference

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.

{% include_file "{{ dirname }}/eajs/snippets/MetabaseQuestionAttributes.md" snippet="properties" %}

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

{% include plans-blockquote.html feature="Modular embedding SDK" sdk=true convert_pro_link_to_embedding=true %}

StaticQuestion embeds a view-only chart.

{% include_file "{{ dirname }}/sdk/api/snippets/StaticQuestionProps.md" snippet="properties" %}

React SDK InteractiveQuestion props

{% include plans-blockquote.html feature="Interactive charts" convert_pro_link_to_embedding=true is_plural=true %}

InteractiveQuestion embeds an interactive chart or a query editor.

{% include_file "{{ dirname }}/sdk/api/snippets/InteractiveQuestionProps.md" snippet="properties" %}

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:

{% include_file "{{ dirname }}/sdk/snippets/questions/customize-interactive-question.tsx" snippet="example-default-interactive-question" %}

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

{% include_file "{{ dirname }}/sdk/snippets/questions/customize-interactive-question.tsx" snippet="example-customized-interactive-question" %}

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