UXP
v2.0.0
v2.0.0
  • Introduction
    • Welcome
    • Understanding the Portal
    • Getting Started
  • Releases
  • Interface Types
    • Widgets
  • Interface Guidelines
    • Lists
  • Interacting with Lucy
    • Real-Time Communication
  • Interface Guidelines
  • Custom Styles and CSS
  • Publishing your UIs
    • Bundles
  • lucy-xp
  • Components
    • AsyncButton
    • AutoCompleteInput
    • BarChartLoader
    • Button
    • CRUDComponent
    • CalendarComponent
    • Checkbox
    • ColorPallet
    • ColorPicker
    • ConfirmButton
    • DataGrid
    • DataList
    • DataTable
    • DatePicker
    • DateRangePicker
    • DateTimePicker
    • DefaultLoader
    • DonutChartLoader
    • DropDownButton
    • DynamicForm
    • DynamicSelect
    • FileInput
    • FilterPanel
    • FormFeedback
    • FormField
    • GaugeLoader
    • HeatmapChartLoader
    • HorizontalScrollList
    • IconButton
    • Input
    • ItemCard
    • ItemListCard
    • Label
    • LinkButtonWidget
    • LinkWidgetContainer
    • Loading
    • LoadingSpinner
    • LocalizationForm
    • LocalizationFormModal
    • MapComponent
    • Modal
    • ModalWizard
    • MultiSelect
    • NotificationBlock
    • PieChartComponent
    • Popover
    • PortalContainer
    • ProfileImage
    • RadialGauge
    • SampleDataLabel
    • SearchBox
    • Select
    • SideBar
    • SpaceworxDescriptionTag
    • TabComponent
    • TableComponent
    • TextArea
    • ThemeChanger
    • TimePicker
    • TimeRangePicker
    • TitleBar
    • ToggleFilter
    • Tooltip
    • TreeViewSelectInput
    • TrendChartComponent
    • UserProfile
    • WidgetContainerBlock
    • WidgetWrapper
    • Wizard
  • Hooks
    • useAlert
    • useDebounce
    • useEffectWithPolling
    • useEventSubscriber
    • useFields
    • useMessageBus
    • useResizeEffect
    • useToast
    • useUpdateWidgetProps
  • Types
    • ActionResponse
    • CRUDComponentInstanceProps
    • CRUDComponentProps
    • Column
    • DynamicFormFieldProps
    • DynamicFormProps
    • ExtendedFormProps
    • FieldsHook
    • FormProps
    • FormSectionProps
    • FormValue
    • IAlertResult
    • IAnimation
    • IAutoCompleteInputInstanceProps
    • IButtonSize
    • IButtonType
    • IBuyOnSpaceworxButtonProps
    • ICalendarComponentProps
    • ICallback
    • ICheckboxInstanceProps
    • ICheckboxType
    • ICircleBound
    • IColorPalletProps
    • IColorPickerPosition
    • IColorPickerProps
    • IColorTypes
    • IContentFunction
    • IDataFunction
    • IDataItem
    • IDataTableColumn
    • IDatePickerProps
    • IDateRangePickerProps
    • IDateTimePickerProps
    • IDivIconInterface
    • IDropDownButtonPosition
    • IDropDownButtonProps
    • IDynamicSelectDataFunction
    • IEventDispatcher
    • IEventSubscriber
    • IFileInputInstanceProps
    • IFileInputProps
    • IGaugeProps
    • IHeatmapConfiguration
    • IHeatmapPoint
    • IInputInstanceProps
    • IInputType
    • ILanguage
    • ILocalisationFormModalInstanceProps
    • ILocalisationFormModalProps
    • ILocalisationFormProps
    • IMarker
    • IMessage
    • IModalWizardProps
    • IModalWizardStep
    • IModalWizardStepProps
    • IMultiSelectProps
    • IPolygonBound
    • IPopoverPosition
    • IPopoverProps
    • IPortalContainerProps
    • IPosition
    • IPreviewDetails
    • IProfileProps
    • IRegion
    • IRemove
    • IRenderMarkerPopup
    • IRenderMarkerTooltip
    • ISampleDataLabelProps
    • ISearchBoxInstanceProps
    • ISelectProps
    • ISidebarProps
    • ISize
    • ISpaceworxDescriptionTagProps
    • IStaticImage
    • ITextAreaInstanceProps
    • IThemeChangerProps
    • ITitleFunc
    • IToast
    • IToastResult
    • IToggleOption
    • ITooltipPosition
    • ITooltipProps
    • IUseEffectWithPolling
    • IUseUpdateWidgetProps
    • IWidgetContainerBlockProps
    • IWidgetPreloaderLoaderProps
    • IWidgetWrapperProps
    • IWizardStep
    • IWizardStepProps
    • ListProps
    • MessageBusHook
    • PaginationProps
    • RenderCustomFormView
    • ResizeEffectHook
    • TabComponentProps
    • TabComponentStyles
    • TableComponentProps
    • ToastHook
    • TreeViewSelectInputInstanceProps
    • TreeViewSelectInputProps
    • regionType
Powered by GitBook
On this page
  • Building Widgets
  • Registering Widgets
  • Defining widgets in your bundle
  1. Interface Types

Widgets

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:

  1. Building the widget component

  2. Registering it

  3. Declaring metadata in your bundle

Building Widgets

Widgets are standard react components. The component takes a single property uxpContext which points to a Context object.

You can declare your props like this:

interface IWidgetProps {
    uxpContext?: IContextProvider
}

The dashboard will pass a context to your widget when it is rendered.

Here is a sample widget component:

const HelloWorldWidget:React.FunctionComponent<IWidgetProps> = (props) => {
    return <div className='hello'>Hello World</div>;
}

Typically you would want your widget component to have a standard border around it to maintain consistency with other widgets. The WidgetWrapper component can be used for this.

const HelloWorldWidget:React.FunctionComponent<IWidgetProps> = (props) => {
    return <WidgetWrapper>
        <div className='hello'>Hello World</div>
    </WidgetWrapper>;
}

You will also typically want to have a title bar in your widget as most widgets have one. There is a standard TitleBar component that you can use for this.

const HelloWorldWidget:React.FunctionComponent<IWidgetProps> = (props) => {
    return <WidgetWrapper>
        <TitleBar title='My First Widget' />
        <div className='hello'>Hello World</div>
    </WidgetWrapper>;
}

Registering Widgets

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:

registerWidget({
  id:'helloworld',
  name:'Hello World Widget',
  widget:HelloWorldWidget,
});

Note: The id you give for your widget must be unique among all interfaces declared in your bundle.

Defining widgets in your bundle

Registering a widget is sufficient for testing your changes locally. When publishing your changes to a server, you will have to provide extra metadata. These go into the bundle.json configuration which would be in your root project directory.

PreviousInterface TypesNextInterface Guidelines

Last updated 1 year ago