Widgets
Last updated
Last updated
Dashboards are composed of widgets. Widgets are small self-contained cards that can display visualizations, data and allow users to take actions.
Users can add widgets to their dashboard from the hamburger menu on the top right.
Widgets can be dragged around and resized.
There are 3 steps to making a widget:
Building the widget component
Registering it
Declaring metadata in your
Widgets are standard react components. The component takes a single property uxpContext
which points to a object.
You can declare your props like this:
The dashboard will pass a context to your widget when it is rendered.
Here is a sample widget component:
Once your widget is built - you need to register your component as a widget. This includes setting up a unique id for your widget, mapping to your React component. You can also add other configuration here like the default size of your widget, whether or not it supports resizing, and if it requires any configuration parameters.
You need to use the registerWidget
function for that.
A simple example:
Typically you would want your widget component to have a standard border around it to maintain consistency with other widgets. The component can be used for this.
You will also typically want to have a title bar in your widget as most widgets have one. There is a standard component that you can use for this.
Note: The id you give for your widget must be unique among all interfaces declared in your .
Registering a widget is sufficient for testing your changes locally. When your changes to a server, you will have to provide extra metadata. These go into the configuration which would be in your root project directory.