Description Usage Arguments See Also Examples
Use the margin()
and padding()
utilities to change the margin or padding
of a tag element. The margin of a tag element is the space outside and
around the tag element, its border, and its content. The padding of a tag
element is the space between the tag element's border and its content or
child elements. All arguments default to NULL
, in which case they are
ignored.
1 2 3 |
tag |
A tag element. |
all, top, right, bottom, left |
A responsive argument. For padding(), one of For margin(), one of |
Other design utilities:
active()
,
affix()
,
background()
,
border()
,
display()
,
float()
,
font()
,
height()
,
scroll()
,
shadow()
,
width()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | ### Centering an element
# In most modern browsers you want to horizontally center a tag element using
# the flex layout. Alternatively, you can horizontally center an element
# using `margin(.., right = "auto", left = "auto")`.
div(
"Nam a sapien. Integer placerat tristique nisl.",
style = "height: 100px; width: 200px;"
) %>%
margin(top = 2, r = "auto", b = 2, l = "auto") %>% # <-
padding(3) %>%
background("indigo")
### Building an inline form
# Inline form elements automatically use the flex layout providing you a
# means of creating condensed sets of inputs. However, you may need to adjust
# the spacing of the form's child elements.
# Here is an inline form without any additional spacing applied.
formInput(
id = "form1",
inline = TRUE,
textInput(
id = "name",
placeholder = "Full name"
),
groupTextInput(
id = "username",
left = "@",
placeholder = "Username"
),
checkboxInput(
id = "remember",
choice = "Remember me"
),
formSubmit("Login", "login")
)
# Without any adjustments the layout is not great. But, with some styling we
# can make this form sparkle. Notice we are also adjusting the default submit
# button added to the form input.
formInput(
id = "form2",
inline = TRUE,
textInput(
id = "name",
placeholder = "Full name"
) %>%
margin(r = c(sm = 2), b = 2), # <-
groupTextInput(
id = "username",
left = "@",
placeholder = "Username"
) %>%
margin(r = c(sm = 2), b = 2), # <-
checkboxInput(
id = "remember",
choice = "Remember me"
) %>%
margin(r = c(sm = 2), b = 2), # <-
formSubmit(
label = "Login",
value = "login"
) %>%
margin(b = 2) # <-
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.