New components
Instructions on creating a new component
This guide walks you through the process of adding a new component in Preswald. For this example, we will create a component named helloworldcomponent
. When adding your own component, replace helloworldcomponent
with your desired component name.
1) Modify preswald/preswald/interfaces/components.py
Add your new component under the existing ones:
2) Modify preswald/preswald/interfaces/__init__.py
Add helloworldcomponent
to the list of available components.
3) Create a Frontend Component
Create a new file in the frontend component directory:
Path: /preswald/frontend/src/components/widgets/HelloWorldWidget.jsx
4) Register Component in DynamicComponents.jsx
Modify frontend/src/components/DynamicComponents.jsx
to add a case for your new component:
5) Test Usage
Modify the example script at examples/iris/hello.py
:
Run the test:
Verify that ‘Hello World’ appears in the output.
6) Customize Your Component
Now that the basic structure is in place, you can customize the component’s appearance and functionality further as needed.
Was this page helpful?