Add Dashboard Modal Extensions with the CLI

The dashboard modal extension allows you to extend your Wix app's functionality by adding modals to your app's dashboard. You can control the modal using openModal() and closeModal() from the dashboard SDK or from useDashboard() in the dashboard-react SDK.

Follow the instructions below to:

  1. Create a dashboard modal extension for a Wix CLI app.
  2. Customize and test your dashboard modal extension.
  3. Build and deploy your app.

Before you begin

Step 1 | Create the extension

  1. Run the following command and follow the prompts to create a dashboard modal extension:

    Copy
    1
    npm run generate
  2. Enter a name for your modal's folder. The CLI will create this directory with the chosen name containing your modal’s files.

  3. Enter the name of your modal. This name will be used to refer to your modal in the Wix Dev Center.

Upon completion, the dashboard modal extension folder and files will be created in your local app files in the "dashboard" folder with the following structure:

Copy
1
src
2
└── dashboard
3
└── modals
4
└── <your-modal-folder-name>
5
├── modal.json
6
└── modal.tsx

For more on the files and their structure, see Dashboard Modal Extensions Files and Code.

Step 2 | Customize your modal

  1. Run the following command to open the dev menu:

    Copy
    1
    npm run dev
  2. Choose a dashboard page to display. This will open a browser window previewing your dashboard page.

  3. Add code to your dashboard page that triggers your modal to open. Use openModal() from the dashboard SDK or from useDashboard() in the dashboard-react SDK. You can find your modal's ID in the modal.json file.

  4. Edit your modal.tsx file to customize the modal itself. For example, change the text inside <Text> to My Dashboard Modal:

    Copy
    1
    function Modal() {
    2
    const { closeModal } = useDashboard();
    3
    4
    return (
    5
    <WixDesignSystemProvider>
    6
    <MessageModalLayout
    7
    title="Wix CLI Modal"
    8
    primaryButtonText="Close"
    9
    primaryButtonOnClick={() => closeModal()}
    10
    >
    11
    <Box direction="vertical" align="center" paddingTop="4">
    12
    <Text>My Dashboard Modal</Text>
    13
    </Box>
    14
    </MessageModalLayout>
    15
    </WixDesignSystemProvider>
    16
    );
    17
    }
  5. Save your files.

  6. Go back to your dashboard page, open your modal, and see your change.

Step 3 | Build and deploy your app

Now that your app is ready for production, you can build your app and create a version in the Dev Center.

  1. Run the following command to build your app:

    Copy
    1
    npm run build
  2. Run the following command and follow the prompts to create an app version:

    Copy
    1
    npm run create-version

    An app version allows you to publish an app to the Wix App Market or install it on a site with a direct install URL.

For more information about building and deploying your app, see Build and Deploy an App with the CLI.

Was this helpful?
Yes
No