Learn about the structure of a standalone Constellation DX component, and how to modify it to match your specific business need.
Updating the component definition
When you create a component, the Constellation DX Component Builder generates a config.json file, or component definition file. Every Constellation DX component created with Constellation DX Component Builder requires a component definition file to publish the component to Pega Platform™.
The component definition drives the UI authoring experience when you configure the component for use in Pega Platform, meaning that the property pane of the component in Pega Platform is defined by this file.
The UI view authoring relies on the information in the component definition to provide a streamlined experience when you edit the view metadata that is consumed at run time.
The component definition consists of header attributes and an array of property definitions. You can modify these attributes and add other attributes when you design your component.

This is an evolving schema that is expanding with each release. For more information on the component definition, see Component definition.
The headers of the component definition file will be generated during component creation, along with sample properties relating to the component type and sub-type selected. Update the properties section of the component definition file to ensure that the App Studio author configuring your component has the best possible authoring experience. This is especially important if you are building a library of reusable Constellation DX components that may need to be configured for use across different business domains or different data model contexts.
- Execution contexts of your component
- There are two types of component run-time modes:
- UI Authoring Preview mode
- Portal run-time mode
- UI Authoring Preview mode
- When using UI Authoring in App Studio, your component will be executed by the UI Authoring Preview if you are previewing as Constellation. However, if you are previewing as DX API, your component will not be executed.
Understanding your code
All Constellation DX components are functional React components with hooks that accept a set of props defined in the component props interface.
The current version of React used in Pega Platform 24.x is 17.0.2. However, it is expected to be updated to 18.0.2 in future major releases of Pega Platform. Constellation DX components are specifically designed to be used within the Constellation front-end architecture, which is a React single-page application. Please note that components created with other React frameworks and versions, including those that perform Server-side rendering (SSR), are not supported.
All Constellation DX components are created in the directory specified in the
tasks.config.json file. Most Constellation DX component
Builder projects typically use the default directory of
src/components located in the Constellation DX component
Builder project folder, which is created when you run the init
command through npx.
All components have the following common characteristics:
- Main React component code
- The index.tsx file contains the entry point for the component and contains the majority of the component code.
- Import declarations
-
- This contains the React imports used by your component.
- Several components are imported from the Constellation design system libraries. All Constellation DX components will have at least one import from the @pega/cosmos-react-core library. The version of the @pega/cosmos-react-core library and other Constellation design system libraries are predefined in your package.json file to align with the major version used by the Constellation front-end version that aligns with the version of Pega Platform you are using. You can use any components from the Constellation design system published on npm, but only a subset of these are documented with code examples on design.pega.com. Avoid changing these package.json versions as doing so may cause your component to stop rendering at runtime in a specific version of Pega Platform. For more information about the @pega/cosmos-react-core library, see @pega/cosmos-react-core.
- The
PConnFieldPropsproperty contains a standard set of types of Constellation DX components. - A Styled Component wrapper component is automatically generated by Constellation DX Component Builder during component creation and added to your import declarations. A separate file is generated containing boilerplate code for styled components. For more information, see Styling a component using Styled Components.
- Interface definition
- This is the standard interface definition that describes the properties of
your Constellation DX component. It extends the
PConnFieldPropsproperty, which defines a standard set of properties that are common to most Constellation DX components. ThePConnFieldPropsproperty is imported from the PConnProps.ts file, which defines thegetPConnectAPI and imports thePConnectobject from the @pega/pcore-pconnect-typedefs package that is automatically included in the package.json file of your project. For more information on the @pega/pcore-pconnect-typedefs package, see @pega/pcore-pconnect-typedefs.NOTE: Do not modify the PConnProps.ts file, as it might be moved to a shared directory in the future, along with other common files. - Component Render function
- The component render function is the main body of the functional component.
- Component definition
- For a component to be published, it must have a valid config.json file that is validated against the component schema during the build and publication process. For more information on the component definition, see Updating the component definition.
- Storybook
- For more information on Storybook stories and the associated mock data, see Creating Storybook mocks for standalone Constellation DX components.
- Migration of code to TypeScript
- Over time, the samples of Constellation DX components have changed as Constellation DX Component Builder has transitioned to TypeScript and moved away from using PropTypes in the samples. Although TypeScript and PropTypes do not completely overlap, most React components do not use both. TypeScript is used for type-checking during development, while PropTypes can be used to enforce basic run-time type-checking of props passed into React components.
Styling a component using Styled Components
The Constellation design system uses styled components to encapsulate CSS styles for a Constellation DX component in a JavaScript object scoped to your component. This is commonly referred to as CSS-in-JS. For more information on styled components, see Styled Components.

In the above figure, the highlighted base.palette['brand-primary']
design token points to the base.colors.blue.medium design token,
which is set to the static RGB value #076bc9.
![A screen shot of VS Code depicting the background color of the component uses the theme design token that represents the brand-primary color provided by the theme object: theme.base.palette['brand-primary'].](https://docs-be.pega.com/bundle/constellation-dx-components/page/constellation-dx-components/custom-components/../images/token-for-styled-components-using-theme-object.png?_LANG=enus)
In this example, the background color of the component uses the theme design token
that represents the brand-primary color provided by the
theme.base.palette['brand-primary'] design token.
Using Constellation design system's design tokens through the theme object ensures that your Constellation DX component will always reflect the portal theme applied in App Studio. This will result in a polished and integrated experience for end users and App Studio authors.
![A screenshot depicting the Branding style that maps to the theme.base.palette['brand-primary'] design token.](https://docs-be.pega.com/bundle/constellation-dx-components/page/constellation-dx-components/custom-components/../images/demo-theme.png?_LANG=enus)
In the above figure, we have changed the Branding style that maps to the
theme.base.palette['brand-primary'] design token.
There may be instances where you need to override the applied out-of-the-box theme. In such cases, base your overrides on the original design tokens so that any changes to the token values will also be reflected in your overrides.
Any changes made in App Studio will reflect in the underlying Rule-UI-Theme instance and also for advanced theming you can edit the Rule-UI-Theme directly in DevStudio as long as you adhere to the Theme properties schema. For more information, see Theme properties.
The Constellation design system and Constellation front-end must have control over where styles are applied in portals and views. To ensure the integrity of Constellation design system styles, Constellation DX components have a special loader that prevents the styles in your component from impacting the global styles. To ensure that your Constellation DX component always previews well in UI Authoring and has your styles applied when being rendered through a Web Embed, use the Configuration component provided by the Constellation design system.
All Constellation DX component samples from Pega Platform 23.x onwards use the withConfiguration higher order component wrapper provided by the @pega/cosmos-react-core library. Therefore, you do not need to perform any additional actions as this wrapper ensures that the Configuration component is properly applied to your component at run time, and that your component styles will be applied in all execution contexts. For more information about the @pega/cosmos-react-core library, see @pega/cosmos-react-core.
Working with external libraries
When working with external libraries, check if they are compatible with React 17 and Styled Components v5.
