Skip to main content

Module theme

Module theme 

Source
Expand description

Theme system for ccf-gpui-widgets

Provides a Theme struct with sensible defaults and builder pattern for customization. Widgets can access the theme via a global context or per-widget override.

§Example

use ccf_gpui_widgets::{Theme, Palette};

// Use dark theme (default)
let theme = Theme::dark();

// Use light theme
let theme = Theme::light();

// Customize
let theme = Theme::dark()
    .with_accent(0x00ff00)
    .with_border_focus(0x00ff00);

// Create from minimal palette (derives all 52 colors from 7 seeds)
let theme = Theme::from_palette(Palette::dark());

// Customize brand colors with palette
let theme = Theme::from_palette(
    Palette::dark()
        .with_primary(0xe94560)
        .with_accent(0x0f3460)
);

// Fully custom palette
let theme = Theme::from_palette(Palette {
    bg: 0x1a1a2e,
    text: 0xeaeaea,
    primary: 0xe94560,
    accent: 0x0f3460,
    success: 0x4ecca3,
    error: 0xff6b6b,
    warning: 0xffc93c,
});

// Set globally
cx.set_global(theme);

Structs§

Palette
Minimal color palette for generating a full Theme
Theme
Theme configuration for widgets

Functions§

get_theme
Get the theme from context, falling back to dark theme if not set
get_theme_or
Get the theme from context or use a custom theme