多行文本输入闪亮

编程入门 行业动态 更新时间:2024-10-08 18:32:31
本文介绍了多行文本输入闪亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在多行/换行(透明显示或仅软包装以在UI中获得更好的输出)的文本输入中,我有哪些选择可以实现?

我想实现一个具有描述/详细信息字段的应用程序,所输入的内容很可能不仅仅是一行.

基本上,我正在寻找实现Stackoverflow文本输入框类似功能的东西,我在用以下方法编写此问题:换行符,滚动条和/或(自动)调整高度.

示例

# UI --------------------------------------------------------------------- ui <- fluidPage( p(), textInput("title", "Title"), textInput("description", "Description"), tags$hr(), h3("Database state"), DT::dataTableOutput("datatable") ) # Server ------------------------------------------------------------------ server <- function(input, output, session) { output$datatable <- DT::renderDataTable( data.frame( Title = input$title, Description = input$description, stringsAsFactors = FALSE ) ) } shinyApp(ui, server)

解决方案

尝试使用textAreaInput而不是textInput. 使用前者,您可以设置高度和宽度,如果行太长,它将自动换行到下一行.

此处是在文档中提到的地方. >

What are my options to realize text inputs with multiple lines/line breaks (either explicit or just soft-wraps for nicer output in the UI) in shiny?

I'd like to implement an app that has a description/details field and the content being entered will most likely be more than just one line.

Basically, I'm looking for something to realize a similar functionality of the very text input box of stackoverflow I'm writing this question in: line breaks, scroll bar and/or (auto-)adjustment of height.

Example

# UI --------------------------------------------------------------------- ui <- fluidPage( p(), textInput("title", "Title"), textInput("description", "Description"), tags$hr(), h3("Database state"), DT::dataTableOutput("datatable") ) # Server ------------------------------------------------------------------ server <- function(input, output, session) { output$datatable <- DT::renderDataTable( data.frame( Title = input$title, Description = input$description, stringsAsFactors = FALSE ) ) } shinyApp(ui, server)

解决方案

Try using textAreaInput instead of textInput. With the former you can set height and width, and it automatically will wrap to next line if line is too long.

Here is where it is mentioned in the docs.

更多推荐

多行文本输入闪亮

本文发布于:2023-11-23 00:54:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619531.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!