How to edit jupyter lab theme

2020-03-01 17:27发布

As described in a previous question, it is now possible to edit the Jupyter Lab theme. However, this theme has a few issues for me personally. For example, it makes plot axes hard to read, since their default color is black. Other users have had similar problems. Consequently, I would like to fork the existing theme and make plot display cells a light grey colour. How does one do this?

I tried to find the corresponding .css file, but all I could find was /usr/local/share/jupyter/lab/themes/@jupyterlab/theme-dark-extension/. I understand that I could edit the index.css to achieve what I want, but how do I instead fork that theme and edit it? How do I let Jupyter Lab know about my custom theme?

3条回答
等我变得足够好
2楼-- · 2020-03-01 18:05

we are using version 0.35.x ... the following steps worked for me ... it will create a clone of the light theme, would install it in jupyter lab and you would be able to select that from settings menu. you can customize this theme, build it and have the effect in jupyter lab

  • install miniconda from here https://docs.conda.io/en/latest/miniconda.html (chose python3.7 one)
  • open Anaconda Terminal, [in windows goto search type Anaconda, select the terminal]
  • then run this conda create -n jupyterlab-ext -c conda-forge --override-channels nodejs jupyterlab cookiecutter git
  • clone jupyterlab from here https://github.com/jupyterlab/jupyterlab.git
  • switch branch with git checkout 0.35.x
  • then jlpm install jlpm build npm run create:theme
  • copy the theme folder to your chosen local theme folder for extension development. Replace tsconfig.json content with the following

{ "compilerOptions": { "declaration": true, "lib": ["es2015", "dom"], "module": "commonjs", "moduleResolution": "node", "noEmitOnError": true, "noUnusedLocals": true, "outDir": "lib", "rootDir": "src", "strict": true, "strictNullChecks": false, "target": "es2015", "types": [] }, "include": ["src/*"] } [created by the steps here https://jupyterlab.readthedocs.io/en/stable/developer/xkcd_extension_tutorial.html#xkcd-extension-tutorial]

inside the theme folder ..

  • run the following commands jlpm install, jlpm run build , jlpm run build:webpack
  • open another conda terminal, there go to repo folder and run conda activate jupyterlab-ext then jupyter labextension install .
  • in a conda terminal conda activate jupyterlab-ext then, jupyter lab --watch

For version 1.0 , this cookie cutter could be used ... https://github.com/jupyterlab/theme-cookiecutter

查看更多
ら.Afraid
3楼-- · 2020-03-01 18:08

To expand on the answer from @Payam Khaninejad once you've forked the Jupyter Lab project you need to find the variables.css file and make your desired edits.

Then you can join the current (as of posting) issue on Github https://github.com/jupyterlab/jupyterlab/issues/3855 and get help to format your pull request to conform to the style used by the Jupyter Lab project. Info on contributing to the project here.


Here's a reply I wrote another question detailing the steps to make changes to the Jupyter Lab interface:

To edit Jupypter Lab themes you need to make changes to the file variables.css which is located in jupyterlab/packages/[THEME NAME]/style/

You can inspect the element of the Jupyter Lab that you'd like to change to find out its class. I used Chrome DevTools ctrl+shift+i and click on various div classes until I found the one I wanted to alter.

Once you have the name of the div class you'd like to customize, add the changes to the variables.css file. Here's what I changed and the result.

.jp-RenderedImage {
  background-color: #A4A4A4
}

Change background of figures to grey to allow axis to be read

You can use this gist (where the code in the first cell comes from) created by one of the JupyterLab contributors to experiment with changes you made to the variables.css file.

查看更多
Animai°情兽
4楼-- · 2020-03-01 18:27
  • First fork the Jupyter Lab project, then edit and commit your changes.

  • Second, go to Jupyter Lab project and ask pull request.

  • if they like your project they will accept and put your changes on their master branch

查看更多
登录 后发表回答