Added method for removing the title from a shinydashboard::box

This commit is contained in:
2026-01-26 13:45:26 +00:00
parent 392c545b8d
commit c1c81c597e
3 changed files with 43 additions and 0 deletions

View File

@@ -8,6 +8,7 @@ export(htmlFixBoxCollapseButtonAria)
export(htmlMarkOptional) export(htmlMarkOptional)
export(htmlMarkRequired) export(htmlMarkRequired)
export(htmlRemoveAttributes) export(htmlRemoveAttributes)
export(htmlRemoveBoxTitle)
export(htmlReplaceBoxTitleLevel) export(htmlReplaceBoxTitleLevel)
export(htmlSetMaxLength) export(htmlSetMaxLength)
export(htmlSetMinLength) export(htmlSetMinLength)

View File

@@ -153,3 +153,22 @@ htmlAddBoxHelpLink <- function(box, href, title = NULL) {
) )
) )
} }
#' Removes title from box element (leaving an un-titled box with header if required)
#'
#' @param box The box to remove the title from
#' @param removeHeader Remove the header as well
#'
#' @return The modified box
#' @export
#'
#' @examples
#' x <- shinydashboard::box(title = "TBR")
#' htmlRemoveBoxTitle(x)
htmlRemoveBoxTitle <- function(box, removeHeader = FALSE) {
if (removeHeader) {
htmltools::tagQuery(box)$find(".box-header")$remove()$allTags()
} else {
htmltools::tagQuery(box)$find(".box-title")$remove()$allTags()
}
}

23
man/htmlRemoveBoxTitle.Rd Normal file
View File

@@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/htmlBoxManipulation.R
\name{htmlRemoveBoxTitle}
\alias{htmlRemoveBoxTitle}
\title{Removes title from box element (leaving an un-titled box with header if required)}
\usage{
htmlRemoveBoxTitle(box, removeHeader = FALSE)
}
\arguments{
\item{box}{The box to remove the title from}
\item{removeHeader}{Remove the header as well}
}
\value{
The modified box
}
\description{
Removes title from box element (leaving an un-titled box with header if required)
}
\examples{
x <- shinydashboard::box(title = "TBR")
htmlRemoveBoxTitle(x)
}