style

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorBackgroundHover = css.Token{Name: "--color-background-hover", Fallback: "#f2f2f7"}
	ColorSurfaceHover    = css.Token{Name: "--color-surface-hover", Fallback: "#e5e5ea"}
	ColorPrimaryHover    = css.Token{Name: "--color-primary-hover", Fallback: "#0096bc"}
	ColorSecondaryHover  = css.Token{Name: "--color-secondary-hover", Fallback: "#503cd1"}
	ColorSelectionHover  = css.Token{Name: "--color-selection-hover", Fallback: "#0062cc"}
	ColorSuccessHover    = css.Token{Name: "--color-success-hover", Fallback: "#34a243"}
	ColorErrorHover      = css.Token{Name: "--color-error-hover", Fallback: "#cf3c15"}
	ColorMutedHover      = css.Token{Name: "--color-muted-hover", Fallback: "#55555a"}

	ColorBackgroundFocus = css.Token{Name: "--color-background-focus", Fallback: "#ffffff"}
	ColorSurfaceFocus    = css.Token{Name: "--color-surface-focus", Fallback: "#f2f2f7"}
	ColorPrimaryFocus    = css.Token{Name: "--color-primary-focus", Fallback: "#0096bc"}
	ColorSecondaryFocus  = css.Token{Name: "--color-secondary-focus", Fallback: "#503cd1"}
	ColorSelectionFocus  = css.Token{Name: "--color-selection-focus", Fallback: "#0062cc"}

	ColorBackgroundPress = css.Token{Name: "--color-background-press", Fallback: "#e5e5ea"}
	ColorSurfacePress    = css.Token{Name: "--color-surface-press", Fallback: "#d1d1d6"}
	ColorPrimaryPress    = css.Token{Name: "--color-primary-press", Fallback: "#0080a0"}
	ColorSecondaryPress  = css.Token{Name: "--color-secondary-press", Fallback: "#4532be"}
	ColorSelectionPress  = css.Token{Name: "--color-selection-press", Fallback: "#0052b3"}
)

Tokens de estados interactivos locales (Hover, Focus, Press)

Functions

This section is empty.

Types

type Elevation

type Elevation uint8
const (
	Flat Elevation = iota
	Raised
	Floating
	Overlay
)

type Opt

type Opt func(*Rule)

Opt es una opción visual que configura una regla.

func Center

func Center() Opt

Center define una columna centrada con tope Prose/Content.

func Clip

func Clip() Opt

Clip recorta a los hijos (overflow:hidden).

func Cover

func Cover() Opt

Cover llena el contenedor con un hijo centrado.

func Fill

func Fill() Opt

Fill toma el alto disponible completo.

func Fixed

func Fixed() Opt

Fixed NO reflota: mantiene su disposición bajo cualquier ancho.

func Flush

func Flush() Opt

Flush es sin radio ni margen: pega a ras del contenedor padre.

func FontWeight

func FontWeight(w Weight) Opt

FontWeight establece el grosor de la fuente.

func Frame

func Frame(ratio Ratio) Opt

Frame define una caja de proporción fija (media).

func Grid

func Grid(min Track, gap Space) Opt

Grid define auto-fit + minmax sin número fijo de columnas.

func On

func On(s Surface) Opt

On establece la decisión de superficie de color (background, texto y borde).

func Pad

func Pad(s Space) Opt

Pad aplica relleno interno (padding) según la escala de espacio.

func Raise

func Raise(e Elevation) Opt

Raise aplica elevación (box-shadow) según la escala de elevación.

func Reel

func Reel(gap Space) Opt

Reel define una tira horizontal con scroll-snap.

func Round

func Round(rad Radius) Opt

Round aplica radio de borde (border-radius) según la escala de radio.

func Row

func Row(gap Space) Opt

Row define un flujo horizontal que envuelve cuando no cabe.

func Scrolls

func Scrolls() Opt

Scrolls desborda internamente en vez de crecer. Implica Fill().

func Split

func Split(ratio Ratio, gap Space) Opt

Split define dos paneles que se apilan bajo su propio ancho.

func Stack

func Stack(gap Space) Opt

Stack define un ritmo vertical con hijos a ancho completo.

func Text

func Text(ts TextSize) Opt

Text establece el tamaño del texto.

func Width

func Width(s Size) Opt

Width aplica la única medida de ancho relativa (Size) aceptada en la API.

type Radius

type Radius uint8
const (
	RadiusNone Radius = iota
	RadiusSm
	RadiusMd
	RadiusLg
	RadiusFull
)

type Ratio

