# jupyter-dark-detect
Detect dark mode in Jupyter environments (Notebook, Lab, VS Code, etc.).
## Installation
```bash
pip install jupyter-dark-detect
```
## Usage
```python
from jupyter_dark_detect import is_dark
# Check if Jupyter is running in dark mode
if is_dark():
print("Dark mode is enabled!")
# Use dark theme colors for visualizations
bg_color = "#1e1e1e"
text_color = "#d4d4d4"
else:
print("Light mode is enabled!")
# Use light theme colors for visualizations
bg_color = "#ffffff"
text_color = "#000000"
```
## Features
- **Multiple detection strategies** for maximum compatibility:
- JupyterLab theme settings files
- VS Code workspace and user settings
- JavaScript-based DOM inspection
- System preferences (macOS and Windows)
- **Zero configuration** - just import and use
- **Lightweight** with minimal dependencies (only requires IPython)
- **Cross-platform** support for JupyterLab, Jupyter Notebook, VS Code, and more
## How It Works
The package tries multiple detection methods in order:
1. **JupyterLab Settings**: Checks `~/.jupyter/lab/user-settings/` for theme configuration
2. **VS Code Settings**: When running in VS Code, checks both workspace and user settings
3. **JavaScript Detection**: Uses IPython magic to inspect the DOM for theme classes
4. **System Preferences**: Falls back to OS-level dark mode settings on macOS and Windows
## Use Cases
- **Matplotlib/Plotly Visualizations**: Automatically adjust plot colors based on theme
- **Rich Terminal Output**: Style console output to match the notebook theme
- **Custom Widgets**: Build theme-aware Jupyter widgets
- **Documentation**: Generate screenshots that match the user's theme
## Example: Matplotlib Integration
```python
import matplotlib.pyplot as plt
from jupyter_dark_detect import is_dark
# Set style based on theme
plt.style.use('dark_background' if is_dark() else 'default')
# Your plotting code
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
plt.title("Theme-Aware Plot")
plt.show()
```
## Example: Plotly Integration
```python
import plotly.graph_objects as go
from jupyter_dark_detect import is_dark
# Create theme-aware Plotly figure
fig = go.Figure()
fig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[1, 4, 9, 16]))
# Update layout based on theme
if is_dark():
fig.update_layout(
template="plotly_dark",
paper_bgcolor="#1e1e1e",
plot_bgcolor="#1e1e1e"
)
else:
fig.update_layout(
template="plotly_white",
paper_bgcolor="white",
plot_bgcolor="white"
)
fig.show()
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/jupyter-dark-detect",
"name": "jupyter-dark-detect",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "jupyter notebook jupyterlab dark-mode theme detection",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/72/5b/4e3fc83ffd16d502bf34a143f1c6453da0ffacf7d461e825c5926bbcaa09/jupyter_dark_detect-0.1.0.tar.gz",
"platform": null,
"description": "# jupyter-dark-detect\n\nDetect dark mode in Jupyter environments (Notebook, Lab, VS Code, etc.).\n\n## Installation\n\n```bash\npip install jupyter-dark-detect\n```\n\n## Usage\n\n```python\nfrom jupyter_dark_detect import is_dark\n\n# Check if Jupyter is running in dark mode\nif is_dark():\n print(\"Dark mode is enabled!\")\n # Use dark theme colors for visualizations\n bg_color = \"#1e1e1e\"\n text_color = \"#d4d4d4\"\nelse:\n print(\"Light mode is enabled!\")\n # Use light theme colors for visualizations\n bg_color = \"#ffffff\"\n text_color = \"#000000\"\n```\n\n## Features\n\n- **Multiple detection strategies** for maximum compatibility:\n - JupyterLab theme settings files\n - VS Code workspace and user settings\n - JavaScript-based DOM inspection\n - System preferences (macOS and Windows)\n \n- **Zero configuration** - just import and use\n\n- **Lightweight** with minimal dependencies (only requires IPython)\n\n- **Cross-platform** support for JupyterLab, Jupyter Notebook, VS Code, and more\n\n## How It Works\n\nThe package tries multiple detection methods in order:\n\n1. **JupyterLab Settings**: Checks `~/.jupyter/lab/user-settings/` for theme configuration\n2. **VS Code Settings**: When running in VS Code, checks both workspace and user settings\n3. **JavaScript Detection**: Uses IPython magic to inspect the DOM for theme classes\n4. **System Preferences**: Falls back to OS-level dark mode settings on macOS and Windows\n\n## Use Cases\n\n- **Matplotlib/Plotly Visualizations**: Automatically adjust plot colors based on theme\n- **Rich Terminal Output**: Style console output to match the notebook theme\n- **Custom Widgets**: Build theme-aware Jupyter widgets\n- **Documentation**: Generate screenshots that match the user's theme\n\n## Example: Matplotlib Integration\n\n```python\nimport matplotlib.pyplot as plt\nfrom jupyter_dark_detect import is_dark\n\n# Set style based on theme\nplt.style.use('dark_background' if is_dark() else 'default')\n\n# Your plotting code\nplt.plot([1, 2, 3, 4], [1, 4, 9, 16])\nplt.title(\"Theme-Aware Plot\")\nplt.show()\n```\n\n## Example: Plotly Integration\n\n```python\nimport plotly.graph_objects as go\nfrom jupyter_dark_detect import is_dark\n\n# Create theme-aware Plotly figure\nfig = go.Figure()\nfig.add_trace(go.Scatter(x=[1, 2, 3, 4], y=[1, 4, 9, 16]))\n\n# Update layout based on theme\nif is_dark():\n fig.update_layout(\n template=\"plotly_dark\",\n paper_bgcolor=\"#1e1e1e\",\n plot_bgcolor=\"#1e1e1e\"\n )\nelse:\n fig.update_layout(\n template=\"plotly_white\",\n paper_bgcolor=\"white\",\n plot_bgcolor=\"white\"\n )\n\nfig.show()\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Detect dark mode in Jupyter environments",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/yourusername/jupyter-dark-detect"
},
"split_keywords": [
"jupyter",
"notebook",
"jupyterlab",
"dark-mode",
"theme",
"detection"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "76c08cc378aad5ccfcc37adeda27d3864f20ea808ad5b63572f5b986a42a649c",
"md5": "dbfc6ea76931f1db726b15c81f7a6513",
"sha256": "198a7fa1270c6ce1ac2fd056cea9300e018bb8d04211de4c946cbe9e03e7a89d"
},
"downloads": -1,
"filename": "jupyter_dark_detect-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "dbfc6ea76931f1db726b15c81f7a6513",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7978,
"upload_time": "2025-07-27T16:20:12",
"upload_time_iso_8601": "2025-07-27T16:20:12.167968Z",
"url": "https://files.pythonhosted.org/packages/76/c0/8cc378aad5ccfcc37adeda27d3864f20ea808ad5b63572f5b986a42a649c/jupyter_dark_detect-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "725b4e3fc83ffd16d502bf34a143f1c6453da0ffacf7d461e825c5926bbcaa09",
"md5": "ed740202511810a43504b68b45146b4b",
"sha256": "b0358da684f1e36d0a869e839fa55dc1d9183cfc3ff228fe416d5132a7f36bcc"
},
"downloads": -1,
"filename": "jupyter_dark_detect-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ed740202511810a43504b68b45146b4b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7167,
"upload_time": "2025-07-27T16:20:13",
"upload_time_iso_8601": "2025-07-27T16:20:13.076940Z",
"url": "https://files.pythonhosted.org/packages/72/5b/4e3fc83ffd16d502bf34a143f1c6453da0ffacf7d461e825c5926bbcaa09/jupyter_dark_detect-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-27 16:20:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "jupyter-dark-detect",
"github_not_found": true,
"lcname": "jupyter-dark-detect"
}