Skip to contents

The styles argument is function that returns a character vector or list that defines the styles for the component. Styles are scoped to the component.

Details

The styles argument takes a character vector of length 1 that defines the styles for the component. For example:

styles = function() {
"a { color: red; }"
}

This would define the CSS styles for the anchor elements (<a>) in the component, setting their color to red.

Scoped Styles

Styles defined in a component are scoped to the component, meaning they will only apply to elements within that component.

To style the top-level node of the component, we can apply the styles without specifying a tag:

x <- component(
 name = "scoped_styles",
 template = function(ns) {
     shiny::div(
      "Hello world!"
     )
 },
 styles = function() {
    "color: red"
  }
)