更改Shiny App中文字的颜色和字体 [英] Change the color and font of text in Shiny App

查看:1425
本文介绍了更改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)})
}
))



<通常情况下,你可以在 styles.css 文件中包含这个文件,但是这里显示的内容是自包含的。 #text1 引用 id = text1
的DOM元素,大括号的内容是相关的样式。 / p>

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