The Application Class

The Application() class provides the foundation for UI elements in Foundry VTT. As a developer, you should extend this class to define your own custom UI concepts which can be rendered in-game.

class Application(options)

The standard application window that is rendered for a large variety of UI elements in Foundry VTT

  • options (Object) – Configuration options which control how the application is rendered
  • options.height (Number) – The height in pixels (or “auto”) for the rendered element
  • options.width (Number) – The width in pixels (or “auto”) for the rendered element
  • (Number) – The vertical position (from the top) of the rendered element
  • options.left (Number) – The horizontal position (from the left) of the rendered element
  • options.template (String) – The default HTML template path to use for applications of this type
  • options.popOut (Boolean) – Display the element wrapped in a containing window frame (true, the default) or only the inner HTML (false).
  • options.minimizable (Boolean) – Customize whether the application is able to be minimized by double-clicking the header. Default behavior is the value of options.popOut
  • options.resizable (Boolean) – Customize whether a window application window may be re-sized by dragging a handle in the bottom-right corner of the window display.

type: jQuery

An internal reference to the HTML element this application renders


Once the HTML for an Application has been rendered, activate event listeners which provide interactivity for the application

  • html (jQuery|HTMLElement) –

type: Number

The application ID is a unique incrementing integer which is used to identify every application window drawn by the VTT


Close the application and un-register references to it within UI mappings This function returns a Promise which resolves once the window closing animation concludes


Assign the default options which are supported by all Application classes. Application subclasses may include additional options which are specific to their usage. All keys are optional, descriptions and default values are listed below:


type: jQuery|HTMLElement

Return the active application element, if it currently exists in the DOM


An application should define the data object used to render its template. This function may either return an Object directly, or a Promise which resolves to an Object If undefined, the default implementation will return an empty object allowing only for rendering of static HTML


Return the CSS application ID which uniquely references this UI element


Maximize the pop-out window, expanding it to its original size Take no action for applications which are not of the pop-out variety or are already maximized

Returns:Promise – A Promise which resolves to true once the maximization action has completed

Minimize the pop-out window, collapsing it to a small tab Take no action for applications which are not of the pop-out variety or apps which are already minimized

Returns:Promise – A Promise which resolves to true once the minimization action has completed

type: Object

The options provided to this application upon initialization


type: boolean

Control the rendering style of the application. If popOut is true, the application is rendered in its own wrapper window, otherwise only the inner app content is rendered


type: Object

Track the current position and dimensions of the Application UI

Application.render(force=false, options)

Render the Application by evaluating it’s HTML template against the object of data provided by the getData method If the Application is rendered as a pop-out window, wrap the contained HTML in an outer frame with window controls

  • force (Boolean) – Add the rendered application to the DOM if it is not already present. If false, the Application will only be re-rendered if it is already present.
  • options (Object) – Additional rendering options which are applied to customize the way that the Application is rendered in the DOM.
  • options.left (Number) – The left positioning attribute
  • (Number) – The top positioning attribute
  • options.width (Number) – The rendered width
  • options.height (Number) – The rendered height
  • options.scale (Number) – The rendered transformation scale
  • options.log (Boolean) – Whether to display a log message that the Application was rendered
  • options.renderContext (String) – A context-providing string which suggests what event triggered the render
  • options.renderData (*) – The data change which motivated the render request
Application.setPosition(left, top, width, height, scale)

Set the application position and store it’s new location.

  • left (number|null) – The left offset position in pixels
  • top (number|null) – The top offset position in pixels
  • width (number|null) – The application width in pixels
  • height (number|string|null) – The application height in pixels
  • scale (number|null) – The application scale as a numeric factor where 1.0 is default

Object – The updated position object for the application containing the new values


type: string

The path to the HTML template file which should be used to render the inner content of the app


type: string

An Application window should define its own title definition logic which may be dynamic depending on its data

Application Example

This section provides a working example Application that could be defined in your game. When creating a module, or a UI component of a game system, you would pair this JavaScript code which defines the Application with an HTML template (options.template) as well as accompanying CSS rules to define how the HTML should be styled.

 * A simple demo application which displays each active player's impersonated Actor
 * Displays the portrait and health bar for that Actor

class PartySummary extends Application {

   * Define default options for the PartySummary application
  static get defaultOptions() {
    const options = super.defaultOptions;
    options.template = "public/modules/party-summary/templates/summary.html";
    options.width = 600;
    options.height = "auto";
    return options;

  /* -------------------------------------------- */

   * Return the data used to render the summary template
   * Get all the active users
   * The impersonated character for each player is available as user.character
   getData() {
    return game.users.entities.filter(u =>;

  /* -------------------------------------------- */

   * Add some event listeners to the UI to provide interactivity
   * Let's have the game highlight each player's token when their name is clicked on
  activateListeners(html) {

    html.find(".actor-name").click(ev => {

      // Get the actor which was clicked and the active token(s) for that actor
      let actorId = ev.currentTarget.parentElement.getAttribute("data-actor-id"),
          actor = game.actors.get(actorId),
          tokens = actor.getActiveTokens(true);

      // Highlight active token(s) by triggering the token's mouse-over handler
      for ( let t of tokens ) {

To render your party summary UI to the player, all that needs to be done is to create an instance of the application class and call it’s render function.

let ps = new PartySummary();