User Interface (UI)

In UXP, you can write the UI in three ways - using standard HTML Elements, built-in Spectrum UXP widgets, and Spectrum Web Components (recently added).

data-variant=info
data-slots=header, text1, text2
Scripts and plugins
In scripts, you can only create modal dialogs.
In plugins, you can create persistent plugin panels, visible at all times. Or command plugins, that can create modal dialogs only.

But before we proceed, it's important to understand some terminology

With that in mind, let's get into the details:

Differences

Now that you know the various options, you must understand their differences and limitations

That said, you can mix and match these three offerings to suit your use case. For example, the following will work seamlessly

<form> \<!-- plain HTML element --\>
   <sp-banner> \<!-- Spectrum Web Component --\>
     <div slot="header">Header text</div>
     <div slot="content">Content of the banner</div>
  </sp-banner>
  <sp-button variant="primary">I'm a button</sp-button> \<!-- Spectrum widget --\>
</form>

What's best for you?

The choice you make depends on your use case and the stage of development you are in.

If you are looking for a ready-made Adobe Spectrum-styled UI or are just getting started with programming your UI, we recommend you start your journey with SWC. Fall back to Spectrum UXP widgets for the comps that are not available yet. And use plain HTML elements when they are not available in either.

However, if you prefer vanilla HTML and don't mind undertaking the efforts of styling, use the HTML elements along with your custom stylesheet. Make sure you read the CSS Styling recipe.

<!-- // TODO add once the starter templates are ready

Additional notes

While writing a simple JS/HTML/CSS plugin is possible, those who are building plugins that have internal state management, or more complicated UI may benefit from commonly used UI libraries. The below examples are not necessarily only ones you can use but can serve as good starters if you already are familiar with a library.

We do not suggest that you use any particular library for your plugins but suggest that you read about them and decide for yourself what will work best for you.

React

React.js is one of the most used UI libraries. It's declarative and component-based, helping you break your UI into reusable components.

See react-starter for the sample project.

We soon will be adding more samples for other popular frameworks such as Vue, and Svelte.

Vue

Vue.js is another declarative UI library that's easy to learn.

See ui-vue-starter for the sample project. // TODO update link

Svelte

Svelte is different from the other two libraries, in the sense that it compiles your code to a simple JS application, shrinking its size.

See ui-svelte-starter for the sample project. // TODO update link -->

Reference material