## Building Outputs Similar to custom inputs, if you have some knowledge of HTML/CSS/JavaScript you can also build reusable, custom *output* components. Output values are received from the server and are directed to an *output binding*, which then ### Write an Output Binding Each custom output component needs an *output binding*, an object you create that tells Shiny how to identify instances of your component and how to interact with them. (Note that each *instance* of the output component doesn't need its own output binding object; rather, all instances of a particular type of output component share a single output binding object.) An output binding object needs to have the following methods:
find(scope)
Given an HTML document or element (scope), find any descendant elements that are an instance of your component and return them as an array (or array-like object). The other output binding methods all take an el argument; that value will always be an element that was returned from find.
A very common implementation is to use jQuery's find method to identify elements with a specific class, for example:
exampleOutputBinding.find = function(scope) {
return $(scope).find(".exampleComponentClass");
};
getId(el)
el, or null if the element doesn't have an ID and should therefore be ignored. The default implementation in Shiny.InputBinding reads the data-output-id attribute and falls back to the element's id if not present.
renderValue(el, data)
renderError(el, err)
err is an object with a message String property.
clearError(el)
el is currently displaying an error, clear it.
showProgress(el, show)
Shiny.outputBindings.register(exampleOutputBinding, "yourname.exampleOutputBinding");
The second argument is a name the user can use to change the priority of the binding. On the off chance that the user has multiple bindings that all want to claim the same HTML element as their own, this call can be used to control the priority of the bindings:
Shiny.outputBindings.setPriority("yourname.exampleOutputBinding", 10);
Higher numbers indicate a higher priority; the default priority is 0. All of Shiny's built-in input component bindings default to a priority of 0.
If two bindings have the same priority value, then the more recently registered binding has the higher priority.
### Example