The component props
OptionalclassName?: stringOptional CSS class name to apply to the img element
OptionaldebounceMs?: numberOptional debounce delay in milliseconds for dimension change detection (default: 400ms). Controls how long to wait after a resize event before sending updated dimensions to Shiny. Higher values reduce server load but may delay updates.
Optionalheight?: stringOptional height as a CSS size string (e.g., "200px", "50vh", "auto"). If provided, sets the height attribute on the img tag. If not provided, the height should be controlled via CSS applied to this element.
The Shiny output ID that corresponds to a renderImage() call on the server
Optionalnamespace?: string | nullOptional namespace override for Shiny module
support. If provided, overrides the namespace from ShinyModuleProvider
context. Pass null to explicitly disable namespacing even when inside
a provider.
OptionalonRecalculating?: (isRecalculating: boolean) => voidOptional callback function that gets called whenever the recalculation status changes. Receives a boolean indicating whether the image is currently recalculating.
Optionalwidth?: stringOptional width as a CSS size string (e.g., "300px", "50%", "auto"). If provided, sets the width attribute on the img tag. If not provided, the width should be controlled via CSS applied to this element.
The component automatically:
The server-side renderImage() function receives the client dimensions and can use them to generate appropriately sized images.
Note that if you use two ImageOutputs with the same ID, the server will generate only one image at the width and height for one of them; both ImageOutputs will receive the same image data. but it will only be sized for one of the ImageOutputs.
// With explicit dimensions
<ImageOutput id="myplot" width="100%" height="300px" />
// With CSS-controlled dimensions
<ImageOutput id="myplot" className="output-image" />
A React component for displaying Shiny image outputs with dynamic sizing capabilities.
Unlike typical web images that have an inherent size, this component tells the server to generate an image that is sized to fit the dimensions of the
element which is rendered by the component. This means that the element
must have a width and height, either through CSS or through the width and
height props.
For vertical stretching, you can use height: "100%" inside a flex container, or use viewport units like "100vh" for full height