sparklinekit/theme

Named colour schemes for the SVG and PNG renderers.

import sparklinekit/line
import sparklinekit/theme

pub fn ocean_chart() -> String {
  line.new([1.0, 5.0, 3.0, 8.0, 4.0])
  |> line.with_theme(theme.ocean())
  |> line.with_area_fill(True)
  |> line.to_svg
}

Each theme is a small bundle of four CSS colour strings:

Pass a theme to line.with_theme / bar.with_theme to set all four slots at once. The individual with_color, with_background_color, with_area_color, and with_negative_color helpers override one slot at a time and can be chained after with_theme to tweak it.

Types

Opaque colour scheme. Use the named constructors below (ocean(), forest(), …) and the accessor functions (foreground/1, background/1, …) — the constructor is private so the set of slots can grow without breaking callers.

pub opaque type Theme

Values

pub fn amber() -> Theme

Golden amber on white — popular for finance and “warning” indicators where red would be too strong.

pub fn area(theme: Theme) -> String

Area-fill colour used under the line in line charts when with_area_fill(True) is set.

pub fn background(theme: Theme) -> String

Background rectangle colour. The string "none" disables the background rectangle entirely (the renderer omits it from the SVG / leaves PNG pixels transparent).

pub fn crimson() -> Theme

Saturated red on white — useful for losses, alerts, or “attention required” KPIs.

pub fn default() -> Theme

Default theme used when no with_theme call is made: CSS currentColor for the foreground, no background fill, an auto-derived area tint, and a fallback negative bar colour.

pub fn foreground(theme: Theme) -> String

The chart’s main stroke / fill colour.

pub fn forest() -> Theme

Emerald green paired with a red negative — the canonical “finance up / down” palette.

pub fn midnight() -> Theme

Off-white foreground on deep navy — a dark-mode companion to mono(), for embedding into dark dashboards.

pub fn mono() -> Theme

Near-black on pure white — print-friendly and embeds cleanly in monochrome dashboards.

pub fn negative(theme: Theme) -> String

Colour applied to negative bars in bar charts. Ignored by line charts.

pub fn neon() -> Theme

High-contrast cyan on near-black — designed for dark UIs.

pub fn ocean() -> Theme

Classic vivid blue on white — a sensible default for product dashboards. Foreground is Tailwind blue-600.

pub fn pastel() -> Theme

Soft violet on a paper-white canvas — low-key, design-focused.

pub fn slate() -> Theme

Neutral slate grey on white — corporate, low-saturation, works alongside any brand colour without competing with it.

pub fn sunset() -> Theme

Warm orange — good for attention or “trending” indicators.

Search Document