styling

package
v0.3.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package styling resolves lys-shell's design tokens to concrete colors: the Go counterpart of crates/wayle-styling. The palette is the runtime source of truth and every token is a color-mix derivation from it, defined once in Palette.Token: TokensCSS hands the stylesheet the same colors lys-ui's theme and the painters use.

Index

Constants

View Source
const LegacyUserStylesFile = "index.scss"

LegacyUserStylesFile is the SCSS entry lys-shell read before its styles became plain CSS.

View Source
const RemBase = 16.0

RemBase is the rem the stylesheet's base values multiply: styling.rs's REM_BASE.

View Source
const UserStylesFile = "index.css"

UserStylesFile is the user's stylesheet under <configDir>/styles/.

Variables

View Source
var ErrPaletteNotFound = errors.New("styling: palette file not found")

ErrPaletteNotFound reports that a provider's palette file does not exist yet (Error::PaletteNotFound); the extractor has not run.

View Source
var StaticCSS = concatSheets()

StaticCSS is the built-in stylesheet: every file in sheetOrder, concatenated.

Functions

func BarCSS

func BarCSS(bar config.BarConfig, provider config.ThemeProvider) string

BarCSS is the bar's variable block (crates/lys-shell/src/shell/bar/ styling.rs build_css): scale, colors, borders, the pixel-rounded spacing, the button opacity and weight, the group chrome, and the shadow.

func BundleCSS

func BundleCSS(cfg *config.Config, palette config.Palette, p *Palette) string

BundleCSS is the built-in stylesheet under cfg's theme: the static rules, the palette and config block for palette, the tokens resolved from p, the same palette as render colors, and the type scale.

func ButtonCSS

ButtonCSS is one bar button's variable block (bar_buttons/styling.rs build_css): the five colors, each a threshold override when one is active, and the bar's button border width.

func ColorMix

func ColorMix(a, b render.Color, pct int) render.Color

ColorMix interpolates two premultiplied colors: color-mix(in srgb, a pct%, b). CSS interpolates premultiplied channels, which is exactly what interpolating render.Color's bytes does — straight-alpha edge cases (mixing with transparent) come out right by construction.

func ContainerCSS

func ContainerCSS(c config.ContainerConfig, bar config.BarConfig, provider config.ThemeProvider) string

ContainerCSS is a bar container's variable block (bar_container/styling.rs build_css): background, border color, and the bar's button border width, zero while border-show is off.

func EnsureUserStylesScaffold

func EnsureUserStylesScaffold(configDir string)

EnsureUserStylesScaffold creates <configDir>/styles/ and a starter index.css when either is missing. It is a no-op once both exist, and never overwrites the user's file; failures are logged, not returned, so scaffolding never blocks startup.

func HexRGBA

func HexRGBA(c render.Color) string

HexRGBA renders a premultiplied color as the straight-alpha #rrggbbaa (or #rrggbb when opaque) form lys-ui stylesheets parse.

func LoadMatugen

func LoadMatugen(path string, isLight bool) (config.Palette, error)

LoadMatugen reads a matugen palette: primary doubles as blue, tertiary is yellow, secondary green, error red.

func LoadPywal

func LoadPywal(path string, isLight bool) (config.Palette, error)

LoadPywal reads pywal's colors.json: the special background and foreground, color1-4 as red/green/yellow/blue, color7 muted.

func LoadWallust

func LoadWallust(path string, isLight bool) (config.Palette, error)

LoadWallust reads wallust's cached palette: color3 red, color4 green, color5 yellow, color6 primary and blue, color7 muted.

func NotificationCSS added in v0.2.0

func NotificationCSS(p config.Palette, n config.NotificationConfig) string

NotificationCSS declares the popup cards' resting surface: the card color, the palette's elevated surface, at popup-opacity.

func ParseHex

func ParseHex(s string) (render.Color, bool)

ParseHex is parseHex for callers outside styling: a CSS hex color as a premultiplied render.Color.

func ResolveColor

func ResolveColor(cv config.ColorValue, p *Palette) (render.Color, bool)

