Back to Directus

Dashboard Panels

content/guides/09.extensions/3.app-extensions/4.panels.md

latest5.2 KB
Original Source

Panels are customizable components within :product-link{product="insights"} dashboards.

Panels are the building blocks of analytics dashboards, enabling rapid, no-code creation of data visualizations with data from a Directus project. Panels can also contain interactive elements, making them suitable for building custom internal applications within dashboards.

:partial{content="extensions-app"}

Panel Entrypoint

The index.js or index.ts file exports an object that is read by Directus. It contains properties that control how a panel is displayed within menus, it’s minimum width and height on the dashboard grid, what configurable options will be available to users, and the actual Vue component that will be loaded.

Entrypoint Example

js
import { defineInterface } from '@directus/extensions-sdk'
import PanelComponent from './panel.vue';

export default defineInterface({
	id: 'custom',
	name: 'Custom',
	icon: 'box',
	description: 'This is my custom panel!',
	component: PanelComponent,
	minWidth: 12,
	minHeight: 8,
	options: [
		{
			field: 'text',
			name: 'Text',
			type: 'string',
			meta: {
				interface: 'input',
				width: 'full',
			},
		},
	],
});

Properties

PropertyTypeDescription
idstringA unique identifier for this extension.
namestringThe displayed name for this panel in the Data Studio.
iconstringAn icon name from the Google Material Icons set. Supports filled and outlined variants.
descriptionstringA description of this panel shown in the Data Studio. Maximum 80 characters.
componentcomponentA reference to the Vue component rendered in the dashboard.
minWidthnumberSmallest number of grid units in the dashboard.
minHeightnumberSmallest number of grid units in the dashboard.
optionsarray | component
previewstringInline SVG to display in panel selection drawer.

:partial{content="extensions-uid"}

:partial{content="extensions-theme"}

Panel Component

The panel component is a Vue component that will be rendered in the Data Studio within a dashboard. Data from the entrypoint are passed in as props.

Component Example

This example assumes there is an item in the entrypoint’s options array with a field value of text.

vue
<template>
	<div class="text" :class="{ 'has-header': showHeader }">
		{{ text }}
	</div>
</template>

<script setup>
defineProps(['showHeader', 'text']);
</script>

<style scoped>
.text {
	padding: 12px;
}

.text.has-header {
	padding: 0 12px;
}
</style>

Props

The panel component will be passed all user configuration options from the entrypoint file. It will also receive the following props:

PropTypeDescription
iduuidThe UUID for this panel. This is for a specific instance of the panel and will not be the defined id in the entrypoint file.
dashboarduuidThe UUID for the dashboard containing the panel.
showHeaderbooleanWhether the panel header visibility is enabled in the options.
widthnumberThe current number of grid units wide the panel is.
heightnumberThe current number of grid units high the panel is.
nowdateThe date object at the time of loading the dashboard.

:partial{content="extensions-app-internals"}