custom styles

Inline custom styles

Define styles in the cell option and apply them by name. No preset needed.

```{r}
#| code-line-style:
#|   styles:
#|     warn:  { bg: "#fff3bf", gutter: "#f08c00", marker: "!" }
#|     ghost: { opacity: 0.35 }
#|   steps:
#|     - warn: 3
#|     - ghost: 1-2
```
mtcars |>
  dplyr::filter(cyl == 6) |>
  dplyr::group_by(gear) |>
  dplyr::summarise(m = mean(mpg)) |>
  dplyr::arrange(dplyr::desc(m))

Composing styles

A line can be targeted by multiple styles in the same step. Non-conflicting properties stack; conflicting properties use spec order — later wins.

```{r}
#| code-line-style:
#|   styles:
#|     bold-line: { weight: bold }
#|   steps:
#|     - hi: 3
#|       bold-line: 3
```
mtcars |>
  dplyr::filter(cyl == 6) |>
  dplyr::group_by(gear) |>
  dplyr::summarise(m = mean(mpg)) |>
  dplyr::arrange(dplyr::desc(m))

Text color instead of background

fg recolors the whole line — including syntax-highlighted tokens, which are otherwise immune to a line-level color setting.

```{r}
#| code-line-style:
#|   styles:
#|     added:   { fg: "#2ea043" }
#|     removed: { fg: "#f85149" }
#|     muted:   { fg: "#888" }
#|   steps:
#|     - added: 3
#|       muted: [1-2, 4-5]
#|     - removed: 5
#|       muted: [1-4]
```
mtcars |>
  dplyr::filter(cyl == 6) |>
  dplyr::group_by(gear) |>
  dplyr::summarise(m = mean(mpg)) |>
  dplyr::arrange(dplyr::desc(m))

Text color, without muting

Same idea, but only the added / removed lines are touched — the rest stay at the editor’s default colors.

```{r}
#| code-line-style:
#|   styles:
#|     added:   { fg: "#2ea043" }
#|     removed: { fg: "#f85149" }
#|   steps:
#|     - added: 3
#|     - removed: 5
```
mtcars |>
  dplyr::filter(cyl == 6) |>
  dplyr::group_by(gear) |>
  dplyr::summarise(m = mean(mpg)) |>
  dplyr::arrange(dplyr::desc(m))

Dev-mode errors

Append ?cls-debug=1 to the page URL to see inline error banners for unknown style names, bad ranges, or malformed specs. In production, errors only log to the console.