theme/devtools/devtools.go
Functions
func AsTheme
func (t *Theme) AsTheme() *theme.Theme {
cs := t.Colors
mode := theme.ModeLight
name := "DevTools Light"
shadows := theme.DefaultShadowsLight()
if t.dark {
mode = theme.ModeDark
name = "DevTools Dark"
shadows = theme.DefaultShadowsDark()
}
return &theme.Theme{
Name: name,
Mode: mode,
Colors: theme.ColorPalette{
Primary: cs.Primary,
PrimaryLight: cs.PrimaryHover,
PrimaryDark: cs.PrimaryPress,
Secondary: cs.Primary,
SecondaryLight: cs.PrimaryHover,
SecondaryDark: cs.PrimaryPress,
Background: cs.Background,
Surface: cs.Surface,
SurfaceVariant: cs.SurfaceElevated,
Error: cs.Error,
Warning: cs.Warning,
Success: cs.Success,
Info: cs.Info,
OnPrimary: cs.OnPrimary,
OnSecondary: cs.OnPrimary,
OnBackground: cs.OnSurface,
OnSurface: cs.OnSurface,
OnError: widget.ColorWhite,
Divider: cs.Border,
Outline: cs.BorderStrong,
Shadow: cs.Shadow,
},
Typography: devtoolsTypography(),
Spacing: devtoolsSpacing(),
Shadows: shadows,
Radii: devtoolsRadii(),
Extensions: make(map[string]any),
}
}
func IsDark
IsDark returns true if this theme uses a dark color scheme.
func (t *Theme) IsDark() bool {
return t.dark
}
func NewDarkTheme
NewDarkTheme creates a DevTools dark theme.
This is the primary theme for DevTools, optimized for long sessions.
By default it uses JetBrains Blue (#3574F0) as the accent color.
Use [WithAccentColor] to customize.
func NewDarkTheme(opts ...Option) *Theme {
cfg := themeConfig{accent: DefaultAccentColor}
for _, o := range opts {
o(&cfg)
}
cs := DarkScheme()
applyAccent(&cs, cfg.accent, true)
return &Theme{Colors: cs, dark: true}
}
func NewTheme
NewTheme creates a DevTools light theme.
By default it uses JetBrains Blue (#3574F0) as the accent color.
Use [WithAccentColor] to customize:
t := devtools.NewTheme(devtools.WithAccentColor(widget.Hex(0x57965C)))
func NewTheme(opts ...Option) *Theme {
cfg := themeConfig{accent: DefaultAccentColor}
for _, o := range opts {
o(&cfg)
}
cs := LightScheme()
applyAccent(&cs, cfg.accent, false)
return &Theme{Colors: cs}
}
func OnSurface
OnSurface returns the default text/icon color for surface backgrounds.
This satisfies the widget.ThemeProvider interface.
func (t *Theme) OnSurface() widget.Color {
return t.Colors.OnSurface
}
func WithAccentColor
WithAccentColor sets the accent color for the DevTools theme.
If not provided, the default JetBrains Blue (#3574F0) is used.
The accent color is applied to Primary, PrimaryHover, PrimaryPress,
BorderFocus, and Info roles. Hover and press variants are derived
automatically.
func WithAccentColor(accent widget.Color) Option {
return func(c *themeConfig) {
c.accent = accent
}
}
Structs
type Theme struct
Theme provides JetBrains-inspired DevTools design tokens.
A Theme contains the complete set of design tokens needed to style
a DevTools application: colors (based on JetBrains Int UI gray scale
with a customizable accent), and references to the shared theme.Theme
for typography, spacing, shadows, and radii.
DevTools is dark-first: [NewDarkTheme] produces the primary theme,
while [NewTheme] produces a light variant. Both themes feature a dark
header toolbar, matching JetBrains IDE behavior.
Create a theme:
dark := devtools.NewDarkTheme() // default dark
dark := devtools.NewDarkTheme(devtools.WithAccentColor(widget.Hex(0x57965C))) // green accent
light := devtools.NewTheme() // default light
type Theme struct {
// Colors holds the DevTools color scheme.
Colors ColorScheme
// dark indicates whether this theme uses a dark color scheme.
dark bool
}
AsTheme converts the DevTools theme to a theme.Theme for use with
the generic theme system. This maps DevTools color roles to the
shared ColorPalette structure.