简体中文
布局、样式与主题类型:完整声明
以下声明由 Go AST 提取,保留源码英文契约和字段注释,隐藏私有字段;struct {} 表示外部不可直接配置的内部表示,不表示可以用零值替代构造函数。常量块保留 iota 上下文。
Length
text
Length is an opaque automatic, logical-pixel, or percentage length. Its zero
value means automatic sizing; use Px or Percent for an explicit value.go
type Length struct {
}对应示例 · 源文件 style.go:13
Px
text
Px creates a logical-pixel length.go
func Px(value float32) Length对应示例 · 源文件 style.go:19
Percent
text
Percent creates a percentage length in the range 0..100.go
func Percent(value float32) Length对应示例 · 源文件 style.go:22
Fill
text
Fill is the common full-available-axis length. It is equivalent to
Percent(100) and remains subject to the parent's definite-size rules.go
func Fill() Length对应示例 · 源文件 style.go:26
MetricToken
text
MetricToken names a theme metric.go
type MetricToken string对应示例 · 源文件 style.go:29
ColorToken
text
ColorToken names a theme color.go
type ColorToken string对应示例 · 源文件 style.go:32
MetricValue
text
MetricValue is either a literal logical-unit metric or a theme token.go
type MetricValue struct {
}对应示例 · 源文件 style.go:35
Metric
text
Metric creates a literal metric.go
func Metric(value float32) MetricValue对应示例 · 源文件 style.go:43
NoShrink
text
NoShrink explicitly disables flex shrinking. It is equivalent to Some(0)
and is distinct from an unset Shrink, whose default is one.go
func NoShrink() Option[float32]对应示例 · 源文件 style.go:47
Padding
text
Padding applies one literal logical-unit metric to every edge. The returned
metrics are explicitly set, including when value is zero.go
func Padding(value float32) EdgeValues对应示例 · 源文件 style.go:51
PaddingXY
text
PaddingXY applies literal logical-unit metrics to the horizontal and vertical
edges. The returned metrics are explicitly set, including zero values.go
func PaddingXY(horizontal, vertical float32) EdgeValues对应示例 · 源文件 style.go:55
Margin
text
Margin applies one literal logical-unit metric to every edge, like Padding.
The returned metrics are explicitly set, including when value is zero.go
func Margin(value float32) EdgeValues对应示例 · 源文件 style.go:64
MarginXY
text
MarginXY applies literal logical-unit metrics to the horizontal and vertical
edges, like PaddingXY. The returned metrics are explicitly set, including zero values.go
func MarginXY(horizontal, vertical float32) EdgeValues对应示例 · 源文件 style.go:68
Round
text
Round applies one literal logical-unit radius to every corner. The returned
metrics are explicitly set, including when value is zero.go
func Round(value float32) CornerValues对应示例 · 源文件 style.go:72
TokenMetric
text
TokenMetric creates a token-backed metric.go
func TokenMetric(token MetricToken) MetricValue对应示例 · 源文件 style.go:75
ColorValue
text
ColorValue is either a literal color or a theme token.go
type ColorValue struct {
}对应示例 · 源文件 style.go:80
ColorRGBA
text
ColorRGBA creates an explicitly set literal paint color from RGBA channels,
including transparent zero. Use RGBA for raw RGBAColor data instead.go
func ColorRGBA(r, g, b, a uint8) ColorValue对应示例 · 源文件 style.go:89
LiteralColor
text
LiteralColor wraps existing raw RGBA data as a literal paint color.
Use ColorRGBA when supplying channels directly.go
func LiteralColor(value RGBAColor) ColorValue对应示例 · 源文件 style.go:93
TokenColor
text
TokenColor creates a token-backed paint color.go
func TokenColor(token ColorToken) ColorValue对应示例 · 源文件 style.go:96
EdgeValues
text
EdgeValues contains metrics in top, right, bottom, left order. Its zero-value
fields are unset.go
type EdgeValues struct{ Top, Right, Bottom, Left MetricValue }对应示例 · 源文件 style.go:102
Edges
text
Edges creates explicit logical-unit edges in top, right, bottom, left order.go
func Edges(top, right, bottom, left float32) EdgeValues对应示例 · 源文件 style.go:105
UniformEdges
text
UniformEdges applies one metric to every edge.go
func UniformEdges(value MetricValue) EdgeValues对应示例 · 源文件 style.go:115
CornerValues
text
CornerValues contains radii in top-left, top-right, bottom-right, bottom-left order.
Its zero-value fields are unset.go
type CornerValues struct{ TopLeft, TopRight, BottomRight, BottomLeft MetricValue }对应示例 · 源文件 style.go:121
Corners
text
Corners creates explicit logical-unit radii in top-left, top-right,
bottom-right, bottom-left order.go
func Corners(topLeft, topRight, bottomRight, bottomLeft float32) CornerValues对应示例 · 源文件 style.go:125
UniformCorners
text
UniformCorners applies one radius to every corner.go
func UniformCorners(value MetricValue) CornerValues对应示例 · 源文件 style.go:135
Position
text
Position controls normal-flow versus absolute layout.go
type Position uint8对应示例 · 源文件 style.go:140
PositionFlow
go
const (
PositionFlow Position = iota
PositionAbsolute
)对应示例 · 源文件 style.go:143
PositionAbsolute
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:144
Insets
text
Insets contains absolute-position insets.go
type Insets struct{ Top, Right, Bottom, Left Length }对应示例 · 源文件 style.go:148
Overflow
text
Overflow controls container clipping.go
type Overflow uint8对应示例 · 源文件 style.go:151
OverflowVisible
go
const (
OverflowVisible Overflow = iota
OverflowClip
)对应示例 · 源文件 style.go:154
OverflowClip
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:155
Align
text
Align controls cross-axis alignment.go
type Align uint8对应示例 · 源文件 style.go:159
AlignStart
go
const (
AlignStart Align = iota
AlignCenter
AlignEnd
AlignStretch
)对应示例 · 源文件 style.go:162
AlignCenter
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:163
AlignEnd
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:164
AlignStretch
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:165
Justify
text
Justify controls main-axis alignment.go
type Justify uint8对应示例 · 源文件 style.go:169
JustifyStart
go
const (
JustifyStart Justify = iota
JustifyCenter
JustifyEnd
JustifySpaceBetween
)对应示例 · 源文件 style.go:172
JustifyCenter
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:173
JustifyEnd
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:174
JustifySpaceBetween
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:175
Style
text
Style contains the supported layout, paint, and typography controls. Box
is always single-line; there is intentionally no wrap or order
property. The zero value is safe and selects intrinsic sizing and theme
defaults.go
type Style struct {
Width, Height Length
MinWidth, MinHeight Length
MaxWidth, MaxHeight Length
Margin, Padding EdgeValues
Position Position
Insets Insets
Grow float32
Shrink Option[float32]
Basis Length
AlignSelf Option[Align]
ZIndex int
Overflow Overflow
Background ColorValue
Border Border
Radius CornerValues
// Shadow is an explicitly requested list of outer shadows. A nil value
// leaves a theme/state value unchanged; a non-nil empty slice removes it.
Shadow []Shadow
Opacity Option[float32]
Visibility Visibility
Text TextStyle
// Force is applied after component and interaction-state styles. It is for
// deliberate paint overrides such as suppressing a focus ring; ordinary
// base appearance belongs in the fields above so Hover/Pressed/Focus remain
// visible. Force cannot affect layout.
Force StylePatch
}对应示例 · 源文件 style.go:182
Visibility
text
Visibility controls whether a node contributes display items.go
type Visibility uint8对应示例 · 源文件 style.go:212
Visible
go
const (
Visible Visibility = iota
Hidden
)对应示例 · 源文件 style.go:215
Hidden
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:216
PointerBehavior
text
PointerBehavior controls pointer participation for a view subtree.go
type PointerBehavior uint8对应示例 · 源文件 style.go:220
PointerAuto
go
const (
PointerAuto PointerBehavior = iota
// PointerNone excludes the view and all descendants. It is intended for
// decorative overlays that must not intercept content below them.
PointerNone
)对应示例 · 源文件 style.go:223
PointerNone
text
PointerNone excludes the view and all descendants. It is intended for
decorative overlays that must not intercept content below them.类型和值见本页同组常量块。
对应示例 · 源文件 style.go:226
BorderPattern
text
BorderPattern selects how a border is painted. The zero value is solid.go
type BorderPattern uint8对应示例 · 源文件 style.go:230
BorderSolid
go
const (
BorderSolid BorderPattern = iota
BorderDashed
)对应示例 · 源文件 style.go:233
BorderDashed
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:234
BorderSides
text
BorderSides selects edges. Zero means all edges, not an absent border.go
type BorderSides uint8对应示例 · 源文件 style.go:238
BorderTop
go
const (
BorderTop BorderSides = 1 << iota
BorderRight
BorderBottom
BorderLeft
BorderAll = BorderTop | BorderRight | BorderBottom | BorderLeft
)对应示例 · 源文件 style.go:241
BorderRight
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:242
BorderBottom
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:243
BorderLeft
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:244
BorderAll
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:245
Border
text
Border is a paint-only border drawn inside a view's layout bounds.
Each side owns the nearest half of its two adjacent corner arcs.go
type Border struct {
Width MetricValue
Color ColorValue
Pattern BorderPattern
// Sides defaults to all edges. In Style, a Width/Color assignment resets
// Sides too; otherwise nonzero Sides changes only edge selection.
// StylePatch.Border replaces the complete Border.
Sides BorderSides
}对应示例 · 源文件 style.go:250
NoBorder
text
NoBorder explicitly clears the border width. In ordinary Style, later state
patches may restore a border; Style.Force is applied after those patches.go
func NoBorder() Border对应示例 · 源文件 style.go:262
Stroke
text
Stroke creates a solid border with a literal logical-unit width.go
func Stroke(width float32, color ColorValue) Border对应示例 · 源文件 style.go:265
Shadow
text
Shadow is an outer paint-only shadow. MVP shadows support finite,
non-negative blur/spread and are rendered by a bounded approximation.go
type Shadow struct {
OffsetX, OffsetY MetricValue
Blur, Spread MetricValue
Color ColorValue
}对应示例 · 源文件 style.go:271
FontWeight
text
FontWeight selects the nearest registered face weight in a family.go
type FontWeight uint16对应示例 · 源文件 style.go:278
WeightRegular
go
const (
WeightRegular FontWeight = 400
WeightMedium FontWeight = 500
WeightBold FontWeight = 700
)对应示例 · 源文件 style.go:281
WeightMedium
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:282
WeightBold
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:283
FontSlant
text
FontSlant selects a registered normal or italic face.go
type FontSlant uint8对应示例 · 源文件 style.go:287
SlantNormal
go
const (
SlantNormal FontSlant = iota
SlantItalic
)对应示例 · 源文件 style.go:290
SlantItalic
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:291
TextAlign
text
TextAlign is horizontal alignment within a Text node's content box.go
type TextAlign uint8对应示例 · 源文件 style.go:295
TextStart
go
const (
TextStart TextAlign = iota
TextCenter
TextEnd
)对应示例 · 源文件 style.go:298
TextCenter
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:299
TextEnd
类型和值见本页同组常量块。
对应示例 · 源文件 style.go:300
TextStyle
text
TextStyle contains the simple-LTR/CJK MVP text inputs. Families are tried in
order before the App default and built-in Latin fallback. Size is a font
size in logical units; zero uses the current theme's default. LineHeight is
a logical-unit line height; zero uses the current theme's default.
Arabic/Indic shaping, bidi/RTL, color emoji, and vertical text are not
supported by this API.go
type TextStyle struct {
Families []FontFamily
Size float32
LineHeight float32
Weight FontWeight
Slant FontSlant
Color ColorValue
Align TextAlign
}对应示例 · 源文件 style.go:309
ComponentToken
text
ComponentToken names a component-level theme entry.go
type ComponentToken string对应示例 · 源文件 style.go:320
PrimitiveTokens
text
PrimitiveTokens are the literal foundation of a theme.go
type PrimitiveTokens struct {
Colors map[ColorToken]RGBAColor
Metrics map[MetricToken]float32
}对应示例 · 源文件 style.go:323
SemanticTokens
text
SemanticTokens map product meaning onto primitive or earlier semantic
tokens. A literal ColorValue/MetricValue is also accepted.go
type SemanticTokens struct {
Colors map[ColorToken]ColorValue
Metrics map[MetricToken]MetricValue
}对应示例 · 源文件 style.go:330
StylePatch
text
StylePatch is an explicitly optional paint-only override. State styles are
intentionally paint-only in MVP, so interaction never moves layout.go
type StylePatch struct {
Background Option[ColorValue]
Border Option[Border]
Radius Option[CornerValues]
Shadow Option[[]Shadow]
Opacity Option[float32]
Visibility Option[Visibility]
TextColor Option[ColorValue]
}对应示例 · 源文件 style.go:337
StateStyles
text
StateStyles contains the deterministic MVP visual-state cascade.go
type StateStyles struct {
Default StylePatch
Hover StylePatch
Focus StylePatch
Disabled StylePatch
Pressed StylePatch
Checked StylePatch
}对应示例 · 源文件 style.go:348
ComponentTheme
text
ComponentTheme supplies semantic-token-backed defaults for one component.go
type ComponentTheme struct {
Base StylePatch
States StateStyles
}对应示例 · 源文件 style.go:358
Theme
text
Theme is the public, type-safe Primitive -> Semantic -> Component token
structure. SetTheme validates and copies every map and slice atomically.go
type Theme struct {
Primitive PrimitiveTokens
Semantic SemanticTokens
Components map[ComponentToken]ComponentTheme
}对应示例 · 源文件 style.go:365
Direction
text
Direction selects Box's main axis. Vertical is the zero value.go
type Direction uint8对应示例 · 源文件 style.go:384
Vertical
text
Vertical lays out Box children from top to bottom and is the zero value.go
const (
// Vertical lays out Box children from top to bottom and is the zero value.
Vertical Direction = iota
// Horizontal lays out Box children from left to right.
Horizontal
)对应示例 · 源文件 style.go:388
Horizontal
text
Horizontal lays out Box children from left to right.类型和值见本页同组常量块。
对应示例 · 源文件 style.go:390
BoxProps
text
BoxProps configures a Box. Gap is a fixed logical-unit spacing; zero means
no spacing between children.go
type BoxProps struct {
Key string
Style Style
Token ComponentToken
States StateStyles
Pointer PointerBehavior
Direction Direction
Gap float32
Justify Justify
Align Align
}对应示例 · 源文件 style.go:395