Dashboard modal extensions allow you to add modals to your headless project's dashboard. You can control the modal using openModal()
and closeModal()
from the dashboard SDK.
Follow the instructions below to:
Run the following command and follow the prompts to create a dashboard modal extension:
Enter a name for your modal's folder. The CLI will create this directory with the chosen name containing your modal's files.
Enter the name of your modal. This name will be used to refer to your modal in your project's dashboard.
Upon completion, the dashboard modal extension folder and files will be created in your local project files in the 'src/extensions/' folder with the following structure:
For more on the files and their structure, see Dashboard Modal Extensions Files and Code.
Run the following command to open the dev menu:
Choose a dashboard page to display. This will open a browser window previewing your project's dashboard page.
Add code to your dashboard page that triggers your modal to open. Use openModal()
from the dashboard SDK. You can find your modal's ID in the modal.json
file.
Edit your modal.tsx
file to customize the modal itself. For example, change the text inside <Text>
to My Dashboard Modal
:
Set your dashboard modal extension to interact with custom data passed by the openModal()
function or any data passed from the dashboard page hosting a menu plugin that navigates to your modal.
To retrieve the data, use the observeState()
function.
Use React to add code and logic to your modal.
Save your files.
Go back to your dashboard page, open your modal, and see your changes.
Now that your project is ready for production, you can build your project and release your project.
Run the following command to build your project:
Run the following command and follow the prompts to release your project:
For more information about building and deploying your project, see Build and Deploy a Project with the Wix CLI for Headless.
To delete an existing dashboard modal from your project, delete the subfolder under src/extensions/
that contains your dashboard modal's files.