Skip to main content
The UI module provides methods for controlling UI components in the Shopware Administration. Open a modal dialog with custom content or a location.
title
string
Modal title displayed in the header
locationId
string
If provided, renders the specified location inside the modal
textContent
string
If no locationId is provided, displays this text content in the modal. Only simple text is supported.
variant
string
Modal size variant: 'default', 'small', 'large', or 'full'Default: 'default'
showHeader
boolean
Whether to show the modal headerDefault: true
Whether to show the modal footerDefault: true
closable
boolean
Whether the modal can be closed by the userDefault: true
buttons
buttonProps[]
Array of button configurations for the modal footer
response
Promise<void>
Returns a promise that resolves when the modal opens

Example - Simple Modal

import { ui } from '@shopware-ag/admin-sdk';

// Open simple text modal
await ui.modal.open({
  title: 'Confirmation',
  textContent: 'Are you sure you want to continue?',
  variant: 'small',
  buttons: [
    {
      label: 'Cancel',
      variant: 'ghost',
      method: () => {
        ui.modal.close();
      }
    },
    {
      label: 'Confirm',
      variant: 'primary',
      method: async () => {
        await performAction();
        ui.modal.close();
      }
    }
  ]
});

Example - Location Modal

import { ui, location } from '@shopware-ag/admin-sdk';

// Register location
location.startRendering('custom-form', (_, { updateHeight }) => {
  return `
    <form id="custom-form">
      <input type="text" name="name" placeholder="Name" />
      <textarea name="description" placeholder="Description"></textarea>
    </form>
  `;
});

// Open modal with location
await ui.modal.open({
  title: 'Custom Form',
  locationId: 'custom-form',
  variant: 'large',
  buttons: [
    {
      label: 'Save',
      variant: 'primary',
      method: () => {
        const form = document.getElementById('custom-form');
        const formData = new FormData(form);
        saveFormData(formData);
        ui.modal.close();
      }
    }
  ]
});

Example - Full Screen Modal

await ui.modal.open({
  title: 'Preview',
  locationId: 'product-preview',
  variant: 'full',
  showFooter: false,
  closable: true
});

Close an open modal.
locationId
string
Optional location ID of the modal to close. If not provided, closes the last opened modal without a locationId.
response
Promise<void>
Returns a promise that resolves when the modal closes

Example

import { ui } from '@shopware-ag/admin-sdk';

// Close specific modal
await ui.modal.close({ locationId: 'custom-form' });

// Close last opened modal
await ui.modal.close();

Update an open modal’s properties.
locationId
string
required
Location ID of the modal to update
title
string
New modal title
showHeader
boolean
Update header visibility
Update footer visibility
closable
boolean
Update closable state
buttons
buttonProps[]
Update button configuration
response
Promise<void>
Returns a promise that resolves when the modal updates

Example

import { ui } from '@shopware-ag/admin-sdk';

// Update modal title and buttons
await ui.modal.update({
  locationId: 'custom-form',
  title: 'Edit Form (Modified)',
  buttons: [
    {
      label: 'Save Changes',
      variant: 'primary',
      method: saveChanges
    },
    {
      label: 'Discard',
      variant: 'danger',
      method: discardChanges
    }
  ]
});

Add a custom menu item to the administration sidebar.
label
string
required
Display label for the menu item
locationId
string
required
Location ID to render when the menu item is clicked
Show/hide the search bar on the pageDefault: true
displaySmartBar
boolean
Show/hide the smart bar on the pageDefault: true
parent
string
Parent menu entry under which to display the itemDefault: 'sw-extension'
position
number
Position of the menu item in the parent menuDefault: 110
response
Promise<void>
Returns a promise that resolves when the menu item is added

Example

import { ui, location } from '@shopware-ag/admin-sdk';

// Register location
location.startRendering('my-custom-page', () => {
  return `
    <div class="custom-page">
      <h1>My Custom Page</h1>
      <p>Content goes here...</p>
    </div>
  `;
});

// Add menu item
await ui.menu.addMenuItem({
  label: 'My Extension',
  locationId: 'my-custom-page',
  displaySearchBar: true,
  displaySmartBar: true,
  parent: 'sw-catalogue',
  position: 50
});

Example - Multiple Menu Items

// Add to different parent menus
await ui.menu.addMenuItem({
  label: 'Products Manager',
  locationId: 'products-manager',
  parent: 'sw-catalogue',
  position: 10
});

await ui.menu.addMenuItem({
  label: 'Order Analytics',
  locationId: 'order-analytics',
  parent: 'sw-order',
  position: 20
});

await ui.menu.addMenuItem({
  label: 'Customer Insights',
  locationId: 'customer-insights',
  parent: 'sw-customer',
  position: 30
});

Collapse the administration sidebar menu.
response
Promise<void>
Returns a promise that resolves when the menu collapses

Example

import { ui } from '@shopware-ag/admin-sdk';

await ui.menu.collapseMenu();

Expand the administration sidebar menu.
response
Promise<void>
Returns a promise that resolves when the menu expands

Example

import { ui } from '@shopware-ag/admin-sdk';

await ui.menu.expandMenu();

Media Modal

The media modal allows users to select media files from the Shopware media library.

mediaModal.open()

import { ui } from '@shopware-ag/admin-sdk';

const selectedMedia = await ui.mediaModal.open({
  allowMultiSelect: false,
});

if (selectedMedia) {
  console.log('Selected media:', selectedMedia);
}

Type Definitions

buttonProps

type buttonProps = {
  method: () => void;
  label: string;
  variant?: 'primary'|'ghost'|'danger'|'ghost-danger'|'contrast'|'context';
  size?: 'x-small'|'small'|'large';
  square?: boolean;
};

uiModalOpen

type uiModalOpen = {
  responseType: void;
  title?: string;
  locationId?: string;
  textContent?: string;
  variant?: 'default'|'small'|'large'|'full';
  showHeader?: boolean;
  showFooter?: boolean;
  closable?: boolean;
  buttons?: buttonProps[];
};

uiModalClose

type uiModalClose = {
  responseType: void;
  locationId?: string;
};

uiModalUpdate

type uiModalUpdate = {
  responseType: void;
  locationId: string;
  title?: string;
  showHeader?: boolean;
  showFooter?: boolean;
  closable?: boolean;
  buttons?: buttonProps[];
};
type menuItemAdd = {
  responseType: void;
  label: string;
  locationId: string;
  displaySearchBar?: boolean;
  displaySmartBar?: boolean;
  parent?: string;
  position?: number;
};

Best Practices

Use appropriate modal variants: 'small' for confirmations, 'large' for forms, and 'full' for previews.
Always provide a way to close modals, either through buttons or by keeping closable: true.
Menu items are added under 'sw-extension' by default. Use the parent parameter to organize items under relevant sections.

Button Variants

  • primary - Primary action button (blue)
  • ghost - Secondary button (transparent)
  • danger - Destructive action (red)
  • ghost-danger - Secondary destructive action
  • contrast - High contrast button
  • context - Contextual action button
  • default - Standard modal width (~600px)
  • small - Compact modal (~400px)
  • large - Wide modal (~900px)
  • full - Full screen modal

Build docs developers (and LLMs) love