A Python package for generating interactive HTML snippets optimized for Jupyter notebooks and web applications.
- Interactive Tables: Sortable, searchable tables with color-coded data and fancy headers
- Image Processing: Convert PIL images to HTML with thumbnails, scaling, and base64 encoding
- Image Overlays: Create animated overlays with fade effects, hover interactions, and frame sequences
- CSS/JS Animations: Frame-by-frame animations using pure CSS or JavaScript
- Toggle Controls: Interactive visibility toggles with checkboxes and labels
- Volume Visualization: Multiplanar 3D volume viewer with RGB channel controls
- Layout Utilities: Horizontal layout containers and flexible UI components
See example.ipynb for detailed usage examples.
git clone https://github.com/aaichert/html_snippets.git
cd html_snippets
pip install -e .pip install html_snippetspip install html_snippets[jupyter]from html_snippets import html_table, html_image, html_animation_css
from PIL import Image
import numpy as np
# Create an HTML table
data = [{'name': 'Item 1', 'value': 42}, {'name': 'Item 2', 'value': 37}]
head, body, tail = html_table(data)
# Convert PIL image to HTML
image = Image.open('example.jpg')
html_img = html_image(image)
# Create frame-by-frame animation
frames = ['<div>Frame 1</div>', '<div>Frame 2</div>']
css, html_anim = html_animation_css(frames, frame_duration_sec=1.0)
# Create 3D volume viewer (requires numpy)
volume = np.random.randint(0, 255, (50, 100, 100, 3), dtype=np.uint8) # DHWC format
multiplanar_html = html_multiplanar(volume)Licensed under Apache 2.0.