type Ratio uint8
const (
	RatioHalf Ratio = iota
	RatioTwoThirds
	RatioThreeQuarters
)

type Rule

type Rule struct {
	HasFlow   bool
	FlowType  string // "stack", "row", "split", "grid", "center", "cover", "reel", "frame"
	FlowGap   Space
	FlowRatio Ratio
	FlowTrack Track

	HasSurface bool
	Surface    Surface

	HasPad bool
	Pad    Space

	HasRound bool
	Round    Radius

	HasRaise bool
	Raise    Elevation

	HasSize bool
	Size    Size

	Fill    bool
	Scrolls bool
	Fixed   bool
	Flush   bool
	Clip    bool

	HasTextSize bool
	TextSize    TextSize
	HasWeight   bool
	Weight      Weight
}

Rule contiene todas las propiedades visuales acumuladas para un elemento (Root o Part).

func (Rule) Decls

func (r Rule) Decls() []string

Rule.Decls formats the declarations of a rule

type Sheet

type Sheet struct {
	Name       widget.Name
	RootRule   Rule
	PartRules  map[widget.Part]Rule
	StateRules map[stateKey]Rule
	CueRules   map[cueKey]Rule
}

Sheet representa el bloque de estilo scoped a un widget.

func Of

func Of(n widget.Name) *Sheet

Of abre el bloque de estilo de un widget. Todas sus reglas quedan scoped a n.

func (*Sheet) Cue

func (s *Sheet) Cue(c widget.Cue, p widget.Part, opts ...Opt) *Sheet

Cue define el estilo de una parte (o Root si p es "") cuando el navegador posee un cue (hover, focus, etc.).

func (*Sheet) Part

func (s *Sheet) Part(p widget.Part, opts ...Opt) *Sheet

Part define el estilo de una parte anatómica del widget.

func (*Sheet) Root

func (s *Sheet) Root(opts ...Opt) *Sheet

Root define el estilo de la raíz del widget.

func (*Sheet) Stylesheet

func (s *Sheet) Stylesheet() *css.Stylesheet

Stylesheet genera un css.Stylesheet para el Sheet.

func (*Sheet) When

func (s *Sheet) When(st widget.State, p widget.Part, opts ...Opt) *Sheet

When define el estilo de una parte (o Root si p es "") cuando el widget posee un estado.

type Size

type Size uint8

Size es la ÚNICA medida de ancho. Relativa al contenedor, nunca al viewport — las unidades vw/vh no existen en esta API.

const (
	Content Size = iota // se ajusta a su contenido
	Prose               // ancho legible (~65ch)
	Third
	Half
	TwoThirds
	Full // 100% del contenedor
)

type Space

type Space uint8
const (
	Space0 Space = iota
	Space1
	Space2
	Space3
	Space4
	Space5
	Space6
	Space7
	Space8
	Space9
	Space10
	Space11
	Space12
)

type Styler

type Styler interface {
	widget.Widget
	Style() *Sheet
}

Styler es la capacidad "este widget tiene aspecto". La asevera el recolector SSR.

type Surface

type Surface uint8

Surface es una decisión visual completa: fondo, texto y borde resueltos como UNA tripleta. No hay forma de elegir un fondo sin su texto.

const (
	Page Surface = iota
	PageHover
	PageFocus
	PagePress

	Panel
	PanelHover
	PanelFocus
	PanelPress

	Sunken
	SunkenHover
	SunkenFocus
	SunkenPress

	Accent
	AccentHover
	AccentFocus
	AccentPress

	Secondary
	SecondaryHover
	SecondaryFocus
	SecondaryPress

	Selected
	SelectedHover
	SelectedFocus
	SelectedPress

	Success
	SuccessHover
	SuccessFocus
	SuccessPress

	Danger
	DangerHover
	DangerFocus
	DangerPress

	Muted
	MutedHover
	MutedFocus
	MutedPress

	Disabled
)

func (Surface) Resolve

func (s Surface) Resolve() Triplet

Resolve traduce una Surface a su correspondiente Triplet de estilos.

type TextSize

type TextSize uint8
const (
	TextXs TextSize = iota
	TextSm
	TextBase
	TextLg
	TextXl
	Text2xl
)

type Track

type Track uint8
const (
	TrackSm Track = iota
	TrackMd
	TrackLg
)

type Triplet

type Triplet struct {
	Bg     string
	Text   string
	Border string
}

Triplet representa la combinación de fondo, texto y borde.

type Weight

type Weight uint8
const (
	WeightRegular Weight = iota
	WeightMedium
	WeightBold
)

Jump to

Keyboard shortcuts

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