Skip to content

Style

Style

An object that manages visual styling for UI components, supporting dynamic state-based values via StateVariable.

Specific kwargs

Argument Type Description
border_radius / br SVar[int | float | tuple] border radius(default is 0).
border_width / bw SVar[int] border width(default is 1).
font_size SVar[int] font size(default is 20).
font_name / font_path SVar[str] font name or path(default is 'Arial').
align_x SVar[Align] horizontal alignment(default is Align.CENTER).
align_y SVar[Align] vertical alignment(default is Align.CENTER).
transparency SVar[int] alpha transparency from 0 to 255(default is None).
bg_image SVar[str] background image path(default is None). uwO - easter egg 4.
colortheme SVar[ColorTheme] color theme(default is material3_blue).
gradient SVar[GradientPygame] gradient background(default is None).
color_role SVar[SubThemeRole] specific color role(default is None).
subtheme_role SVar[SubThemeRole] specific subtheme role(default is None).
font_role SVar[PairColorRole] specific font color role(default is None).

Methods

Name Kwargs Description
add_style_parameter name: str, attribute_name: str, checker_lambda: Callable registers a new custom style parameter.
parse_color value: Any, can_be_gradient: bool = False, can_be_trasparent: bool = False, can_be_string: bool = False validates and parses a color value.
parse_int value: int, max_restriction: int | None = None, min_restriction: int | None = None validates an integer value with optional limits.
parse_str value: str validates a string value.
parse_type value: Any, type: type | tuple validates a value against a specific type.
mark_state state: HoverState updates the current active state for StateVariable resolution.
__call__ **kwargs: Unpack[StyleKwargs] returns a new Style instance with updated parameters.
clone None returns an exact copy of the style.

Getters

Name ReturnType Description
Any StyleKwargs Any accessing any style attribute dynamically returns its value based on the current HoverState.

Setters

Name Kwargs Description
Any StyleKwargs Any you can overwrite style attributes directly, supporting both raw values and StateVariables.

Use case

from nevu_ui import *
import pygame

pygame.init()

window = Window((500, 500), title = "Style example")

menu = Menu(window, (100%vw, 100%vh))

layout = Grid([100%fillw, 100%fillh], x=3, y=3)
style = Style(border_radius = 10, border_width = 2)
widget = Widget(size = (100, 100), style = style)
layout.add_item(widget, 2, 2)

menu.layout = layout

while True:
    window.begin_frame()
    window.update()
    menu.update()
    menu.draw()
    window.end_frame()
from nevu_ui import *
import pyray

window = Window((500, 500), title = "Style example", backend = Backend.RayLib)

menu = Menu(window, (100%vw, 100%vh))

layout = Grid([100%fillw, 100%fillh], x=3, y=3)
style = Style(border_radius = 10, border_width = 2)
widget = Widget(size = (100, 100), style = style)
layout.add_item(widget, 2, 2)

menu.layout = layout

while True:
    window.begin_frame()
    window.update()
    menu.update()
    menu.draw()
    window.end_frame()

Created with GGen v1.1.0 for nevu_ui v0.7.5