App Extensions

Dashboard Panels

Panels are customizable components within Directus Insights dashboards.

Panels are customizable components within 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.

A panel in the insights module

This extension type is loaded into the Directus Data Studio. They are are built with Vue 3, and can use the provided composables exported by the @directus/extensions-sdk package. Extensions can be written in JavaScript or TypeScript.

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

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.
Unique Identifiers
The extension id must not conflict with other extensions, so consider prefixing with author name.
Theme-Aware Previews
In your SVG, use available theme CSS variables such as --theme--primary and --theme--primary-subdued to match your panel preview with the project 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.

<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.

Using Directus Internals

To access internal systems like the API or the stores in app extensions, you can use the useApi() and useStores() composables exported by the @directus/extensions-sdk package.

Learn more about using Directus composables.

Directus UI components are globally registered, making them accessible throughout your extension without the need to import them.

Learn more about using the Directus UI library.

Using External APIs

To avoid Cross Site Request Forgery (CSRF), app extensions cannot make requests to external servers by default. A common approach to achieve this is to create a bundle containing an endpoint that makes the external request, and an app extension that uses the now-internal endpoint to retrieve data.

Learn more about building extensions through our tutorials.