Files
shiny/reference/fillRow.html
2025-06-25 22:08:12 +00:00

161 lines
13 KiB
HTML

<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Flex Box-based row/column layouts — fillRow • shiny</title><!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous"><script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"><script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"><!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"><script src="../pkgdown.js"></script><meta property="og:title" content="Flex Box-based row/column layouts — fillRow"><meta property="og:description" content="Creates row and column layouts with proportionally-sized cells, using the
Flex Box layout model of CSS3. These can be nested to create arbitrary
proportional-grid layouts. Warning: Flex Box is not well supported
by Internet Explorer, so these functions should only be used where modern
browsers can be assumed."><meta property="og:image" content="/logo.png"><!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]--></head><body data-spy="scroll" data-target="#toc">
<div class="container template-reference-topic">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">shiny</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">1.11.0.9000</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav"><li>
<a href="../reference/index.html">Reference</a>
</li>
<li>
<a href="../news/index.html">Changelog</a>
</li>
</ul><ul class="nav navbar-nav navbar-right"><li>
<a href="https://github.com/rstudio/shiny/" class="external-link">
<span class="fab fa-github fa-lg"></span>
</a>
</li>
</ul></div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header><div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Flex Box-based row/column layouts</h1>
<small class="dont-index">Source: <a href="https://github.com/rstudio/shiny/blob/main/R/bootstrap-layout.R" class="external-link"><code>R/bootstrap-layout.R</code></a></small>
<div class="hidden name"><code>fillRow.Rd</code></div>
</div>
<div class="ref-description">
<p>Creates row and column layouts with proportionally-sized cells, using the
Flex Box layout model of CSS3. These can be nested to create arbitrary
proportional-grid layouts. <strong>Warning:</strong> Flex Box is not well supported
by Internet Explorer, so these functions should only be used where modern
browsers can be assumed.</p>
</div>
<div id="ref-usage">
<div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">fillRow</span><span class="op">(</span><span class="va">...</span>, flex <span class="op">=</span> <span class="fl">1</span>, width <span class="op">=</span> <span class="st">"100%"</span>, height <span class="op">=</span> <span class="st">"100%"</span><span class="op">)</span></span>
<span></span>
<span><span class="fu">fillCol</span><span class="op">(</span><span class="va">...</span>, flex <span class="op">=</span> <span class="fl">1</span>, width <span class="op">=</span> <span class="st">"100%"</span>, height <span class="op">=</span> <span class="st">"100%"</span><span class="op">)</span></span></code></pre></div>
</div>
<div id="arguments">
<h2>Arguments</h2>
<dl><dt id="arg--">...<a class="anchor" aria-label="anchor" href="#arg--"></a></dt>
<dd><p>UI objects to put in each row/column cell; each argument will
occupy a single cell. (To put multiple items in a single cell, you can use
<code><a href="https://rstudio.github.io/htmltools/reference/tagList.html" class="external-link">tagList()</a></code> or <code><a href="https://rstudio.github.io/htmltools/reference/builder.html" class="external-link">div()</a></code> to combine them.) Named
arguments will be used as attributes on the <code>div</code> element that
encapsulates the row/column.</p></dd>
<dt id="arg-flex">flex<a class="anchor" aria-label="anchor" href="#arg-flex"></a></dt>
<dd><p>Determines how space should be distributed to the cells. Can be a
single value like <code>1</code> or <code>2</code> to evenly distribute the available
space; or use a vector of numbers to specify the proportions. For example,
<code>flex = c(2, 3)</code> would cause the space to be split 40%/60% between
two cells. NA values will cause the corresponding cell to be sized
according to its contents (without growing or shrinking).</p></dd>
<dt id="arg-width-height">width, height<a class="anchor" aria-label="anchor" href="#arg-width-height"></a></dt>
<dd><p>The total amount of width and height to use for the
entire row/column. For the default height of <code>"100%"</code> to be
effective, the parent must be <code>fillPage</code>, another
<code>fillRow</code>/<code>fillCol</code>, or some other HTML element whose height is
not determined by the height of its contents.</p></dd>
</dl></div>
<div id="details">
<h2>Details</h2>
<p>If you try to use <code>fillRow</code> and <code>fillCol</code> inside of other
Shiny containers, such as <code><a href="sidebarLayout.html">sidebarLayout()</a></code>,
<code><a href="navbarPage.html">navbarPage()</a></code>, or even <code>tags$div</code>, you will probably find
that they will not appear. This is due to <code>fillRow</code> and <code>fillCol</code>
defaulting to <code>height="100%"</code>, which will only work inside of
containers that have determined their own size (rather than shrinking to
the size of their contents, as is usually the case in HTML).</p>
<p>To avoid this problem, you have two options:</p><ul><li><p>only use <code>fillRow</code>/<code>fillCol</code> inside of <code>fillPage</code>,
<code>fillRow</code>, or <code>fillCol</code></p></li>
<li><p>provide an explicit <code>height</code> argument to
<code>fillRow</code>/<code>fillCol</code></p></li>
</ul></div>
<div id="ref-examples">
<h2>Examples</h2>
<div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span><span class="co"># Only run this example in interactive R sessions.</span></span></span>
<span class="r-in"><span><span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/interactive.html" class="external-link">interactive</a></span><span class="op">(</span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">ui</span> <span class="op">&lt;-</span> <span class="fu"><a href="fillPage.html">fillPage</a></span><span class="op">(</span><span class="fu">fillRow</span><span class="op">(</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="plotOutput.html">plotOutput</a></span><span class="op">(</span><span class="st">"plotLeft"</span>, height <span class="op">=</span> <span class="st">"100%"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span> <span class="fu">fillCol</span><span class="op">(</span></span></span>
<span class="r-in"><span> <span class="fu"><a href="plotOutput.html">plotOutput</a></span><span class="op">(</span><span class="st">"plotTopRight"</span>, height <span class="op">=</span> <span class="st">"100%"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span> <span class="fu"><a href="plotOutput.html">plotOutput</a></span><span class="op">(</span><span class="st">"plotBottomRight"</span>, height <span class="op">=</span> <span class="st">"100%"</span><span class="op">)</span></span></span>
<span class="r-in"><span> <span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="va">server</span> <span class="op">&lt;-</span> <span class="kw">function</span><span class="op">(</span><span class="va">input</span>, <span class="va">output</span>, <span class="va">session</span><span class="op">)</span> <span class="op">{</span></span></span>
<span class="r-in"><span> <span class="va">output</span><span class="op">$</span><span class="va">plotLeft</span> <span class="op">&lt;-</span> <span class="fu"><a href="renderPlot.html">renderPlot</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">cars</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span> <span class="va">output</span><span class="op">$</span><span class="va">plotTopRight</span> <span class="op">&lt;-</span> <span class="fu"><a href="renderPlot.html">renderPlot</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">pressure</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span> <span class="va">output</span><span class="op">$</span><span class="va">plotBottomRight</span> <span class="op">&lt;-</span> <span class="fu"><a href="renderPlot.html">renderPlot</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/graphics/plot.default.html" class="external-link">plot</a></span><span class="op">(</span><span class="va">AirPassengers</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="fu"><a href="shinyApp.html">shinyApp</a></span><span class="op">(</span><span class="va">ui</span>, <span class="va">server</span><span class="op">)</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
</code></pre></div>
</div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
<nav id="toc" data-toggle="toc" class="sticky-top"><h2 data-toc-skip>Contents</h2>
</nav></div>
</div>
<footer><div class="copyright">
<p></p><p>Developed by Winston Chang, Joe Cheng, JJ Allaire, Carson Sievert, Barret Schloerke, Yihui Xie, Jeff Allen, Jonathan McPherson, Alan Dipert, Barbara Borges, Posit Software, PBC.</p>
</div>
<div class="pkgdown">
<p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.1.3.</p>
</div>
</footer></div>
</body></html>