Skip to content

Highlights

Christopher Wood edited this page Dec 27, 2024 · 4 revisions

Highlights are done via the hl-* ncss properties that can be applied to elements.

For example, if you want to make all div's red background, then use the following style rule:

div {
  hl-bg: red;
}

The property names given are passed directly to nvim_set_hl, so you can check :help nvim_set_hl to use those highlights.

hl-__name

There is one additional property that can be added: hl-__name. This allows highlights groups to be named, and overriden by the user.

div {
  hl-bg: red;
  hl-__name: Override;
}

This will set all divs background to be red unless this is called somewhere in lua:

vim.api.nvim_set_hl(0, "Override", {
  bg = "blue"
})

gradients

Currently, linear and radial gradients are supported. Unlike in html, gradients can be applied both as a background and foreground value

For linear-gradient every parameter possibility except for color space input are supported. The mdn documentation should clarify any questions

For radial-gradient, the shape, size, and position parameters are not supported currently. See mdn docs for more help.

Banana also does not support passing multiple gradients to one color field

div {
  /* This is not allowed */
  hl-bg: linear-gradient(45deg, orange, blue)
    linear-gradient(90deg, white, black);
}
<nml>
  <head>
    <style>
    div {
      width: 40ch;
      height: 20ch;
      hl-bg: linear-gradient(45deg, orange, blue);
    }
    </style>
  </head>
  <body>
  <div> gradient </div>
  </body>
</nml>

the above code looks like:

gradient

Clone this wiki locally