|
| 1 | +# Top area widget (cross compatible extension) |
| 2 | + |
| 3 | +This example defines an extension that adds a single self-contained text widget |
| 4 | +to the top bar of the UI. |
| 5 | + |
| 6 | + |
| 7 | + |
| 8 | +## Jupyter Notebook / JupyterLab compatibility |
| 9 | + |
| 10 | +As Jupyter Notebook 7+ is built with components from JupyterLab, and since |
| 11 | +both use the same building blocks, that means your extension can work |
| 12 | +on both (or any other frontend built with JupyterLab components) with |
| 13 | +little or no modification depending on its design. |
| 14 | + |
| 15 | +This extension doesn't need to do anything at all to be compatible |
| 16 | +with both JupyterLab and Notebook 7+ (both apps have a top area that can hold the |
| 17 | +widget, so it will be visible in both JupyterLab and Notebook 7+ upon install and |
| 18 | +after launch). This will be the case if your extension only uses features |
| 19 | +that both applications have. |
| 20 | + |
| 21 | +## Adding a widget to the top area |
| 22 | + |
| 23 | +You can add a widget to the top area by calling the following |
| 24 | +method of the application shell: |
| 25 | + |
| 26 | +```ts |
| 27 | +// src/index.ts#L34-L34 |
| 28 | + |
| 29 | +app.shell.add(widget, 'top', { rank: 1000 }); |
| 30 | +``` |
| 31 | + |
| 32 | +The _rank_ is used to order the widget within the top area. |
| 33 | + |
| 34 | +## Where to Go Next |
| 35 | + |
| 36 | +If your extension is using features that are not common to both interfaces, |
| 37 | +special steps needs to be taken. You can have a look at the [Shout button example](../shout-button-message) |
| 38 | +that uses a feature available in JupyterLab but not in Notebook 7+. |
| 39 | + |
| 40 | +You can have more information about this in the |
| 41 | +[Extension Dual Compatibility Guide](https://jupyterlab.readthedocs.io/en/latest/extension_dual_compatibility.html). |
0 commit comments