PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, November 9, 2022

[FIXED] How to align text using shiny html?

 November 09, 2022     css, html, popover, r, shiny     No comments   

Issue

In the code at the bottom, I successfully justify-align the bullet-point text in the popover when hovering over the information circle. However, I still can't figure out how to justify-align its header immediately above as shown in this image. If I remove the ul from the line tags$style('.popover ul {padding: 15px; text-align: justify;}'), everthing is justified but I lose all other desired formatting. How would I modify this code so I can cleanly justify that header paragraph too?

enter image description here

Code:

library(shiny)
library(shinyBS)

ui <- fluidPage(
  tags$style('.popover ul {padding: 15px; text-align: justify;}'),
  br(),
  uiOutput("uiExample")
)
    
server <- function(input, output, session) {
  output$uiExample <- renderUI({
    tagList(
      tags$span("Little circle >>"),
      tags$span(
        popify(
          icon("info-circle", verify_fa = FALSE),
          "Placeholder",
          paste(
           "Here is an excerpt from a famous poem Still I Rise:",
           "<ul>",
             "<li>You may write me down in history With your bitter, twisted lies,</li>",
             "<li>You may tread me in the very dirt. But still, like dust, I will rise.",
             "Does my sassiness upset you...</li>",
           "</ul>"
           )
        )
      )  
    )
  })
}

shinyApp(ui, server)

Solution

You can add this to your CSS:

'.popover-content {text-align: justify;}'
library(shiny)
library(shinyBS)

ui <- fluidPage(
  tags$style('.popover ul {padding: 15px; text-align: justify;}',
             '.popover-content {text-align: justify;}'),
  br(),
  uiOutput("uiExample")
)

server <- function(input, output, session) {
  output$uiExample <- renderUI({
    tagList(
      tags$span("Little circle >>"),
      tags$span(
        popify(
          icon("info-circle", verify_fa = FALSE),
          "Placeholder",
          paste(
            "Here is an excerpt from a famous poem Still I Rise:",
            "<ul>",
            "<li>You may write me down in history With your bitter, twisted lies,</li>",
            "<li>You may tread me in the very dirt. But still, like dust, I will rise.",
            "Does my sassiness upset you...</li>",
            "</ul>"
          )
        )
      )  
    )
  })
}

shinyApp(ui, server)


Answered By - TimTeaFan
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing