Xterm.js: How to set background color on terminal

Created on 1 Oct 2018  路  4Comments  路  Source: xtermjs/xterm.js

I set the background terminal color with

term._core.renderer.colorManager.colors.background = {
  css: "#fdf6e3",
  rgba: "rgb(253, 246, 227)",
}

Just wanted to share my solution and immediately close this in case anyone else was having the same problem

Most helpful comment

I would blame our docs, they are not really helpful in explaining the options available 馃槄

All 4 comments

Also, I don't think gitter is a viable solution, because other people can't learn from that

This is not really the recommended way of defining the colors 馃榾You can pass a theme object with colors in the Terminal constructor options, e.g.:

const term = new Terminal({
  theme: {
    background: '#fdf6e3'
  }
});

You can also update the theme colors at runtime:

term.setOption('theme', {
    background: '#fdf6e3'
});

Note 1: If you don't define a theme value, we will use the default fallback value for it.
Note 2: If you want a transparent background, you also have to specify the allowTransparency option.

For a list of available theme colors, check this out:
https://xtermjs.org/docs/api/terminal/interfaces/itheme/

Well, don't I feel silly

I would blame our docs, they are not really helpful in explaining the options available 馃槄

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tyriar picture Tyriar  路  4Comments

zhangjie2012 picture zhangjie2012  路  3Comments

LB-J picture LB-J  路  3Comments

Tyriar picture Tyriar  路  4Comments

kolbe picture kolbe  路  3Comments