ResolveColor resolves a config ColorValue against the palette: Auto defers to the accent (ColorValue::to_css's documented fallback), transparent is fully transparent, custom hex parses, tokens go through the token table. An invalid hex or unknown token is a load- time error by construction; the bool return covers the custom hex that only fails at resolve time.

func ResolveColorCSS

func ResolveColorCSS(value, fieldDefault config.ColorValue, provider config.ThemeProvider) string

ResolveColorCSS is a color field's CSS (resolve_color in crates/wayle-widgets/src/styling.rs): tokens, transparent, and auto pass through as CSS so a palette swap follows; a custom hex is used under the lys-shell provider but falls back to the field's schema default under an extractor, where a fixed hex has no mapping.

func ResolveIconColor

func ResolveIconColor(b config.ButtonConfig, variant config.BarButtonVariant, provider config.ThemeProvider) string

ResolveIconColor is a bar button's icon color (resolve_icon_color in crates/wayle-widgets/src/components/bar_buttons/component.rs): the custom-hex fallback of ResolveColorCSS, then auto resolves to the module's accent token under the basic variant and to fg-on-accent on the block-prefix and icon-square chrome.

func ResolvePalette

func ResolvePalette(fallback config.Palette, s config.StylingConfig) (config.Palette, error)

ResolvePalette is the active palette for the configured theme provider (resolve_palette): the lys-shell provider is fallback itself, the extractors load the file extract.ColorsPath names for their tool, with the forced appearance overriding the tool's own light setting. A provider that fails yields fallback and the failure, which the caller logs — the palette is always usable, as in Rust, which logs and falls back.

func RoundingRadiusPx

func RoundingRadiusPx(level config.RoundingLevel, scale float64) int

RoundingRadiusPx resolves a rounding level to corner pixels: the --radius-* table (css/tokens/index.css) times the scale, with full pinned at 9999px unscaled.

func ThemeCSS

ThemeCSS is the runtime theme block, byte for byte the Rust theme_css (crates/wayle-styling/src/lib.rs): the :root custom properties for the palette, the dropdown surface, fonts, scales, the bar-button pixel overrides, and the rounding tokens. Rust resolves the palette inside theme_css; here the caller passes the result of ResolvePalette, so the provider failure surfaces as an error to log instead of a hidden log line. The output is the full ":root { ... }" rule.

func TokensCSS

func TokensCSS(p *Palette) string

TokensCSS declares every palette token (--bg-overlay, --accent, ...) as the color Palette.Token resolves for p: the Go table is the one definition the stylesheet, lys-ui's theme and the settings swatches all read.

func ToolkitRadiusPx added in v0.2.0

func ToolkitRadiusPx() int

ToolkitRadiusPx is lys-ui's default corner radius, what the default rounding level resolves to.

func TryUserCSS

func TryUserCSS(configDir string) (string, error)

TryUserCSS is UserCSS surfacing the failure. ("", nil) means the file does not exist. A leftover styles/index.scss is an error naming the CSS file that replaces it, so its rules never silently stop applying.

func TypeScaleCSS added in v0.2.0

func TypeScaleCSS() string

TypeScaleCSS declares every role's tokens on :root: rem times the role's ratio times --global-scale, and the bar's twin over --bar-scale.

func UserCSS

func UserCSS(configDir string) string

UserCSS is the user's optional overrides at <configDir>/styles/index.css. A failure is logged and yields "", so a broken user stylesheet leaves the rest of the bundle intact.

func UserStylesDir

func UserStylesDir(configDir string) (string, bool)

UserStylesDir returns <configDir>/styles/ when it is a directory.

func WidthStyle added in v0.2.0

func WidthStyle(px int) string

WidthStyle is the inline style that makes a widget exactly px wide, its border included: lys-ui's explicit width for content that fills whatever width it is offered (an Item, a progress bar), on a surface that would otherwise offer it the whole output.

func WorkspacesCSS added in v0.2.0

func WorkspacesCSS(c config.CompositorWorkspacesConfig, otherMonitor *config.ColorValue, bar config.BarConfig) string

WorkspacesCSS is a workspaces module's variable block, the colors workspaces.css reads: the state colors, the container background, and the border-show border at the bar's button border width, zero while border-show is off. otherMonitor is hyprland's active-on-other-monitor color, nil for the other compositors.

Types

type Palette

type Palette struct {
	Bg, Surface, Elevated render.Color
	Fg, FgMuted           render.Color
	Primary               render.Color
	Red, Yellow           render.Color
	Green, Blue           render.Color
}

Palette is the runtime color palette — the --palette-* custom properties. Themes replace it wholesale.

func ConfigPalette

func ConfigPalette(s config.StylingConfig) (*Palette, error)

ConfigPalette is the render palette the styling config resolves to: the active palette through its provider, a failing provider leaving the configured palette (as Rust logs and falls back), an unparsable one the compiled Default. Failures are returned for the caller to log; the palette is always usable.

func Default

func Default() *Palette

Default is the built-in catppuccin-mocha palette, the set the shell falls back to when a palette cannot be resolved.

func PaletteFromHex

func PaletteFromHex(p config.Palette) (*Palette, error)

PaletteFromHex converts a resolved hex palette to the render-color Palette the Go painters consume. A provider can hand back any string, so an unparsable color is an error naming the slot.

func (*Palette) Token

func (p *Palette) Token(t config.CssToken) (render.Color, bool)

Token resolves one design token against the palette: the color-mix table, one entry per token; a token without a mix is a palette color passed through. It is the only definition of the tokens.

type TextRole added in v0.2.0

type TextRole int

TextRole is one step of the type scale every surface sizes its text from: a ratio of the desktop's body size (1rem, the desktop font).

const (
	// Caption is secondary text: descriptions, statuses, section headers.
	Caption TextRole = iota
	// Body is running text, labels and controls.
	Body
	// Subtitle is a card or item heading one step above body.
	Subtitle
	// Title is a page or window heading.
	Title
	// Display is a large readout: a percentage, a temperature, a PIN.
	Display
	// Hero is a full-screen readout: the lock and dropdown clocks.
	Hero
)

func TextRoles added in v0.2.0

func TextRoles() []TextRole

TextRoles is every role, smallest first.

func (TextRole) BarToken added in v0.2.0

func (r TextRole) BarToken() string

BarToken is the role's custom property for the bar, scaled by --bar-scale.

func (TextRole) Px added in v0.2.0

func (r TextRole) Px(rem, scale float64) float64

Px is the role's size in pixels over a body of rem pixels at scale.

func (TextRole) Ratio added in v0.2.0

func (r TextRole) Ratio() float64

Ratio is the role's size relative to body.

func (TextRole) Token added in v0.2.0

func (r TextRole) Token() string

Token is the role's custom property for surfaces scaled by --global-scale.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL