更改Shiny App中文字的颜色和字体 [英] Change the color and font of text in Shiny App
问题描述
我使用 server.R
中的以下代码在主面板中显示文本。
输出$ text1< - renderText({
if(input $ ag == 0)return(NULL)
return('请求AG的前20行')
})
有什么方法可以改变文字的字体和颜色吗?
可以使用css作为@jbaums表示
$ p $ library $ $ $ $ $ $ $ $ runApp(list(
ui = bootstrapPage (
numericInput('n','Number of obs',100),
textOutput('text1'),
tags $ head(tags $ style(#text1 {color:red ;
font-size:20px;
font-style:italic;
}
)
)
),
server = function (input,output){
output $ text1< - renderText({paste(hello input is,input $ n)})
}
))
的DOM元素,大括号的内容是相关的样式。 / p>
<通常情况下,你可以在 styles.css
文件中包含这个文件,但是这里显示的内容是自包含的。 #text1
引用
I am using below code in server.R
to display the text in the main panel. This is working exactly the way it should work.
output$text1 <- renderText({
if(input$ag == 0) return(NULL)
return('First 20 rows for requested AG')
})
Is there any way to change the font and color of the text?
You can use css as @jbaums indicated
library(shiny)
runApp(list(
ui = bootstrapPage(
numericInput('n', 'Number of obs', 100),
textOutput('text1'),
tags$head(tags$style("#text1{color: red;
font-size: 20px;
font-style: italic;
}"
)
)
),
server = function(input, output) {
output$text1 <- renderText({ paste("hello input is",input$n) })
}
))
Normally you would include this in a styles.css
file but it is shown inline here to be self contained. #text1
refers to the DOM element with id=text1
and the contents of the curly brackets are the relevant styles.
这篇关于更改Shiny App中文字的颜色和字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!