@@ -792,9 +792,9 @@ verbatimTextOutput <- function(outputId, placeholder = FALSE) {
792
792
# ' @name plotOutput
793
793
# ' @rdname plotOutput
794
794
# ' @export
795
- imageOutput <- function (outputId , width = " 100%" , height = " 400px" ,
795
+ imageOutput <- function (outputId , width = " 100%" , height = " 400px" ,
796
796
click = NULL , dblclick = NULL , hover = NULL , brush = NULL ,
797
- inline = FALSE ) {
797
+ inline = FALSE , fill = TRUE ) {
798
798
799
799
style <- if (! inline ) {
800
800
# Using `css()` here instead of paste/sprintf so that NULL values will
@@ -850,7 +850,11 @@ imageOutput <- function(outputId, width = "100%", height="400px",
850
850
}
851
851
852
852
container <- if (inline ) span else div
853
- do.call(container , args )
853
+ res <- do.call(container , args )
854
+ if (fill ) {
855
+ res <- asFillItem(res )
856
+ }
857
+ res
854
858
}
855
859
856
860
# ' Create an plot or image output element
@@ -918,6 +922,10 @@ imageOutput <- function(outputId, width = "100%", height="400px",
918
922
# ' `imageOutput`/`plotOutput` calls may share the same `id`
919
923
# ' value; brushing one image or plot will cause any other brushes with the
920
924
# ' same `id` to disappear.
925
+ # ' @param fill whether or not the returned tag should be wrapped
926
+ # ' [htmltools::asFillItem()] so that it's `height` is allowed to grow/shrink
927
+ # ' inside a tag wrapped with [htmltools::asFillContainer()] (e.g.,
928
+ # ' [bslib::card_body_fill()]).
921
929
# ' @inheritParams textOutput
922
930
# ' @note The arguments `clickId` and `hoverId` only work for R base graphics
923
931
# ' (see the \pkg{\link[graphics:graphics-package]{graphics}} package). They do
@@ -1088,11 +1096,11 @@ imageOutput <- function(outputId, width = "100%", height="400px",
1088
1096
# ' @export
1089
1097
plotOutput <- function (outputId , width = " 100%" , height = " 400px" ,
1090
1098
click = NULL , dblclick = NULL , hover = NULL , brush = NULL ,
1091
- inline = FALSE ) {
1099
+ inline = FALSE , fill = TRUE ) {
1092
1100
1093
1101
# Result is the same as imageOutput, except for HTML class
1094
1102
res <- imageOutput(outputId , width , height , click , dblclick ,
1095
- hover , brush , inline )
1103
+ hover , brush , inline , fill )
1096
1104
1097
1105
res $ attribs $ class <- " shiny-plot-output"
1098
1106
res
@@ -1144,6 +1152,11 @@ dataTableOutput <- function(outputId) {
1144
1152
# ' @param outputId output variable to read the value from
1145
1153
# ' @param ... Other arguments to pass to the container tag function. This is
1146
1154
# ' useful for providing additional classes for the tag.
1155
+ # ' @param fill whether or not the returned `container` should be wrapped in
1156
+ # ' [htmltools::asFillContainer()] and [htmltools::asFillItem()]. This has the
1157
+ # ' benefit of allowing `uiOutput()`'s children to stretch to `uiOutput()`'s
1158
+ # ' container, but has the downside of changing the `display` context of
1159
+ # ' `uiOutput()`'s children to be flex items.
1147
1160
# ' @inheritParams textOutput
1148
1161
# ' @return An HTML output element that can be included in a panel
1149
1162
# ' @examples
@@ -1155,12 +1168,16 @@ dataTableOutput <- function(outputId) {
1155
1168
# ' )
1156
1169
# ' @export
1157
1170
htmlOutput <- function (outputId , inline = FALSE ,
1158
- container = if (inline ) span else div , ... )
1171
+ container = if (inline ) span else div , fill = FALSE , ... )
1159
1172
{
1160
1173
if (any_unnamed(list (... ))) {
1161
1174
warning(" Unnamed elements in ... will be replaced with dynamic UI." )
1162
1175
}
1163
- container(id = outputId , class = " shiny-html-output" , ... )
1176
+ res <- container(id = outputId , class = " shiny-html-output" , ... )
1177
+ if (fill ) {
1178
+ res <- asFillContainer(res , asItem = TRUE )
1179
+ }
1180
+ res
1164
1181
}
1165
1182
1166
1183
# ' @rdname htmlOutput
0 commit comments