diff --git a/NAMESPACE b/NAMESPACE index a385c84..d82ac60 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(htmlFixBoxCollapseButtonAria) export(htmlMarkOptional) export(htmlMarkRequired) export(htmlRemoveAttributes) +export(htmlRemoveBoxTitle) export(htmlReplaceBoxTitleLevel) export(htmlSetMaxLength) export(htmlSetMinLength) diff --git a/R/htmlBoxManipulation.R b/R/htmlBoxManipulation.R index 535b81f..7df58b8 100644 --- a/R/htmlBoxManipulation.R +++ b/R/htmlBoxManipulation.R @@ -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() + } +} diff --git a/man/htmlRemoveBoxTitle.Rd b/man/htmlRemoveBoxTitle.Rd new file mode 100644 index 0000000..c2e5a58 --- /dev/null +++ b/man/htmlRemoveBoxTitle.Rd @@ -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) +}