ui
分层
只有 api/stable/ui.txt 列出的符号受兼容性承诺约束。标有「实验性」的符号,以及类型下「实验性成员」列出的字段,任何 0.x 版本都可能有不兼容变化(docs/release.md「API 稳定性」)。
import "github.com/tangoui/tango/ui"本页由
site/tools/apigen从源码注释生成(按 darwin 构建标签选文件),请勿手改。
Package ui is the self-drawn GUI layer of Tango: an immediate-mode API over retained widget state, rendered by a pure-Go pipeline (no cgo) with the visual language of Ant Design 6.7 (default), Element Plus and shadcn/ui.
Programming model
A page is a plain function called every frame:
func page(c *ui.Context) {
ui.Input(c, &name).Placeholder("用户名")
if ui.Button(c, "保存").Primary().Clicked() {
save(name)
}
}
Calls build a tree of layout nodes; chained modifiers (Primary, Disabled, ...) configure the widget before layout and paint run at the end of the frame. Interaction (Clicked, Hovered, focus) is answered from the previous frame's geometry, keyed by widget ID. IDs derive from the enclosing scope, widget kind, label and occurrence; wrap dynamic lists in ui.Key. Values live in the app (pointers); widgets only retain transient state (caret, scroll, open dropdowns, animations) via ui.State. Frames are event driven. A static UI stays idle until input or a request for a new frame. In a page function, call Context.WakeAt to schedule a frame. For example, compute a countdown from its deadline each frame, and call c.WakeAt(time.Now().Add(time.Second)) while it is still running. From a background goroutine, use Runner.Post to update application state on the UI thread and request a redraw.
Layers
ui/theme design tokens (AntDesign, ElementPlus, Shadcn, Dark, derived palettes)
ui/layout flex/stack/absolute solver with two-axis measurement
ui/paint display list + Renderer interface + CPU rasterizer
ui/text shaping (go-text/typesetting), fallback fonts, line breaking
ui/input events, keys, IME composition, cursors, focus order
ui/icon built-in vector icons
ui Context, Runner, Driver, Window/Host contracts, components
Platform integration
A platform backend implements Window (size, scale, invalidation, cursor, clipboard, IME, Present) and Host (open a window bound to a Runner); see window.go for the exact contract. The headless Driver implements Window for tests and screenshots. See AUTHORING.md for writing components.
Accessibility
A window that also implements AccessibilityHost receives a semantics tree (package ui/a11y: roles, names, states, values, bounds, actions) after every frame that changed it, and forwards screen-reader requests through Runner.PerformAction. Nothing is built while the host reports accessibility disabled. Keyboard access (Tab order, roving arrow keys, focus traps in dialogs, focus return from popups), the reduced-motion preference (RunnerOptions.ReduceMotion) and theme contrast checks (theme.CheckContrast) complete the picture; docs/accessibility.md maps every role to NSAccessibility, UI Automation, AT-SPI, UIAccessibility and AccessibilityNodeInfo.
API tiers: only the symbols listed in api/stable/ui.txt are covered by the compatibility promise of docs/release.md ("API 稳定性"); every other exported symbol is Experimental and may change in any 0.x release. The API reference on the documentation site marks the experimental symbols.
常量
const (
TreeDropBefore = -1
TreeDropInside = 0
TreeDropAfter = 1
)Tree drop positions reported by Dropped and accepted by TreeMove.
实验性
const (
AlignAuto = "auto"
AlignTop = "top"
AlignBottom = "bottom"
)Scroll alignments of Listy.ScrollToKey / ScrollToGroup.
实验性
const (
ValuePassword = "password"
ValueTextArea = "textarea"
ValueSelect = "select"
ValueMultiSelect = "multiSelect"
ValueRadio = "radio"
ValueRadioButton = "radioButton"
ValueCheckbox = "checkbox"
ValueSwitch = "switch"
ValueRate = "rate"
ValueSlider = "slider"
ValueSegmented = "segmented"
ValueDateRange = "dateRange"
ValueCascader = "cascader" // []string path; options: ValueEnum with Children
ValueTreeSelect = "treeSelect" // string; options: ValueEnum with Children
ValueUpload = "upload" // []UploadFile; ProField.Pick adds files
ValueTime = "time" // time.Time (time of day)
ValueTimeRange = "timeRange" // [2]time.Time
ValueColor = "color" // string "#RRGGBB" / "#RRGGBBAA"
ValueDigitRange = "digitRange" // [2]float64; an empty end is NaN
)Value types used by ProForm fields in addition to the ProTable ones (ValueText, ValueMoney, ValueDigit, ValuePercent, ValueDate, ValueDateTime, ValueStatus, ValueTag ...): one set describes both a column's display and a field's editor.
实验性
const (
ValueDateWeek = "dateWeek" // time.Time, shown as its week ("2026-46周")
ValueDateMonth = "dateMonth" // time.Time, shown as "2006-01"
ValueDateQuarter = "dateQuarter" // time.Time, shown as its quarter ("2026-Q4")
ValueDateYear = "dateYear" // time.Time, shown as "2006"
ValueDateTimeRange = "dateTimeRange" // [2]time.Time with the times of day
// ValueImage is an image.Image, []image.Image or UploadFile(s) with a
// Thumb; the editor is a one-picture Upload card (ProField.Pick adds).
ValueImage = "image"
// ValueAvatar is an image.Image (or UploadFile) or a name string (its
// first letter, edited as text); a picture is edited like image.
ValueAvatar = "avatar"
ValueCode = "code" // string in a monospace block
ValueJSONCode = "jsonCode" // JSON text (string / []byte) or any value, shown indented; validated when edited
ValueFromNow = "fromNow" // time.Time shown relative to now ("3 分钟前"); edited with a date-time picker
ValueSecond = "second" // number of seconds shown as a duration ("1 小时 5 秒")
ValueIndex = "index" // ProTable: the 1-based row number (the value is ignored)
// ValueCaptcha is a string code with a "get code" button and its
// countdown (ProField.OnCaptcha sends the code).
ValueCaptcha = "captcha"
// ValueFormList is a list of rows ([]ProValues) edited with Form.List;
// ProField.List gives the fields of a row.
ValueFormList = "formList"
)Value types of the third Pro round: date granularities, a date-time range, media (image, avatar), code, relative time, durations, row numbers, a verification code and nested lists. Like the others they describe both a field's editor and the read-only view in ProForm (readonly), ProField, ProTable and ProDescriptions.
实验性
const (
SplitVertical = "vertical" // children side by side, vertical dividers
SplitHorizontal = "horizontal" // children stacked, horizontal dividers
)Split directions of ProCard.Split.
实验性
const (
SkeletonList = "list"
SkeletonResult = "result"
SkeletonDescriptions = "descriptions"
)ProSkeleton page types.
实验性
const (
StatisticVertical = "vertical"
StatisticHorizontal = "horizontal"
StatisticInline = "inline"
)Statistic layouts of StatisticCard.StatisticLayout and ProStatistic.
实验性
const (
ChartBottom = "bottom"
ChartLeft = "left"
ChartRight = "right"
)Chart placements of StatisticCard.ChartPlace.
实验性
const (
LoginAccount = "account"
LoginMobile = "mobile"
)Login types of LoginForm (the "loginType" value).
实验性
const (
FixedLeft = "left"
FixedRight = "right"
)Fixed column sides (TableColumn.Fixed). They are logical, like Ant's RTL table: "left" is the start side (the right edge in an RTL scope) and "right" the end side.
const (
SelectionAll = "all" // select every selectable row (all pages of local data)
SelectionPage = "page" // select the rows of the current page
SelectionInvert = "invert" // invert the selection of the current page
SelectionNone = "none" // clear the whole selection
)Built-in selection menu items (TableSelection.Key) of Selections.
实验性
const (
PageTopStart = "topStart"
PageTopCenter = "topCenter"
PageTopEnd = "topEnd"
PageBottomStart = "bottomStart"
PageBottomCenter = "bottomCenter"
PageBottomEnd = "bottomEnd" // default
PageNone = "none"
)Pagination placements (PaginationPlacement), Ant Design 6 pagination.placement.
实验性
const (
ValueText = "text"
ValueMoney = "money"
ValueDigit = "digit"
ValuePercent = "percent"
ValueDate = "date"
ValueDateTime = "dateTime"
ValueStatus = "status"
ValueTag = "tag"
ValueProgress = "progress"
ValueLink = "link"
ValueOption = "option" // action column: Render only, never searched
)Value types of ProColumn.ValueType.
实验性
const (
AlignLeft = AlignStart
AlignRight = AlignEnd
)AlignLeft and AlignRight are transitional aliases of AlignStart and AlignEnd, kept while existing call sites are audited (RTL spec §3.2): in LTR they behave exactly as before. Use AlignStart / AlignEnd for "start / end" and AlignPhysicalLeft / AlignPhysicalRight where the physical side is required; after the audit AlignLeft / AlignRight will become the physical values.
const DragSlop = 8DragSlop is how far (logical px) a press may travel before an enclosing container that accepts the movement direction takes the pointer over.
实验性
const FixedNone = "none"FixedNone unpins a column in TableColumnState.Fixed.
const GridContentFixedWidth = 1152GridContentFixedWidth is the content width of a Fixed GridContent.
实验性
const TopNavHeaderWideWidth = 1152TopNavHeaderWideWidth is Pro v3's Fixed top navigation content width.
实验性
变量
var (
EaseInOut = cubicBezier(0.645, 0.045, 0.355, 1)
EaseOut = cubicBezier(0.215, 0.61, 0.355, 1)
EaseIn = cubicBezier(0.55, 0.055, 0.675, 0.19)
)Ant Design motion curves.
实验性
var ButtonPresetColors = []ButtonColor{
ButtonColorBlue, ButtonColorPurple, ButtonColorCyan, ButtonColorGreen, ButtonColorMagenta,
ButtonColorPink, ButtonColorRed, ButtonColorOrange, ButtonColorYellow, ButtonColorVolcano,
ButtonColorGeekblue, ButtonColorLime, ButtonColorGold,
}ButtonPresetColors lists the Ant Design preset colors in display order.
实验性
var ContextMenuSource func(c *Context) (geom.Point, bool)ContextMenuSource is an extra context-menu gesture for platforms without a secondary button (e.g. a two-finger tap): when set, context-menu triggers (Dropdown with TriggerContextMenu) also open when it reports a point inside them. Right-button presses always work (they are read with Context.ContextMenuFor, which respects layers). Nil by default.
实验性
var EnUS = &Locale{
Code: "en-US", Name: "English",
OK: "OK", Cancel: "Cancel", Close: "Close", Confirm: "Confirm", Back: "Back", Clear: "Clear", Reset: "Reset",
Search: "Search", Save: "Save", Delete: "Delete", Edit: "Edit", Copy: "Copy", Copied: "Copied", More: "More",
Expand: "Expand", Collapse: "Collapse", SelectAll: "Select all", Loading: "Loading", Retry: "Retry", GotIt: "Got it",
NoData: "No data", NoMore: "No more", LoadMore: "Load more", LoadFailed: "Failed to load",
TotalFmt: "Total %d items", RangeTotalFmt: "%d-%d of %d items", PageSizeFmt: "%d / page",
PrevPage: "Previous Page", NextPage: "Next Page", Prev5: "Previous 5 Pages", Next5: "Next 5 Pages", JumpTo: "Go to", PageSuffix: "Page",
Placeholder: "Please enter", SelectPlaceholder: "Please select", Required: "This field is required", NotFound: "Not found",
LabelColon: ":", SelectedFmt: "%d selected",
Today: "Today", Now: "Now", SelectDate: "Select date", SelectTime: "Select time", SelectDateTime: "Select date and time",
StartDate: "Start date", EndDate: "End date",
PrevYear: "Previous year", NextYear: "Next year", PrevMonth: "Previous month", NextMonth: "Next month", RangeSeparator: "to",
YearFmt: "%d", MonthFmt: "%[2]s", YearMonthFmt: "%[3]s %[1]d",
Weekdays: [7]string{"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"},
Months: [12]string{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"},
WeekStart: time.Sunday,
FilterConfirm: "OK", FilterReset: "Reset", SortAsc: "Click to sort ascending", SortDesc: "Click to sort descending", CancelSort: "Click to cancel sorting",
SelectionAll: "Select all data", SelectionInvert: "Invert current page", ExpandRow: "Expand row", CollapseRow: "Collapse row",
ItemUnit: "item", ItemsUnit: "items", Searching: "Searching", Currency: "$",
MessageBoxTitle: "Message", Info: "Info", Success: "Success", Warning: "Warning", Error: "Error", BackTop: "Back to top",
CollapseMenu: "Collapse menu", ExpandMenu: "Expand menu", Fullscreen: "Fullscreen", ExitFullscreen: "Exit fullscreen",
PromptPlaceholder: "Please input", PromptInvalid: "Illegal input", CloseAll: "Close all", Steps: "Steps",
Calendar: CalendarLocale{Month: "Month", Year: "Year"},
Carousel: CarouselLocale{Prev: "Previous slide", Next: "Next slide"},
Image: ImageLocale{
Preview: "Preview", PreviewLabel: "Image preview", ClosePreview: "Close preview", Prev: "Previous image", Next: "Next image",
ZoomIn: "Zoom in", ZoomOut: "Zoom out", RotateLeft: "Rotate left", RotateRight: "Rotate right",
FlipHorizontal: "Flip horizontally", FlipVertical: "Flip vertically",
},
ColorPicker: ColorPickerLocale{Presets: "Recommended", None: "None", ClearColor: "Clear color", Clear: "Clear",
Saturation: "Saturation", Hue: "Hue", Alpha: "Alpha", Format: "Color format", Value: "Color value", Gradient: "Gradient stops", Angle: "Angle"},
Tour: TourLocale{Close: "Close tour", Prev: "Previous", Next: "Next", Finish: "Finish"},
Command: CommandLocale{Placeholder: "Type a command or search...", Empty: "No results found."},
QRCode: QRCodeLocale{Expired: "QR code expired", Refresh: "Refresh", Scanned: "Scanned"},
Table: TableLocale{FilterSearch: "Search in filters", FilterAll: "All", Filter: "Filter", FixedLeft: "Fixed to left", NoFixed: "Not fixed", FixedRight: "Fixed to right", PinLeft: "Pin to left", PinRight: "Pin to right", Unpin: "Unpin", SelectRowFmt: "Select row %d",
Selections: "Selection options", SelectPage: "Select current page", SelectNone: "Clear all data", SumText: "Sum"},
Mobile: MobileLocale{PullToRefresh: "Pull to refresh", ReleaseToRefresh: "Release to refresh", Refreshed: "Refreshed", TapToRetry: ", tap to retry", DayFmt: "%d", HourFmt: "%02d", MinuteFmt: "%02d"},
Graph: GraphLocale{Diagram: "Diagram", ER: "ER diagram", GitGraph: "Commit graph", ZoomIn: "Zoom in", ZoomOut: "Zoom out", FitView: "Fit view", AutoLayout: "Auto layout", MiniMap: "Minimap",
PrimaryKey: "Primary key", ForeignKey: "Foreign key", SummaryFmt: "%[1]d nodes, %[2]d edges", CommitsFmt: "%d commits"},
Chart: ChartLocale{Total: "Total", Conversion: "Conversion", Line: "Line chart", Area: "Area chart", Column: "Column chart", Bar: "Bar chart", Pie: "Pie chart", Donut: "Donut chart",
Scatter: "Scatter chart", Radar: "Radar chart", Gauge: "Gauge", Funnel: "Funnel chart", Heatmap: "Heatmap", DualAxes: "Dual axes chart",
Liquid: "Liquid gauge", Sparkline: "Sparkline",
SummaryFmt: "%[1]s, %[2]d series, %[3]d data points", XRangeFmt: "; x axis from %s to %s", YRangeFmt: "; values from %s to %s", ValueFmt: "%s: %s"},
ProTable: ProTableLocale{Query: "Query", Reload: "Refresh", Density: "Density",
DensityDefault: "Default", DensityMiddle: "Middle", DensityCompact: "Compact",
ColumnSetting: "Column settings", ColumnDisplay: "Columns", ClearSelection: "Clear selection", LoadErrorFmt: "Failed to load data: %s"},
Transfer: TransferLocale{Source: "Source", Target: "Target", SearchPlaceholder: "Search here"},
Upload: UploadLocale{Trigger: "Upload", Uploading: "Uploading", Remove: "Remove file", Preview: "Preview file",
Button: "Click to Upload", DragTitle: "Click or drag file to this area to upload", DropPrefix: "Drop file here or ",
DoneFmt: "%s uploaded", FailedFmt: "%s failed to upload", TooManyFmt: "%s: the list is full", BadTypeFmt: "%s: file type not accepted",
TooLargeFmt: "%s is larger than %s", IsDirFmt: "%s is a folder"},
Markdown: MarkdownLocale{ImagePrefix: "[Image] ", CopyCode: "Copy code", Copied: "Copied"},
MarkdownEditor: MarkdownEditorLocale{Placeholder: "Write Markdown here…",
Heading: "Heading", Bold: "Bold", Italic: "Italic", Strike: "Strikethrough", Code: "Code", Link: "Link", Quote: "Quote",
BulletList: "Bulleted list", OrderedList: "Numbered list", Task: "Task", CodeBlock: "Code block", Table: "Table", Divider: "Divider",
BoldSample: "bold text", ItalicSample: "italic text", StrikeSample: "deleted text", LinkSample: "link text", TableColumnFmt: "Column %d",
Edit: "Edit", Split: "Split", Preview: "Preview"},
Form: FormLocale{Validating: "Validating…", RequiredInputFmt: "Please enter %s", RequiredSelectFmt: "Please select %s", Submit: "Submit", Query: "Query", PrevStep: "Previous", NextStep: "Next", MoveUp: "Move up", MoveDown: "Move down", AddRow: "Add a row", Optional: "(optional)"},
A11y: A11yLocale{Navigation: "Navigation", Breadcrumb: "Breadcrumb", Pagination: "Pagination", Notifications: "Notifications", Toolbar: "Toolbar", Menu: "Menu",
PageFmt: "Page %d", MoreActions: "More actions", OpenMenu: "Open menu", Remove: "Remove", DragHandle: "Drag to reorder", Resize: "Resize", Splitter: "Splitter",
ShowPassword: "Show password", HidePassword: "Hide password", Increase: "Increase", Decrease: "Decrease",
Avatar: "Avatar", Image: "Image", Chart: "Chart", Progress: "Progress", Rating: "Rating", Color: "Color", Loading: "Loading",
SlideFmt: "Slide %d of %d", RateFmt: "%[1]g of %[2]d stars",
DateFmt: "%[4]s %[3]d, %[1]d", DigitFmt: "Character %d of %d", RemoveFmt: "Remove %s", Day: "Day", Hour: "Hour", Minute: "Minute", Second: "Second",
MoveToTarget: "Move to target", MoveToSource: "Move to source",
PageSize: "Items per page"},
DatePicker: DatePickerLocale{SelectWeek: "Select week", SelectMonth: "Select month", SelectQuarter: "Select quarter", SelectYear: "Select year",
StartWeek: "Start week", EndWeek: "End week", StartMonth: "Start month", EndMonth: "End month",
StartQuarter: "Start quarter", EndQuarter: "End quarter", StartYear: "Start year", EndYear: "End year",
PrevDecade: "Previous decade", NextDecade: "Next decade", WeekFmt: "%[1]d-%[2]d%[3]s", QuarterFmt: "%[1]d-Q%[2]d", QuarterCellFmt: "Q%d"},
TimePicker: TimePickerLocale{StartTime: "Start time", EndTime: "End time", AM: "AM", PM: "PM", Meridiem: "AM/PM"},
Tabs: TabsLocale{More: "More tabs", Add: "Add tab"},
Pagination: PaginationLocale{Jump: "Go to page", Current: "Current page", Confirm: "Confirm", Prev3: "Previous 3 Pages", Next3: "Next 3 Pages"},
Slider: SliderLocale{Min: "Minimum", Max: "Maximum"},
DropZone: DropZoneLocale{Name: "Drop zone", Release: "Release to drop the files here"},
EditableTable: EditableTableLocale{Actions: "Actions", DeleteConfirm: "Delete this row?"},
PageContainer: PageContainerLocale{FooterToolbar: "Page actions"},
ProCard: ProCardLocale{MoreInfo: "More info"},
StatisticCard: StatisticCardLocale{Up: "Up", Down: "Down"},
ProField: ProFieldLocale{On: "On", Off: "Off", StartFmt: "%s start", EndFmt: "%s end", Min: "Min", Max: "Max", RangeEndFmt: "%s: %s",
JustNow: "just now", AgoFmt: "%s ago", LaterFmt: "in %s", SecondFmt: "%d s", MinuteFmt: "%d min", HourFmt: "%d h", DayFmt: "%d d", MonthFmt: "%d mo", YearFmt: "%d yr", InvalidJSON: "Invalid JSON"},
ProDescriptions: ProDescriptionsLocale{EditFmt: "Edit %s"},
LightFilter: LightFilterLocale{Name: "Filter", ClearFmt: "Clear %s", PillFmt: "%s: %s", More: "More filters", MoreFmt: "More filters (%d)"},
LoginForm: LoginFormLocale{AccountTab: "Account", MobileTab: "Mobile",
Username: "Username", UsernameRequired: "Please enter your username", Password: "Password", PasswordRequired: "Please enter your password",
Mobile: "Mobile number", MobileRequired: "Please enter your mobile number", MobileInvalid: "Invalid mobile number",
Captcha: "Verification code", CaptchaRequired: "Please enter the code", GetCode: "Get code", ResendFmt: "Resend in %ds",
CodeSentFmt: "Code sent. You can resend it in %d seconds.", CodeReady: "You can request a new code now.",
Remember: "Remember me", Forgot: "Forgot password", Submit: "Log in", Others: "Other login methods"},
Chat: ChatLocale{User: "You", Assistant: "Assistant", System: "System", Messages: "Messages", ScrollToBottom: "Scroll to bottom",
Thinking: "Thinking", Generating: "Generating",
Placeholder: "Message… (Enter to send, Shift+Enter for a new line)", Send: "Send", Stop: "Stop generating", Attach: "Attach files",
Suggestions: "Suggestions", Uploading: "Uploading", Failed: "Upload failed", EditPlaceholder: "Edit message",
Pending: "Pending", Running: "Running", Done: "Done", Error: "Failed", StepsFmt: "%d/%d",
SecondsFmt: "%.1fs", MinutesFmt: "%dm %ds", ToolCall: "Tool call", Arguments: "Arguments", Result: "Result",
ApprovalTitle: "Approval required", AllowOnce: "Allow", AllowSession: "Allow for this chat", AllowAlways: "Always allow", Deny: "Deny",
Allowed: "Allowed", Denied: "Denied", FeedbackPlaceholder: "Add a note (optional)", RiskWarning: "Needs review", RiskDanger: "High risk",
Conversations: "Conversations", Rename: "Rename", Untitled: "Untitled chat", Today: "Today", Yesterday: "Yesterday",
Last7Days: "Previous 7 days", Last30Days: "Previous 30 days", Earlier: "Earlier", Prompts: "Prompts"},
SettingDrawer: SettingDrawerLocale{Open: "Open page settings", Title: "Page settings",
NavTheme: "Style", Light: "Light menu", Dark: "Dark menu", RealDark: "Dark mode",
PrimaryColor: "Theme color", Layout: "Navigation", Side: "Side menu", Top: "Top menu", Mix: "Mixed",
ContentWidth: "Content width", Fluid: "Fluid", Fixed: "Fixed",
FixedHeader: "Fixed header", FixSiderbar: "Fixed side menu", ColorWeak: "Color weak mode",
Other: "Other settings", Compact: "Compact", ColorFmt: "Theme color %s"},
CodeBlock: CodeBlockLocale{Code: "Code"},
JSONView: JSONViewLocale{Name: "JSON viewer", CopyValue: "Copy value", CopyPath: "Copy path", ExpandAll: "Expand all", CollapseAll: "Collapse all", ItemsFmt: "%d items", KeysFmt: "%d keys", Search: "Search keys or values", PrevMatch: "Previous match", NextMatch: "Next match", MatchFmt: "%d of %d", NoMatch: "No results", ParseErrorFmt: "Invalid JSON: %s"},
LogView: LogViewLocale{Name: "Log", Search: "Search log", PrevMatch: "Previous match", NextMatch: "Next match", MatchFmt: "%d of %d", NoMatch: "No results", Wrap: "Wrap lines", Follow: "Follow output", Level: "Level", AllLevels: "All levels", Levels: [5]string{"Trace", "Debug", "Info", "Warn", "Error"}, LinesFmt: "%d lines"},
StatusBar: StatusBarLocale{Label: "Status bar"},
TitleBar: TitleBarLocale{Minimize: "Minimize", Maximize: "Maximize", Restore: "Restore", WindowControls: "Window controls"},
NotificationCenter: NotificationCenterLocale{MarkAllRead: "Mark all as read", ClearAll: "Clear all", Dismiss: "Dismiss",
Empty: "No notifications", UnreadFmt: "%d unread", JustNow: "Just now", MinutesAgoFmt: "%dm ago", HoursAgoFmt: "%dh ago", DaysAgoFmt: "%dd ago"},
HotkeyInput: HotkeyInputLocale{Placeholder: "Click to record a shortcut", Recording: "Press a key combination, Esc to cancel", ClearLabel: "Clear shortcut"},
Dock: DockLocale{Maximize: "Maximize", Restore: "Restore", Split: "Split right", Empty: "Drag a tab here", Group: "Tab group"},
Extra: map[string]string{
"diffview.a11y.change": "Difference %d of %d: ",
"diffview.a11y.removed": "removed lines %s",
"diffview.a11y.inserted": "added lines %s",
"diffview.a11y.sep": ", ",
"diffview.a11y.range": "%d–%d",
"diffview.a11y.none": "No differences",
"diffview.hidden": "%d hidden lines",
"diffview.showAbove": "Show %d more lines above",
"diffview.showBelow": "Show %d more lines below",
"diffview.showAll": "Show all",
"diffview.original": "Original (read-only) — %s",
"diffview.originalEditable": "Original — %s",
"diffview.modified": "Modified — %s",
"diffview.revert": "Revert this change",
"diffview.unnamed": "Untitled",
},
}EnUS is the US English locale. RegisterLocale fills the empty texts of every other locale from it.
var ErrQRTooLong = errors.New("ui: qrcode data too long")ErrQRTooLong is returned when the data exceeds version 40 capacity.
实验性
var Ja = &Locale{
Code: "ja-JP", Name: "日本語",
OK: "OK", Cancel: "キャンセル", Close: "閉じる", Confirm: "確認", Back: "戻る", Clear: "クリア", Reset: "リセット",
Search: "検索", Save: "保存", Delete: "削除", Edit: "編集", Copy: "コピー", Copied: "コピーしました", More: "その他",
Expand: "展開", Collapse: "折りたたむ", SelectAll: "すべて選択", Loading: "読み込み中", Retry: "再試行", GotIt: "了解",
NoData: "データがありません", NoMore: "これ以上ありません", LoadMore: "さらに読み込む", LoadFailed: "読み込みに失敗しました",
TotalFmt: "全 %d 件", RangeTotalFmt: "%d-%d 件 / 全 %d 件", PageSizeFmt: "%d 件/ページ",
PrevPage: "前のページ", NextPage: "次のページ", Prev5: "前の 5 ページ", Next5: "次の 5 ページ", JumpTo: "移動", PageSuffix: "ページ",
Placeholder: "入力してください", SelectPlaceholder: "選択してください", Required: "必須項目です", NotFound: "見つかりません",
LabelColon: ":", SelectedFmt: "%d 件選択中",
Today: "今日", Now: "現在", SelectDate: "日付を選択", SelectTime: "時刻を選択", SelectDateTime: "日時を選択",
StartDate: "開始日", EndDate: "終了日",
PrevYear: "前年", NextYear: "翌年", PrevMonth: "前月", NextMonth: "翌月", RangeSeparator: "〜",
YearFmt: "%d年", MonthFmt: "%d月", YearMonthFmt: "%d年%d月",
Weekdays: [7]string{"日", "月", "火", "水", "木", "金", "土"},
Months: [12]string{"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"},
WeekStart: time.Sunday,
FilterConfirm: "OK", FilterReset: "リセット", SortAsc: "クリックで昇順", SortDesc: "クリックで降順", CancelSort: "ソートを解除",
SelectionAll: "すべてを選択", SelectionInvert: "このページを反転", ExpandRow: "行を展開", CollapseRow: "行を折りたたむ",
ItemUnit: "件", ItemsUnit: "件", Searching: "検索中", Currency: "JPY",
MessageBoxTitle: "メッセージ", Info: "情報", Success: "成功", Warning: "警告", Error: "エラー", BackTop: "トップへ戻る",
CollapseMenu: "メニューを折りたたむ", ExpandMenu: "メニューを展開", Fullscreen: "全画面表示", ExitFullscreen: "全画面表示を終了",
PromptPlaceholder: "入力してください", PromptInvalid: "入力が正しくありません", CloseAll: "すべて閉じる", Steps: "ステップ",
Calendar: CalendarLocale{Month: "月", Year: "年"},
Carousel: CarouselLocale{Prev: "前のスライド", Next: "次のスライド"},
Image: ImageLocale{
Preview: "プレビュー", PreviewLabel: "画像プレビュー", ClosePreview: "プレビューを閉じる", Prev: "前の画像", Next: "次の画像",
ZoomIn: "拡大", ZoomOut: "縮小", RotateLeft: "左に回転", RotateRight: "右に回転",
FlipHorizontal: "左右反転", FlipVertical: "上下反転",
},
ColorPicker: ColorPickerLocale{Presets: "おすすめ", None: "なし", ClearColor: "色をクリア", Clear: "クリア",
Saturation: "彩度", Hue: "色相", Alpha: "透明度", Format: "カラー形式", Value: "カラー値", Gradient: "グラデーションの色標", Angle: "角度"},
Tour: TourLocale{Close: "ツアーを閉じる", Prev: "前へ", Next: "次へ", Finish: "完了"},
Command: CommandLocale{Placeholder: "コマンドを入力または検索…", Empty: "結果が見つかりません。"},
QRCode: QRCodeLocale{Expired: "期限切れ", Refresh: "更新", Scanned: "スキャン済み"},
Table: TableLocale{FilterSearch: "フィルターを検索", FilterAll: "すべて", Filter: "フィルター", FixedLeft: "左に固定", NoFixed: "固定なし", FixedRight: "右に固定", PinLeft: "先頭に固定", PinRight: "末尾に固定", Unpin: "固定を解除", SelectRowFmt: "%d 行目を選択",
Selections: "選択オプション", SelectPage: "このページを選択", SelectNone: "選択をすべて解除", SumText: "合計"},
Mobile: MobileLocale{PullToRefresh: "引っ張って更新", ReleaseToRefresh: "離すと更新", Refreshed: "更新しました", TapToRetry: "、タップして再試行", DayFmt: "%d日", HourFmt: "%02d時", MinuteFmt: "%02d分"},
Graph: GraphLocale{Diagram: "ダイアグラム", ER: "ER 図", GitGraph: "コミットグラフ", ZoomIn: "拡大", ZoomOut: "縮小", FitView: "全体表示", AutoLayout: "自動レイアウト", MiniMap: "ミニマップ",
PrimaryKey: "主キー", ForeignKey: "外部キー", SummaryFmt: "%[1]d 個のノード、%[2]d 本の接続", CommitsFmt: "%d 件のコミット"},
Chart: ChartLocale{Total: "合計", Conversion: "コンバージョン率", Line: "折れ線グラフ", Area: "面グラフ", Column: "縦棒グラフ", Bar: "横棒グラフ", Pie: "円グラフ", Donut: "ドーナツグラフ",
Scatter: "散布図", Radar: "レーダーチャート", Gauge: "ゲージ", Funnel: "ファネルチャート", Heatmap: "ヒートマップ", DualAxes: "2 軸グラフ",
Liquid: "リキッドゲージ", Sparkline: "スパークライン",
SummaryFmt: "%[1]s、%[2]d 系列、%[3]d データポイント", XRangeFmt: "、横軸 %s ~ %s", YRangeFmt: "、値 %s ~ %s", ValueFmt: "%s:%s"},
ProTable: ProTableLocale{Query: "検索", Reload: "更新", Density: "表示密度",
DensityDefault: "標準", DensityMiddle: "中", DensityCompact: "コンパクト",
ColumnSetting: "列の設定", ColumnDisplay: "列の表示", ClearSelection: "選択を解除", LoadErrorFmt: "データの読み込みに失敗しました:%s"},
Transfer: TransferLocale{Source: "ソース", Target: "ターゲット", SearchPlaceholder: "ここを検索"},
Upload: UploadLocale{Trigger: "アップロード", Uploading: "アップロード中", Remove: "ファイルを削除", Preview: "ファイルをプレビュー",
Button: "クリックしてアップロード", DragTitle: "クリックまたはドラッグしてアップロード", DropPrefix: "ここにファイルをドロップ、または",
DoneFmt: "%s をアップロードしました", FailedFmt: "%s のアップロードに失敗しました", TooManyFmt: "%s:ファイル数が上限に達しています", BadTypeFmt: "%s:この形式のファイルは使用できません",
TooLargeFmt: "%s は %s を超えています", IsDirFmt: "%s はフォルダーです"},
Markdown: MarkdownLocale{ImagePrefix: "[画像] ", CopyCode: "コードをコピー", Copied: "コピーしました"},
MarkdownEditor: MarkdownEditorLocale{Placeholder: "ここに Markdown を入力…",
Heading: "見出し", Bold: "太字", Italic: "斜体", Strike: "取り消し線", Code: "コード", Link: "リンク", Quote: "引用",
BulletList: "箇条書き", OrderedList: "番号付きリスト", Task: "タスク", CodeBlock: "コードブロック", Table: "表", Divider: "区切り線",
BoldSample: "太字テキスト", ItalicSample: "斜体テキスト", StrikeSample: "取り消しテキスト", LinkSample: "リンクテキスト", TableColumnFmt: "列 %d",
Edit: "編集", Split: "分割", Preview: "プレビュー"},
Form: FormLocale{Validating: "検証中…", RequiredInputFmt: "%sを入力してください", RequiredSelectFmt: "%sを選択してください", Submit: "送信", Query: "検索", PrevStep: "前へ", NextStep: "次へ", MoveUp: "上へ移動", MoveDown: "下へ移動", AddRow: "行を追加", Optional: "(オプション)"},
A11y: A11yLocale{Navigation: "ナビゲーション", Breadcrumb: "パンくずリスト", Pagination: "ページ送り", Notifications: "通知", Toolbar: "ツールバー", Menu: "メニュー",
PageFmt: "%d ページ", MoreActions: "その他の操作", OpenMenu: "メニューを開く", Remove: "削除", DragHandle: "ドラッグして並べ替え", Resize: "サイズ変更", Splitter: "分割バー",
ShowPassword: "パスワードを表示", HidePassword: "パスワードを隠す", Increase: "増やす", Decrease: "減らす",
Avatar: "アバター", Image: "画像", Chart: "グラフ", Progress: "進捗", Rating: "評価", Color: "色", Loading: "読み込み中",
SlideFmt: "スライド %d / %d", RateFmt: "%[2]d 点中 %[1]g 点",
DateFmt: "%d年%d月%d日", DigitFmt: "%d 文字目(全 %d 文字)", RemoveFmt: "%s を削除", Day: "日", Hour: "時", Minute: "分", Second: "秒",
MoveToTarget: "ターゲットへ移動", MoveToSource: "ソースへ戻す",
PageSize: "1 ページあたりの件数"},
DatePicker: DatePickerLocale{SelectWeek: "週を選択", SelectMonth: "月を選択", SelectQuarter: "四半期を選択", SelectYear: "年を選択",
StartWeek: "開始週", EndWeek: "終了週", StartMonth: "開始月", EndMonth: "終了月",
StartQuarter: "開始四半期", EndQuarter: "終了四半期", StartYear: "開始年", EndYear: "終了年",
PrevDecade: "前の10年", NextDecade: "次の10年", WeekFmt: "%[1]d-第%[2]d週", QuarterFmt: "%[1]d-Q%[2]d", QuarterCellFmt: "Q%d"},
TimePicker: TimePickerLocale{StartTime: "開始時間", EndTime: "終了時間", AM: "午前", PM: "午後", Meridiem: "午前/午後"},
Tabs: TabsLocale{More: "その他のタブ", Add: "タブを追加"},
Pagination: PaginationLocale{Jump: "ページを指定して移動", Current: "現在のページ", Confirm: "確認する", Prev3: "前の 3 ページ", Next3: "次の 3 ページ"},
Slider: SliderLocale{Min: "最小値", Max: "最大値"},
DropZone: DropZoneLocale{Name: "ドロップエリア", Release: "ここで離すとファイルをドロップします"},
EditableTable: EditableTableLocale{Actions: "操作", DeleteConfirm: "この行を削除しますか?"},
PageContainer: PageContainerLocale{FooterToolbar: "ページ操作"},
ProCard: ProCardLocale{MoreInfo: "詳細情報"},
StatisticCard: StatisticCardLocale{Up: "上昇", Down: "下降"},
ProField: ProFieldLocale{On: "オン", Off: "オフ", StartFmt: "%s(開始)", EndFmt: "%s(終了)", Min: "最小", Max: "最大", RangeEndFmt: "%s:%s",
JustNow: "たった今", AgoFmt: "%s前", LaterFmt: "%s後", SecondFmt: "%d 秒", MinuteFmt: "%d 分", HourFmt: "%d 時間", DayFmt: "%d 日", MonthFmt: "%d か月", YearFmt: "%d 年", InvalidJSON: "JSON の形式が正しくありません"},
ProDescriptions: ProDescriptionsLocale{EditFmt: "%sを編集"},
LightFilter: LightFilterLocale{Name: "フィルター", ClearFmt: "%sをクリア", PillFmt: "%s:%s", More: "その他のフィルター", MoreFmt: "その他のフィルター(%d)"},
LoginForm: LoginFormLocale{AccountTab: "アカウントでログイン", MobileTab: "携帯電話番号でログイン",
Username: "ユーザー名", UsernameRequired: "ユーザー名を入力してください", Password: "パスワード", PasswordRequired: "パスワードを入力してください",
Mobile: "携帯電話番号", MobileRequired: "携帯電話番号を入力してください", MobileInvalid: "携帯電話番号の形式が正しくありません",
Captcha: "認証コード", CaptchaRequired: "認証コードを入力してください", GetCode: "コードを取得", ResendFmt: "%d 秒後に再送信",
CodeSentFmt: "認証コードを送信しました。%d 秒後に再送信できます。", CodeReady: "認証コードを再送信できるようになりました。",
Remember: "ログイン状態を保持", Forgot: "パスワードをお忘れの方", Submit: "ログイン", Others: "その他のログイン方法"},
Chat: ChatLocale{User: "あなた", Assistant: "アシスタント", System: "システム", Messages: "メッセージ一覧", ScrollToBottom: "最新へ移動",
Thinking: "考え中", Generating: "生成中",
Placeholder: "メッセージを入力(Enter で送信、Shift+Enter で改行)", Send: "送信", Stop: "生成を停止", Attach: "ファイルを添付",
Suggestions: "候補", Uploading: "アップロード中", Failed: "アップロード失敗", EditPlaceholder: "メッセージを編集",
Pending: "待機中", Running: "実行中", Done: "完了", Error: "失敗", StepsFmt: "%d/%d",
SecondsFmt: "%.1f 秒", MinutesFmt: "%d 分 %d 秒", ToolCall: "ツール呼び出し", Arguments: "引数", Result: "結果",
ApprovalTitle: "確認が必要です", AllowOnce: "許可", AllowSession: "この会話で許可", AllowAlways: "常に許可", Deny: "拒否",
Allowed: "許可済み", Denied: "拒否済み", FeedbackPlaceholder: "補足(任意)", RiskWarning: "要確認", RiskDanger: "高リスク",
Conversations: "会話一覧", Rename: "名前を変更", Untitled: "無題の会話", Today: "今日", Yesterday: "昨日",
Last7Days: "過去 7 日間", Last30Days: "過去 30 日間", Earlier: "それ以前", Prompts: "プロンプト"},
SettingDrawer: SettingDrawerLocale{Open: "ページ設定を開く", Title: "ページ設定",
NavTheme: "テーマ", Light: "ライトメニュー", Dark: "ダークメニュー", RealDark: "ダークモード",
PrimaryColor: "テーマカラー", Layout: "ナビゲーション", Side: "サイドメニュー", Top: "トップメニュー", Mix: "ミックス",
ContentWidth: "コンテンツ幅", Fluid: "可変", Fixed: "固定",
FixedHeader: "ヘッダーを固定", FixSiderbar: "サイドメニューを固定", ColorWeak: "色覚サポート",
Other: "その他の設定", Compact: "コンパクト", ColorFmt: "テーマカラー %s"},
CodeBlock: CodeBlockLocale{Code: "コード"},
JSONView: JSONViewLocale{Name: "JSON ビューア", CopyValue: "値をコピー", CopyPath: "パスをコピー", ExpandAll: "すべて展開", CollapseAll: "すべて折りたたむ", ItemsFmt: "%d 項目", KeysFmt: "%d 個のキー", Search: "キーまたは値を検索", PrevMatch: "前の一致", NextMatch: "次の一致", MatchFmt: "%d/%d", NoMatch: "一致なし", ParseErrorFmt: "JSON を解析できません: %s"},
LogView: LogViewLocale{Name: "ログ", Search: "ログを検索", PrevMatch: "前の一致", NextMatch: "次の一致", MatchFmt: "%d/%d", NoMatch: "一致なし", Wrap: "折り返し", Follow: "最新を追跡", Level: "レベル", AllLevels: "すべてのレベル", Levels: [5]string{"Trace", "Debug", "Info", "Warn", "Error"}, LinesFmt: "%d 行"},
StatusBar: StatusBarLocale{Label: "ステータスバー"},
TitleBar: TitleBarLocale{Minimize: "最小化", Maximize: "最大化", Restore: "元に戻す", WindowControls: "ウィンドウ操作"},
NotificationCenter: NotificationCenterLocale{MarkAllRead: "すべて既読にする", ClearAll: "すべてクリア", Dismiss: "通知を削除",
Empty: "通知はありません", UnreadFmt: "未読 %d 件", JustNow: "たった今", MinutesAgoFmt: "%d 分前", HoursAgoFmt: "%d 時間前", DaysAgoFmt: "%d 日前"},
HotkeyInput: HotkeyInputLocale{Placeholder: "クリックしてショートカットを記録", Recording: "キーの組み合わせを押してください(Esc で取消)", ClearLabel: "ショートカットをクリア"},
Dock: DockLocale{Maximize: "最大化", Restore: "元に戻す", Split: "右に分割", Empty: "ここにタブをドラッグ", Group: "タブグループ"},
}Ja is the Japanese locale.
var MessageDuration = 3 * time.SecondMessageDuration is how long Message toasts stay visible by default.
实验性
var NotifyStackThreshold = 3NotifyStackThreshold is the count above which cards collapse into a stack until hovered (Ant stack mode). 0 disables stacking.
实验性
var ProSettingsPresetColors = []theme.Color{
theme.Hex("#1677ff"), theme.Hex("#1890ff"), theme.Hex("#f5222d"), theme.Hex("#fa541c"), theme.Hex("#faad14"),
theme.Hex("#13c2c2"), theme.Hex("#52c41a"), theme.Hex("#2f54eb"), theme.Hex("#722ed1"),
}ProSettingsPresetColors are the theme colors offered by SettingDrawer (Pro's daybreak, dust, volcano, sunset, cyan, green, geekblue, purple).
实验性
var ZhCN = &Locale{
Code: "zh-CN", Name: "简体中文",
OK: "确定", Cancel: "取消", Close: "关闭", Confirm: "确认", Back: "返回", Clear: "清除", Reset: "重置",
Search: "搜索", Save: "保存", Delete: "删除", Edit: "编辑", Copy: "复制", Copied: "复制成功", More: "更多",
Expand: "展开", Collapse: "收起", SelectAll: "全选", Loading: "加载中", Retry: "重试", GotIt: "知道了",
NoData: "暂无数据", NoMore: "没有更多了", LoadMore: "加载更多", LoadFailed: "加载失败",
TotalFmt: "共 %d 条", RangeTotalFmt: "第 %d-%d 条/共 %d 条", PageSizeFmt: "%d 条/页",
PrevPage: "上一页", NextPage: "下一页", Prev5: "向前 5 页", Next5: "向后 5 页", JumpTo: "跳至", PageSuffix: "页",
Placeholder: "请输入", SelectPlaceholder: "请选择", Required: "此项为必填项", NotFound: "无匹配数据",
LabelColon: ":", SelectedFmt: "已选择 %d 项",
Today: "今天", Now: "此刻", SelectDate: "请选择日期", SelectTime: "请选择时间", SelectDateTime: "请选择日期时间",
StartDate: "开始日期", EndDate: "结束日期",
PrevYear: "上一年", NextYear: "下一年", PrevMonth: "上个月", NextMonth: "下个月", RangeSeparator: "至",
YearFmt: "%d年", MonthFmt: "%d月", YearMonthFmt: "%d年%d月",
Weekdays: [7]string{"日", "一", "二", "三", "四", "五", "六"},
Months: [12]string{"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"},
WeekStart: time.Sunday,
FilterConfirm: "确定", FilterReset: "重置", SortAsc: "点击升序", SortDesc: "点击降序", CancelSort: "取消排序",
SelectionAll: "全选所有", SelectionInvert: "反选当页", ExpandRow: "展开行", CollapseRow: "关闭行",
ItemUnit: "项", ItemsUnit: "项", Searching: "搜索中", Currency: "¥",
MessageBoxTitle: "提示", Info: "提示", Success: "成功", Warning: "警告", Error: "错误", BackTop: "回到顶部",
CollapseMenu: "折叠菜单", ExpandMenu: "展开菜单", Fullscreen: "全屏", ExitFullscreen: "退出全屏",
PromptPlaceholder: "请输入内容", PromptInvalid: "输入的数据不合法", CloseAll: "全部关闭", Steps: "步骤",
Calendar: CalendarLocale{Month: "月", Year: "年"},
Carousel: CarouselLocale{Prev: "上一张", Next: "下一张"},
Image: ImageLocale{
Preview: "预览", PreviewLabel: "预览图片", ClosePreview: "关闭预览", Prev: "上一张", Next: "下一张",
ZoomIn: "放大", ZoomOut: "缩小", RotateLeft: "向左旋转", RotateRight: "向右旋转",
FlipHorizontal: "左右翻转", FlipVertical: "上下翻转",
},
ColorPicker: ColorPickerLocale{Presets: "推荐", None: "无", ClearColor: "清除颜色", Clear: "清空",
Saturation: "饱和度", Hue: "色相", Alpha: "透明度", Format: "颜色格式", Value: "颜色值", Gradient: "渐变色标", Angle: "角度"},
Tour: TourLocale{Close: "关闭引导", Prev: "上一步", Next: "下一步", Finish: "结束导览"},
Command: CommandLocale{Placeholder: "输入命令或搜索…", Empty: "没有找到结果。"},
QRCode: QRCodeLocale{Expired: "二维码过期", Refresh: "点击刷新", Scanned: "已扫描"},
Table: TableLocale{FilterSearch: "在筛选项中搜索", FilterAll: "全部", Filter: "筛选", FixedLeft: "固定在左侧", NoFixed: "不固定", FixedRight: "固定在右侧", PinLeft: "固定在列首", PinRight: "固定在列尾", Unpin: "不固定", SelectRowFmt: "选择第 %d 行",
Selections: "选择选项", SelectPage: "选择当页", SelectNone: "清空所有", SumText: "合计"},
Mobile: MobileLocale{PullToRefresh: "下拉刷新", ReleaseToRefresh: "释放立即刷新", Refreshed: "刷新成功", TapToRetry: ",点击重试", DayFmt: "%d日", HourFmt: "%02d时", MinuteFmt: "%02d分"},
Graph: GraphLocale{Diagram: "关系图", ER: "ER 图", GitGraph: "提交图", ZoomIn: "放大", ZoomOut: "缩小", FitView: "适应视图", AutoLayout: "自动布局", MiniMap: "小地图",
PrimaryKey: "主键", ForeignKey: "外键", SummaryFmt: "%[1]d 个节点,%[2]d 条连线", CommitsFmt: "%d 个提交"},
Chart: ChartLocale{Total: "总计", Conversion: "转化率", Line: "折线图", Area: "面积图", Column: "柱状图", Bar: "条形图", Pie: "饼图", Donut: "环形图", Scatter: "散点图", Radar: "雷达图",
Gauge: "仪表盘", Funnel: "漏斗图", Heatmap: "热力图", DualAxes: "双轴图", Liquid: "水波图", Sparkline: "迷你图",
SummaryFmt: "%[1]s,%[2]d 个系列,%[3]d 个数据点", XRangeFmt: ";横轴从 %s 到 %s", YRangeFmt: ";数值从 %s 到 %s", ValueFmt: "%s:%s"},
ProTable: ProTableLocale{Query: "查询", Reload: "刷新", Density: "密度",
DensityDefault: "默认", DensityMiddle: "中等", DensityCompact: "紧凑",
ColumnSetting: "列设置", ColumnDisplay: "列展示", ClearSelection: "取消选择", LoadErrorFmt: "数据加载失败:%s"},
Transfer: TransferLocale{Source: "源列表", Target: "目标列表", SearchPlaceholder: "请输入搜索内容"},
Upload: UploadLocale{Trigger: "上传", Uploading: "文件上传中", Remove: "删除文件", Preview: "预览文件",
Button: "点击上传", DragTitle: "点击或将文件拖拽到这里上传", DropPrefix: "将文件拖到此处,或",
DoneFmt: "%s 上传成功", FailedFmt: "%s 上传失败", TooManyFmt: "%s:文件数量已达上限", BadTypeFmt: "%s:不支持该文件类型",
TooLargeFmt: "%s 超过 %s", IsDirFmt: "%s 是文件夹"},
Markdown: MarkdownLocale{ImagePrefix: "[图片] ", CopyCode: "复制代码", Copied: "已复制"},
MarkdownEditor: MarkdownEditorLocale{Placeholder: "在此输入 Markdown……",
Heading: "标题", Bold: "粗体", Italic: "斜体", Strike: "删除线", Code: "代码", Link: "链接", Quote: "引用",
BulletList: "无序列表", OrderedList: "有序列表", Task: "任务", CodeBlock: "代码块", Table: "表格", Divider: "分割线",
BoldSample: "粗体文字", ItalicSample: "斜体文字", StrikeSample: "删除文字", LinkSample: "链接文字", TableColumnFmt: "列 %d",
Edit: "编辑", Split: "分屏", Preview: "预览"},
Form: FormLocale{Validating: "校验中…", RequiredInputFmt: "请输入%s", RequiredSelectFmt: "请选择%s", Submit: "提交", Query: "查询", PrevStep: "上一步", NextStep: "下一步", MoveUp: "上移", MoveDown: "下移", AddRow: "添加一行数据", Optional: "(可选)"},
A11y: A11yLocale{Navigation: "导航", Breadcrumb: "面包屑", Pagination: "分页", Notifications: "通知", Toolbar: "工具栏", Menu: "菜单",
PageFmt: "第 %d 页", MoreActions: "更多操作", OpenMenu: "打开菜单", Remove: "移除", DragHandle: "拖动排序", Resize: "调整大小", Splitter: "分隔条",
ShowPassword: "显示密码", HidePassword: "隐藏密码", Increase: "增加", Decrease: "减少",
Avatar: "头像", Image: "图片", Chart: "图表", Progress: "进度", Rating: "评分", Color: "颜色", Loading: "加载中",
SlideFmt: "第 %d 张,共 %d 张", RateFmt: "%[1]g 星,共 %[2]d 星",
DateFmt: "%d年%d月%d日", DigitFmt: "第 %d 位,共 %d 位", RemoveFmt: "移除 %s", Day: "日", Hour: "时", Minute: "分", Second: "秒",
MoveToTarget: "移到目标列表", MoveToSource: "移回源列表",
PageSize: "每页条数"},
DatePicker: DatePickerLocale{SelectWeek: "请选择周", SelectMonth: "请选择月份", SelectQuarter: "请选择季度", SelectYear: "请选择年份",
StartWeek: "开始周", EndWeek: "结束周", StartMonth: "开始月份", EndMonth: "结束月份",
StartQuarter: "开始季度", EndQuarter: "结束季度", StartYear: "开始年份", EndYear: "结束年份",
PrevDecade: "上一年代", NextDecade: "下一年代", WeekFmt: "%[1]d-第%[2]d周", QuarterFmt: "%[1]d-Q%[2]d", QuarterCellFmt: "Q%d"},
TimePicker: TimePickerLocale{StartTime: "开始时间", EndTime: "结束时间", AM: "上午", PM: "下午", Meridiem: "上午/下午"},
Tabs: TabsLocale{More: "更多标签页", Add: "添加标签页"},
Pagination: PaginationLocale{Jump: "跳转页码", Current: "当前页", Confirm: "确定", Prev3: "向前 3 页", Next3: "向后 3 页"},
Slider: SliderLocale{Min: "最小值", Max: "最大值"},
DropZone: DropZoneLocale{Name: "拖放区域", Release: "松开即可把文件放到这里"},
EditableTable: EditableTableLocale{Actions: "操作", DeleteConfirm: "删除此行?"},
PageContainer: PageContainerLocale{FooterToolbar: "页面操作"},
ProCard: ProCardLocale{MoreInfo: "更多信息"},
StatisticCard: StatisticCardLocale{Up: "上升", Down: "下降"},
ProField: ProFieldLocale{On: "开", Off: "关", StartFmt: "%s开始", EndFmt: "%s结束", Min: "最小值", Max: "最大值", RangeEndFmt: "%s:%s",
JustNow: "刚刚", AgoFmt: "%s前", LaterFmt: "%s后", SecondFmt: "%d 秒", MinuteFmt: "%d 分钟", HourFmt: "%d 小时", DayFmt: "%d 天", MonthFmt: "%d 个月", YearFmt: "%d 年", InvalidJSON: "JSON 格式错误"},
ProDescriptions: ProDescriptionsLocale{EditFmt: "编辑%s"},
LightFilter: LightFilterLocale{Name: "筛选", ClearFmt: "清除%s", PillFmt: "%s:%s", More: "更多筛选", MoreFmt: "更多筛选(%d)"},
LoginForm: LoginFormLocale{AccountTab: "账户密码登录", MobileTab: "手机号登录",
Username: "用户名", UsernameRequired: "请输入用户名", Password: "密码", PasswordRequired: "请输入密码",
Mobile: "手机号", MobileRequired: "请输入手机号", MobileInvalid: "手机号格式错误",
Captcha: "验证码", CaptchaRequired: "请输入验证码", GetCode: "获取验证码", ResendFmt: "%d 秒后重新获取",
CodeSentFmt: "验证码已发送,%d 秒后可重新获取。", CodeReady: "现在可以重新获取验证码。",
Remember: "自动登录", Forgot: "忘记密码", Submit: "登录", Others: "其他登录方式"},
Chat: ChatLocale{User: "我", Assistant: "助手", System: "系统", Messages: "消息列表", ScrollToBottom: "回到底部",
Thinking: "正在思考", Generating: "正在生成",
Placeholder: "输入消息,Enter 发送,Shift+Enter 换行", Send: "发送", Stop: "停止生成", Attach: "添加附件",
Suggestions: "建议", Uploading: "上传中", Failed: "上传失败", EditPlaceholder: "编辑消息",
Pending: "等待中", Running: "进行中", Done: "已完成", Error: "失败", StepsFmt: "%d/%d",
SecondsFmt: "%.1f 秒", MinutesFmt: "%d 分 %d 秒", ToolCall: "工具调用", Arguments: "参数", Result: "结果",
ApprovalTitle: "需要你的确认", AllowOnce: "允许", AllowSession: "本次会话允许", AllowAlways: "总是允许", Deny: "拒绝",
Allowed: "已允许", Denied: "已拒绝", FeedbackPlaceholder: "补充说明(可选)", RiskWarning: "需确认", RiskDanger: "高风险",
Conversations: "会话列表", Rename: "重命名", Untitled: "未命名对话", Today: "今天", Yesterday: "昨天",
Last7Days: "近 7 天", Last30Days: "近 30 天", Earlier: "更早", Prompts: "提示词"},
SettingDrawer: SettingDrawerLocale{Open: "打开页面设置", Title: "页面设置",
NavTheme: "整体风格", Light: "亮色菜单", Dark: "暗色菜单", RealDark: "暗色模式",
PrimaryColor: "主题色", Layout: "导航模式", Side: "侧边菜单", Top: "顶部菜单", Mix: "混合菜单",
ContentWidth: "内容区域宽度", Fluid: "流式", Fixed: "定宽",
FixedHeader: "固定顶栏", FixSiderbar: "固定侧边菜单", ColorWeak: "色弱模式",
Other: "其他设置", Compact: "紧凑模式", ColorFmt: "主题色 %s"},
CodeBlock: CodeBlockLocale{Code: "代码"},
JSONView: JSONViewLocale{Name: "JSON 查看器", CopyValue: "复制值", CopyPath: "复制路径", ExpandAll: "全部展开", CollapseAll: "全部折叠", ItemsFmt: "%d 项", KeysFmt: "%d 个键", Search: "搜索键或值", PrevMatch: "上一个匹配", NextMatch: "下一个匹配", MatchFmt: "%d/%d", NoMatch: "无匹配", ParseErrorFmt: "JSON 解析失败:%s"},
LogView: LogViewLocale{Name: "日志", Search: "搜索日志", PrevMatch: "上一个匹配", NextMatch: "下一个匹配", MatchFmt: "%d/%d", NoMatch: "无匹配", Wrap: "自动换行", Follow: "跟随最新", Level: "级别", AllLevels: "全部级别", Levels: [5]string{"Trace", "Debug", "Info", "Warn", "Error"}, LinesFmt: "%d 行"},
StatusBar: StatusBarLocale{Label: "状态栏"},
TitleBar: TitleBarLocale{Minimize: "最小化", Maximize: "最大化", Restore: "向下还原", WindowControls: "窗口控制"},
NotificationCenter: NotificationCenterLocale{MarkAllRead: "全部标为已读", ClearAll: "清空通知", Dismiss: "移除通知",
Empty: "暂无通知", UnreadFmt: "%d 条未读", JustNow: "刚刚", MinutesAgoFmt: "%d 分钟前", HoursAgoFmt: "%d 小时前", DaysAgoFmt: "%d 天前"},
HotkeyInput: HotkeyInputLocale{Placeholder: "点击录制快捷键", Recording: "请按下组合键,Esc 取消", ClearLabel: "清除快捷键"},
Dock: DockLocale{Maximize: "最大化", Restore: "还原", Split: "向右拆分", Empty: "将标签页拖到这里", Group: "标签组"},
}ZhCN is the Simplified Chinese locale (default).
var ZhTW = &Locale{
Code: "zh-TW", Name: "繁體中文",
OK: "確定", Cancel: "取消", Close: "關閉", Confirm: "確認", Back: "返回", Clear: "清除", Reset: "重設",
Search: "搜尋", Save: "儲存", Delete: "刪除", Edit: "編輯", Copy: "複製", Copied: "已複製", More: "更多",
Expand: "展開", Collapse: "收合", SelectAll: "全選", Loading: "載入中", Retry: "重試", GotIt: "知道了",
NoData: "暫無資料", NoMore: "沒有更多了", LoadMore: "載入更多", LoadFailed: "載入失敗",
TotalFmt: "共 %d 筆", RangeTotalFmt: "第 %d-%d 筆/共 %d 筆", PageSizeFmt: "%d 筆/頁",
PrevPage: "上一頁", NextPage: "下一頁", Prev5: "向前 5 頁", Next5: "向後 5 頁", JumpTo: "跳至", PageSuffix: "頁",
Placeholder: "請輸入", SelectPlaceholder: "請選擇", Required: "此欄位為必填", NotFound: "無符合資料",
LabelColon: ":", SelectedFmt: "已選擇 %d 項",
Today: "今天", Now: "此刻", SelectDate: "請選擇日期", SelectTime: "請選擇時間", SelectDateTime: "請選擇日期時間",
StartDate: "開始日期", EndDate: "結束日期",
PrevYear: "上一年", NextYear: "下一年", PrevMonth: "上個月", NextMonth: "下個月", RangeSeparator: "至",
YearFmt: "%d年", MonthFmt: "%d月", YearMonthFmt: "%d年%d月",
Weekdays: [7]string{"日", "一", "二", "三", "四", "五", "六"},
Months: [12]string{"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"},
WeekStart: time.Sunday,
FilterConfirm: "確定", FilterReset: "重設", SortAsc: "點擊升序", SortDesc: "點擊降序", CancelSort: "取消排序",
SelectionAll: "全部選取", SelectionInvert: "反向選取", ExpandRow: "展開列", CollapseRow: "收合列",
ItemUnit: "項", ItemsUnit: "項", Searching: "搜尋中", Currency: "NT$",
MessageBoxTitle: "提示", Info: "提示", Success: "成功", Warning: "警告", Error: "錯誤", BackTop: "回到頂端",
CollapseMenu: "收合選單", ExpandMenu: "展開選單", Fullscreen: "全螢幕", ExitFullscreen: "離開全螢幕",
PromptPlaceholder: "請輸入內容", PromptInvalid: "輸入的資料不合法", CloseAll: "全部關閉", Steps: "步驟",
Calendar: CalendarLocale{Month: "月", Year: "年"},
Carousel: CarouselLocale{Prev: "上一張", Next: "下一張"},
Image: ImageLocale{
Preview: "預覽", PreviewLabel: "預覽圖片", ClosePreview: "關閉預覽", Prev: "上一張", Next: "下一張",
ZoomIn: "放大", ZoomOut: "縮小", RotateLeft: "向左旋轉", RotateRight: "向右旋轉",
FlipHorizontal: "左右翻轉", FlipVertical: "上下翻轉",
},
ColorPicker: ColorPickerLocale{Presets: "推薦", None: "無", ClearColor: "清除顏色", Clear: "清空",
Saturation: "飽和度", Hue: "色相", Alpha: "透明度", Format: "色彩格式", Value: "色彩值", Gradient: "漸層色標", Angle: "角度"},
Tour: TourLocale{Close: "關閉導覽", Prev: "上一步", Next: "下一步", Finish: "結束導覽"},
Command: CommandLocale{Placeholder: "輸入指令或搜尋…", Empty: "找不到結果。"},
QRCode: QRCodeLocale{Expired: "QR 碼已過期", Refresh: "點擊重新整理", Scanned: "已掃描"},
Table: TableLocale{FilterSearch: "在篩選項目中搜尋", FilterAll: "全部", Filter: "篩選", FixedLeft: "固定在左側", NoFixed: "不固定", FixedRight: "固定在右側", PinLeft: "固定在列首", PinRight: "固定在列尾", Unpin: "不固定", SelectRowFmt: "選擇第 %d 列",
Selections: "選取選項", SelectPage: "選取本頁", SelectNone: "清除所有選取", SumText: "合計"},
Mobile: MobileLocale{PullToRefresh: "下拉重新整理", ReleaseToRefresh: "放開立即重新整理", Refreshed: "重新整理成功", TapToRetry: ",點擊重試", DayFmt: "%d日", HourFmt: "%02d時", MinuteFmt: "%02d分"},
Graph: GraphLocale{Diagram: "關係圖", ER: "ER 圖", GitGraph: "提交圖", ZoomIn: "放大", ZoomOut: "縮小", FitView: "適應視圖", AutoLayout: "自動配置", MiniMap: "小地圖",
PrimaryKey: "主鍵", ForeignKey: "外鍵", SummaryFmt: "%[1]d 個節點,%[2]d 條連線", CommitsFmt: "%d 個提交"},
Chart: ChartLocale{Total: "總計", Conversion: "轉換率", Line: "折線圖", Area: "面積圖", Column: "直條圖", Bar: "橫條圖", Pie: "圓餅圖", Donut: "環形圖", Scatter: "散佈圖", Radar: "雷達圖",
Gauge: "儀表板", Funnel: "漏斗圖", Heatmap: "熱度圖", DualAxes: "雙軸圖", Liquid: "水波圖", Sparkline: "迷你圖",
SummaryFmt: "%[1]s,%[2]d 個數列,%[3]d 個資料點", XRangeFmt: ";橫軸從 %s 到 %s", YRangeFmt: ";數值從 %s 到 %s", ValueFmt: "%s:%s"},
ProTable: ProTableLocale{Query: "查詢", Reload: "重新整理", Density: "密度",
DensityDefault: "預設", DensityMiddle: "中等", DensityCompact: "緊湊",
ColumnSetting: "欄位設定", ColumnDisplay: "欄位顯示", ClearSelection: "取消選擇", LoadErrorFmt: "資料載入失敗:%s"},
Transfer: TransferLocale{Source: "來源清單", Target: "目的清單", SearchPlaceholder: "請輸入搜尋內容"},
Upload: UploadLocale{Trigger: "上傳", Uploading: "檔案上傳中", Remove: "刪除檔案", Preview: "預覽檔案",
Button: "點擊上傳", DragTitle: "點擊或將檔案拖曳到此區域上傳", DropPrefix: "將檔案拖到此處,或",
DoneFmt: "%s 上傳成功", FailedFmt: "%s 上傳失敗", TooManyFmt: "%s:檔案數量已達上限", BadTypeFmt: "%s:不支援此檔案類型",
TooLargeFmt: "%s 超過 %s", IsDirFmt: "%s 是資料夾"},
Markdown: MarkdownLocale{ImagePrefix: "[圖片] ", CopyCode: "複製程式碼", Copied: "已複製"},
MarkdownEditor: MarkdownEditorLocale{Placeholder: "在此輸入 Markdown……",
Heading: "標題", Bold: "粗體", Italic: "斜體", Strike: "刪除線", Code: "程式碼", Link: "連結", Quote: "引用",
BulletList: "項目清單", OrderedList: "編號清單", Task: "待辦", CodeBlock: "程式碼區塊", Table: "表格", Divider: "分隔線",
BoldSample: "粗體文字", ItalicSample: "斜體文字", StrikeSample: "刪除文字", LinkSample: "連結文字", TableColumnFmt: "欄 %d",
Edit: "編輯", Split: "分割", Preview: "預覽"},
Form: FormLocale{Validating: "驗證中…", RequiredInputFmt: "請輸入%s", RequiredSelectFmt: "請選擇%s", Submit: "提交", Query: "查詢", PrevStep: "上一步", NextStep: "下一步", MoveUp: "上移", MoveDown: "下移", AddRow: "新增一列資料", Optional: "(選填)"},
A11y: A11yLocale{Navigation: "導覽", Breadcrumb: "麵包屑", Pagination: "分頁", Notifications: "通知", Toolbar: "工具列", Menu: "選單",
PageFmt: "第 %d 頁", MoreActions: "更多操作", OpenMenu: "開啟選單", Remove: "移除", DragHandle: "拖曳排序", Resize: "調整大小", Splitter: "分隔線",
ShowPassword: "顯示密碼", HidePassword: "隱藏密碼", Increase: "增加", Decrease: "減少",
Avatar: "頭像", Image: "圖片", Chart: "圖表", Progress: "進度", Rating: "評分", Color: "顏色", Loading: "載入中",
SlideFmt: "第 %d 張,共 %d 張", RateFmt: "%[1]g 顆星,共 %[2]d 顆星",
DateFmt: "%d年%d月%d日", DigitFmt: "第 %d 位,共 %d 位", RemoveFmt: "移除 %s", Day: "日", Hour: "時", Minute: "分", Second: "秒",
MoveToTarget: "移到目標列表", MoveToSource: "移回來源列表",
PageSize: "每頁筆數"},
DatePicker: DatePickerLocale{SelectWeek: "請選擇週", SelectMonth: "請選擇月份", SelectQuarter: "請選擇季度", SelectYear: "請選擇年份",
StartWeek: "開始週", EndWeek: "結束週", StartMonth: "開始月份", EndMonth: "結束月份",
StartQuarter: "開始季度", EndQuarter: "結束季度", StartYear: "開始年份", EndYear: "結束年份",
PrevDecade: "上一個年代", NextDecade: "下一個年代", WeekFmt: "%[1]d-第%[2]d週", QuarterFmt: "%[1]d-Q%[2]d", QuarterCellFmt: "Q%d"},
TimePicker: TimePickerLocale{StartTime: "開始時間", EndTime: "結束時間", AM: "上午", PM: "下午", Meridiem: "上午/下午"},
Tabs: TabsLocale{More: "更多分頁", Add: "新增分頁"},
Pagination: PaginationLocale{Jump: "跳至頁碼", Current: "目前頁碼", Confirm: "確定", Prev3: "向前 3 頁", Next3: "向後 3 頁"},
Slider: SliderLocale{Min: "最小值", Max: "最大值"},
DropZone: DropZoneLocale{Name: "拖放區域", Release: "放開即可將檔案放到這裡"},
EditableTable: EditableTableLocale{Actions: "操作", DeleteConfirm: "確定刪除此列?"},
PageContainer: PageContainerLocale{FooterToolbar: "頁面操作"},
ProCard: ProCardLocale{MoreInfo: "更多資訊"},
StatisticCard: StatisticCardLocale{Up: "上升", Down: "下降"},
ProField: ProFieldLocale{On: "開", Off: "關", StartFmt: "%s開始", EndFmt: "%s結束", Min: "最小值", Max: "最大值", RangeEndFmt: "%s:%s",
JustNow: "剛剛", AgoFmt: "%s前", LaterFmt: "%s後", SecondFmt: "%d 秒", MinuteFmt: "%d 分鐘", HourFmt: "%d 小時", DayFmt: "%d 天", MonthFmt: "%d 個月", YearFmt: "%d 年", InvalidJSON: "JSON 格式錯誤"},
ProDescriptions: ProDescriptionsLocale{EditFmt: "編輯%s"},
LightFilter: LightFilterLocale{Name: "篩選", ClearFmt: "清除%s", PillFmt: "%s:%s", More: "更多篩選", MoreFmt: "更多篩選(%d)"},
LoginForm: LoginFormLocale{AccountTab: "帳號密碼登入", MobileTab: "手機號碼登入",
Username: "帳號", UsernameRequired: "請輸入帳號", Password: "密碼", PasswordRequired: "請輸入密碼",
Mobile: "手機號碼", MobileRequired: "請輸入手機號碼", MobileInvalid: "手機號碼格式錯誤",
Captcha: "驗證碼", CaptchaRequired: "請輸入驗證碼", GetCode: "取得驗證碼", ResendFmt: "%d 秒後重新取得",
CodeSentFmt: "驗證碼已傳送,%d 秒後可重新取得。", CodeReady: "現在可以重新取得驗證碼。",
Remember: "自動登入", Forgot: "忘記密碼", Submit: "登入", Others: "其他登入方式"},
Chat: ChatLocale{User: "我", Assistant: "助理", System: "系統", Messages: "訊息列表", ScrollToBottom: "回到底部",
Thinking: "正在思考", Generating: "正在產生",
Placeholder: "輸入訊息,Enter 傳送,Shift+Enter 換行", Send: "傳送", Stop: "停止產生", Attach: "新增附件",
Suggestions: "建議", Uploading: "上傳中", Failed: "上傳失敗", EditPlaceholder: "編輯訊息",
Pending: "等待中", Running: "進行中", Done: "已完成", Error: "失敗", StepsFmt: "%d/%d",
SecondsFmt: "%.1f 秒", MinutesFmt: "%d 分 %d 秒", ToolCall: "工具呼叫", Arguments: "參數", Result: "結果",
ApprovalTitle: "需要你的確認", AllowOnce: "允許", AllowSession: "本次對話允許", AllowAlways: "一律允許", Deny: "拒絕",
Allowed: "已允許", Denied: "已拒絕", FeedbackPlaceholder: "補充說明(選填)", RiskWarning: "需確認", RiskDanger: "高風險",
Conversations: "對話列表", Rename: "重新命名", Untitled: "未命名對話", Today: "今天", Yesterday: "昨天",
Last7Days: "過去 7 天", Last30Days: "過去 30 天", Earlier: "更早", Prompts: "提示詞"},
SettingDrawer: SettingDrawerLocale{Open: "開啟頁面設定", Title: "頁面設定",
NavTheme: "整體風格", Light: "亮色選單", Dark: "暗色選單", RealDark: "暗色模式",
PrimaryColor: "主題色", Layout: "導覽模式", Side: "側邊選單", Top: "頂部選單", Mix: "混合選單",
ContentWidth: "內容區域寬度", Fluid: "流式", Fixed: "定寬",
FixedHeader: "固定頂欄", FixSiderbar: "固定側邊選單", ColorWeak: "色弱模式",
Other: "其他設定", Compact: "緊湊模式", ColorFmt: "主題色 %s"},
CodeBlock: CodeBlockLocale{Code: "程式碼"},
JSONView: JSONViewLocale{Name: "JSON 檢視器", CopyValue: "複製值", CopyPath: "複製路徑", ExpandAll: "全部展開", CollapseAll: "全部摺疊", ItemsFmt: "%d 項", KeysFmt: "%d 個鍵", Search: "搜尋鍵或值", PrevMatch: "上一個相符項", NextMatch: "下一個相符項", MatchFmt: "%d/%d", NoMatch: "無相符項", ParseErrorFmt: "JSON 解析失敗:%s"},
LogView: LogViewLocale{Name: "日誌", Search: "搜尋日誌", PrevMatch: "上一個相符項", NextMatch: "下一個相符項", MatchFmt: "%d/%d", NoMatch: "無相符項", Wrap: "自動換行", Follow: "跟隨最新", Level: "等級", AllLevels: "全部等級", Levels: [5]string{"Trace", "Debug", "Info", "Warn", "Error"}, LinesFmt: "%d 行"},
StatusBar: StatusBarLocale{Label: "狀態列"},
TitleBar: TitleBarLocale{Minimize: "最小化", Maximize: "最大化", Restore: "還原", WindowControls: "視窗控制"},
NotificationCenter: NotificationCenterLocale{MarkAllRead: "全部標為已讀", ClearAll: "清除所有通知", Dismiss: "移除通知",
Empty: "沒有通知", UnreadFmt: "%d 則未讀", JustNow: "剛剛", MinutesAgoFmt: "%d 分鐘前", HoursAgoFmt: "%d 小時前", DaysAgoFmt: "%d 天前"},
HotkeyInput: HotkeyInputLocale{Placeholder: "按一下以錄製快速鍵", Recording: "請按下組合鍵,Esc 取消", ClearLabel: "清除快速鍵"},
Dock: DockLocale{Maximize: "最大化", Restore: "還原", Split: "向右分割", Empty: "將分頁拖曳到這裡", Group: "分頁群組"},
}ZhTW is the Traditional Chinese locale with Taiwan usage. LocaleByCode maps zh-TW, zh-HK, zh-MO and zh-Hant to it.
函数
func AcceptPatterns 实验性
func AcceptPatterns(accept string) []stringAcceptPatterns turns an accept list into file-dialog patterns ("*.png"); MIME wildcards expand to common extensions. Hosts use it to build the native dialog's filter (uihost.FilePicker).
func BreakpointMins 实验性
func BreakpointMins(th *theme.Theme) [5]float32BreakpointMins returns the minimum widths of SM..XXL for the theme: Ant 576/768/992/1200/1600, Element 768/992/1200/1920 (no xxl), shadcn Tailwind's sm..2xl 640/768/1024/1280/1536.
func CloseContextMenu 实验性
func CloseContextMenu(c *Context, owner ID)CloseContextMenu closes the context menu opened for owner, if any, returning focus to owner when it was inside the menu.
func ContextMenuAt 实验性
func ContextMenuAt(c *Context, owner ID, pos geom.Point, items []MenuItem, onSelect func(key string))ContextMenuAt opens a context menu of items with its top-left corner at the window point pos (top-right in right-to-left scopes); it opens upwards / towards the inline start when it does not fit below / after the point. owner is the widget the menu belongs to: keyboard focus moves to the first enabled item on open (to the panel itself with ContextMenuOptions.NoAutoSelect, see ContextMenuAtWith) and returns to owner when the menu closes (an item is chosen, Escape, or a press outside the menu). onSelect receives the key of the chosen leaf item. The menu takes the theme, locale and direction of the scope ContextMenuAt is called in.
Call it once to open the menu (not every frame):
if p, ok := c.ContextMenuFor(area.ID()); ok {
ui.ContextMenuAt(c, area.ID(), p, items, func(key string) { ... })
}
Calling it again while the menu is open at the same point for the same owner only updates items and onSelect; a new point or owner reopens it.
func ContextMenuAtWith 实验性
func ContextMenuAtWith(c *Context, owner ID, pos geom.Point, items []MenuItem, onSelect func(key string), opts ContextMenuOptions)ContextMenuAtWith is ContextMenuAt with options. Options take effect when the menu (re)opens.
func ContextMenuOpen 实验性
func ContextMenuOpen(c *Context, owner ID) boolContextMenuOpen reports whether a context menu opened for owner is shown.
func Disabled
func Disabled(c *Context, on bool, fn func())Disabled runs fn with every widget inside disabled.
func FieldSet 实验性
func FieldSet(c *Context, f *FormW, fs ProFieldSet, vals ProValues)FieldSet builds a field set as a labelled item of form f (outside a ProForm); vals holds the values. While vals has no fs.Key entry it is filled with a copy of fs.Initial (checked every frame, like ProForm's initial values), so an existing value is never overwritten; to clear the set store nil parts (e.g. []any{nil, nil}) instead of deleting the key.
func FillLocale
func FillLocale(l, base *Locale)FillLocale copies every empty text of l (string fields, entries of the fixed arrays, fields of the component groups and missing Extra keys) from base. RegisterLocale calls it with EnUS so a partial translation never shows blank labels, and new fields added later fall back automatically. WeekStart is not copied (its zero value, Sunday, is valid).
func FormStatus 实验性
func FormStatus(err string) stringFormStatus returns the status string to pass to a control for an error.
func FormatDuration 实验性
func FormatDuration(d time.Duration, format string) stringFormatDuration renders d with tokens D (days), HH, mm, ss, SSS. Larger units absent from the format carry into the largest present one.
func FormatMoney 实验性
func FormatMoney(loc *Locale, amount float64, currency string) stringFormatMoney formats amount in a currency for loc. currency is an ISO 4217 code or a symbol; "" means loc.Currency (itself a code or a symbol), else the default of the locale's region (see ProColumn.Currency). A nil loc formats like zh-CN.
func FormatNumber 实验性
func FormatNumber(v float64, precision int) stringFormatNumber formats v with thousands separators.
func Gap
func Gap(c *Context, size float32)Gap inserts a fixed-size blank.
func HoverDelay 实验性
func HoverDelay(c *Context, key ID, hovering bool, enter, leave time.Duration) boolHoverDelay turns a raw hover signal into a debounced open state: it becomes true after hovering has held for enter and false after it has been off for leave (Ant mouseEnterDelay/mouseLeaveDelay, Element show-after/hide-after). key identifies the trigger across frames.
func Invalidate
func Invalidate(w Window)Invalidate requests a frame of the window w; it is safe to call from any goroutine. Equivalent to w.Invalidate, but tolerates a nil window.
func Key
func Key(c *Context, key any, fn func())Key runs fn in an identity scope named by key, so widgets inside keep their state when siblings are inserted or removed (list rows, tabs).
func MarkdownInsertBlock 实验性
func MarkdownInsertBlock(src string, at int, block string) (string, int, int)MarkdownInsertBlock inserts block on its own lines at position at; the caret lands on the block's first empty line (or after it).
func MarkdownLinePrefix 实验性
func MarkdownLinePrefix(src string, a, b int, prefix string) (string, int, int)MarkdownLinePrefix toggles prefix on every line touched by [a,b).
func MarkdownWrap 实验性
func MarkdownWrap(src string, a, b int, pre, suf, placeholder string) (string, int, int)MarkdownWrap surrounds the selection [a,b) with pre/suf, or inserts pre+placeholder+suf at a when nothing is selected; the inner text stays selected. Wrapping an already wrapped selection unwraps it.
func MessageDestroy 实验性
func MessageDestroy(c *Context, key string)MessageDestroy closes the message with key ("" closes all).
func NotificationDestroy 实验性
func NotificationDestroy(c *Context, key string)NotificationDestroy closes the card with key ("" closes all).
func OpenDialogs 实验性
func OpenDialogs(c *Context) intOpenDialogs returns how many Confirm/MessageBox/Prompt dialogs are open.
func PlainText 实验性
func PlainText(spans []Span) stringPlainText returns the concatenated text of spans.
func ProFormItems 实验性
func ProFormItems(c *Context, f *FormW, fields []ProField, vals ProValues)ProFormItems builds the form items of fields inside f (for use in ProForm.Children, ProFormGroup bodies and custom form layouts).
func ProFormat 实验性
func ProFormat(valueType string, enum []ProEnum, v any) stringProFormat renders a value as text for a value type, formatting money like zh-CN (ProFormatLocale(nil, ...)). Code with a Context should call ProFormatLocale(c.Locale(), ...) so money follows the active Locale, as ProTable, ProDescriptions and the other Pro components do.
func ProFormatLocale 实验性
func ProFormatLocale(loc *Locale, valueType string, enum []ProEnum, v any) stringProFormatLocale is ProFormat with money in the currency and number style of loc (see FormatMoney).
func ProLayout 实验性
func ProLayout(c *Context, cfg ProLayoutConfig, content func())ProLayout builds an Ant Design Pro style admin shell: sider with logo and menu, header with collapse toggle, breadcrumb and user, page title, then content, then footer. cfg.Layout selects the top and mix layouts.
ConfigProvider.Defaults("ProLayout", ...) keys: "layout" (string), "noPadding" (bool), "siderWidth" (number), "breakpoint" (Breakpoint), "title", "footer" (string), "navTheme" ("light" | "dark"), "contentWidth" ("Fluid" | "Fixed"), "fixedHeader", "fixSiderbar" (bool).
func ProSettingsProvider 实验性
func ProSettingsProvider(c *Context, s *ProSettings, fn func())ProSettingsProvider builds fn inside a ConfigProvider following s: realDark selects the dark algorithm, PrimaryColor the brand color, Compact the compact sizes, and ColorWeak the high-contrast theme. Like ConfigProvider.Theme, the theme applies to the whole window: call it at the root.
func Prop 实验性
func Prop[T any](c *Context, component, key string, def T) TProp returns the typed default property, or def when it is unset or of another type.
func QRDataCapacity 实验性
func QRDataCapacity(v int, level QRLevel) intQRDataCapacity returns the number of data codewords of version v at level.
func QRFormatBits 实验性
func QRFormatBits(level QRLevel, mask int) uint32QRFormatBits returns the 15-bit masked format information.
func QRVersionBits 实验性
func QRVersionBits(v int) uint32QRVersionBits returns the 18-bit version information (v >= 7).
func RegisterLocale
func RegisterLocale(l *Locale)RegisterLocale adds (or replaces) a locale under l.Code. Empty texts are filled from EnUS (see FillLocale), so a partial translation works:
ko := &ui.Locale{Code: "ko-KR", Name: "한국어", OK: "확인", Cancel: "취소"}
ui.RegisterLocale(ko)
func SetCodeHighlighter 实验性
func SetCodeHighlighter(h CodeHighlighter)SetCodeHighlighter installs the highlighter CodeBlock and Markdown use when they are not given one of their own (nil: plain text).
ui.SetCodeHighlighter(codehl.New())
func SetDefaultDirection
func SetDefaultDirection(d Direction)SetDefaultDirection sets the window-level direction used where no ConfigProvider decides: pages without a provider and the global layers. DirAuto (the default) derives it from the default locale. Hosts that follow the system layout direction inject it here. It takes effect on the next frame.
func SetDefaultLocale
func SetDefaultLocale(l *Locale)SetDefaultLocale sets the locale used outside any ConfigProvider.
func SetHoverOpen 实验性
func SetHoverOpen(c *Context, key ID, open bool)SetHoverOpen forces the debounced state (used when a click closes a hover-triggered popup).
func ShortcutKeys 实验性
func ShortcutKeys(accel string) []stringShortcutKeys returns the key caps of an accelerator for this platform: on macOS the modifier symbols in Apple's order ("⌃", "⌥", "⇧", "⌘") then the key, elsewhere "Ctrl", "Alt", "Shift", "Win" / "Super" then the key; nil when accel does not parse. Kbd draws one cap.
func ShortcutLabel 实验性
func ShortcutLabel(accel string) stringShortcutLabel returns an accelerator as one string for this platform: "⌘⇧K" on macOS, "Ctrl+Shift+K" elsewhere ("" when it does not parse). Use it for MenuItem.Shortcut and similar hints.
func SkeletonAvatar 实验性
func SkeletonAvatar(c *Context, size float32, square, active bool)SkeletonAvatar adds an avatar placeholder.
func SkeletonButton 实验性
func SkeletonButton(c *Context, size ControlSize, shape string, active bool)SkeletonButton adds a button-shaped placeholder (shape: "default", "round", "circle").
func SkeletonImage 实验性
func SkeletonImage(c *Context, w, h float32, active bool)SkeletonImage adds a picture placeholder with a mountain glyph.
func SkeletonInput 实验性
func SkeletonInput(c *Context, size ControlSize, active bool)SkeletonInput adds an input-shaped placeholder.
func Spacer
func Spacer(c *Context)Spacer grows to take free space.
func State
func State[T any](c *Context, id ID, init func() T) *TState returns retained per-widget state, creating it with init on first use. State that is not requested for a while is dropped.
func ToggleMarkdownTask 实验性
func ToggleMarkdownTask(src string, index int) stringToggleMarkdownTask flips the index-th task checkbox ("- [ ]" / "- [x]", in document order) in src and returns the new source.
func VDivider
func VDivider(c *Context)VDivider draws a short vertical separator for inline content.
类型
A11yLocale
type A11yLocale struct {
Navigation, Breadcrumb, Pagination, Notifications, Toolbar, Menu string
PageFmt string // pagination item, arg: page number ("第 %d 页")
MoreActions, OpenMenu, Remove, DragHandle, Resize, Splitter string
ShowPassword, HidePassword, Increase, Decrease string
Avatar, Image, Chart, Progress, Rating, Color, Loading string
SlideFmt string // carousel slide, args: n, total ("第 %d 张,共 %d 张")
RateFmt string // rating value, args: value, count ("%[1]g 星,共 %[2]d 星")
DateFmt string // full date of a calendar cell, args: year, month number, day, Months entry ("%d年%d月%d日")
DigitFmt string // one-time-code cell, args: n, total ("第 %d 位,共 %d 位")
RemoveFmt string // remove button of a tag / file, arg: its label ("移除 %s")
Hour, Minute, Second string // time picker columns
MoveToTarget, MoveToSource string // Transfer move buttons
PageSize string // page-size select of Pagination ("每页条数")
Day string // day column of a date picker wheel (mobile)
// contains filtered or unexported fields
}A11yLocale holds accessible names and descriptions that are read by screen readers but not shown (icon-only controls, regions, summaries).
ANSIColor 实验性
type ANSIColor struct {
Kind ANSIColorKind
Index uint8 // ANSIIndexed
R, G, B uint8 // ANSIRGB
}ANSIColor is a foreground or background color of an SGR sequence.
ANSIColorKind 实验性
type ANSIColorKind uint8ANSIColorKind says how an ANSIColor is given.
const (
ANSIDefault ANSIColorKind = iota
ANSIIndexed
ANSIRGB
)The color kinds: the default color, one of the 256 indexed colors (0–15 are the theme's ANSI colors, 16–231 the 6×6×6 cube, 232–255 grays) or a 24-bit color.
实验性
ANSIParser 实验性
type ANSIParser struct {
// contains filtered or unexported fields
}ANSIParser strips escape sequences from lines of terminal output and turns SGR sequences ("\x1b[1;31m") into styled spans. The style carries over from one line to the next, as in a terminal. Supported: reset, bold, faint, italic, underline, inverse, strike-through and their resets; the 8 + 8 colors (30–37, 90–97, 40–47, 100–107), 256 colors (38;5;n) and 24-bit colors (38;2;r;g;b, also with ":" separators). Other CSI sequences, OSC strings and control characters are removed; a carriage return inside a line discards what came before it (progress output). The zero value is ready to use.
func (*ANSIParser) Line 实验性
func (p *ANSIParser) Line(s string, dst []ANSISpan) (string, []ANSISpan)Line parses one line (without "\n"): it returns the plain text and appends its styled spans (default-styled text has none) to dst.
func (*ANSIParser) Reset 实验性
func (p *ANSIParser) Reset()Reset returns the parser to the default style.
ANSISpan 实验性
type ANSISpan struct {
Start, End int
Style ANSIStyle
}ANSISpan styles bytes [Start, End) of the plain text ParseANSI returns.
func ParseANSI 实验性
func ParseANSI(s string) (string, []ANSISpan)ParseANSI parses s (one line, or several separated by "\n" sharing one style state) into plain text and styled spans of it.
ANSIStyle 实验性
type ANSIStyle struct {
Fg, Bg ANSIColor
Bold, Faint, Italic, Underline, Inverse, Strike bool
}ANSIStyle is the text style set by SGR sequences.
AccessibilityHost 实验性
type AccessibilityHost interface {
AccessibilityEnabled() bool
// AccessibilityUpdate delivers the tree of the last frame. changed
// lists added and modified nodes and then removed ones (tree.Node
// returns nil for those). tree.Focus is the focused node and
// tree.Announcements the messages to speak once.
AccessibilityUpdate(tree *a11y.Tree, changed []a11y.NodeID)
}AccessibilityHost is an optional interface of Window. A platform backend implements it to receive the semantics tree and expose it through the native accessibility API (NSAccessibility, UI Automation, AT-SPI, UIAccessibility, AccessibilityNodeInfo); docs/accessibility.md has the role mapping and the expected update protocol.
The runner calls AccessibilityEnabled at the start of every frame (it must be cheap) and, while it returns true, AccessibilityUpdate after every frame whose tree differs from the previous one. When an assistive technology attaches, the host flips its flag and calls Runner.Invalidate so the first full tree (every node reported as changed) arrives promptly. Both methods run on the UI thread. The tree must not be modified; it stays valid after the call (the runner builds a new one each frame).
AddonW 实验性
type AddonW struct {
// contains filtered or unexported fields
}AddonW is a static (or clickable) label attached before/after an input inside Compact (Ant addonBefore/addonAfter, Element prepend/append).
func Addon 实验性
func Addon(c *Context, label string) *AddonWAddon adds an addon box with a label.
func (*AddonW) A11yLabel 实验性
func (a *AddonW) A11yLabel(s string) *AddonWA11yLabel sets the accessible name (needed for an icon-only addon button).
func (*AddonW) Clicked 实验性
func (a *AddonW) Clicked() boolClicked makes the addon a button (Element append button) and reports a click.
func (*AddonW) Disabled 实验性
func (a *AddonW) Disabled(on bool) *AddonWfunc (*AddonW) Icon 实验性
func (a *AddonW) Icon(ic *icon.Icon) *AddonWIcon shows an icon before (or instead of) the label.
func (*AddonW) Layout 实验性
func (a *AddonW) Layout(o ...layout.Option) *AddonWfunc (*AddonW) Size 实验性
func (a *AddonW) Size(s ControlSize) *AddonWAffixW 实验性
type AffixW struct {
// contains filtered or unexported fields
}AffixW pins its content to the viewport (or to a scroll container) once it would scroll past OffsetTop / OffsetBottom.
func Affix 实验性
func Affix(c *Context) *AffixWAffix starts a pinned block (default: offset top 0 in the window). Give it Target(scrollBox.ID()) when the page scrolls inside a container.
ConfigProvider.Defaults("Affix", ...) keys: "offsetTop", "offsetBottom" (numbers). Element's position="bottom" + offset is OffsetBottom.
func (*AffixW) Affixed 实验性
func (a *AffixW) Affixed() boolAffixed reports whether the content is currently pinned.
func (*AffixW) Body 实验性
func (a *AffixW) Body(fn func()) *AffixWBody builds the pinned content.
func (*AffixW) Changed 实验性
func (a *AffixW) Changed() boolChanged reports a pin state change on the first build after it was detected.
func (*AffixW) OffsetBottom 实验性
func (a *AffixW) OffsetBottom(px float32) *AffixWOffsetBottom pins the content this far above the bottom of the viewport.
func (*AffixW) OffsetTop 实验性
func (a *AffixW) OffsetTop(px float32) *AffixWOffsetTop pins the content this far below the top of the viewport.
func (*AffixW) Target 实验性
func (a *AffixW) Target(id ID) *AffixWTarget uses a scroll container (ScrollBox.ID()) as viewport.
AlertEffect
type AlertEffect stringAlertEffect selects how an Alert is filled (Element's effect).
const (
// AlertEffectLight tints the box with the light status background
// (the default).
AlertEffectLight AlertEffect = "light"
// AlertEffectDark fills the box with the solid status color and
// draws the text and icon on it in a contrasting color.
AlertEffectDark AlertEffect = "dark"
)AlertW
type AlertW struct {
// contains filtered or unexported fields
}AlertW is an inline status banner.
func Alert
func Alert(c *Context, status, title string) *AlertWAlert adds a banner; call Show after options. status: success, info, warning, error. title is antd's title (v6; message before).
As in antd and Element Plus the icon is off unless ShowIcon(true) (or Banner, which shows it by default).
ConfigProvider.Defaults("Alert", ...) keys: "showIcon", "closable", "banner" (bool), "variant" (string: "outlined" | "filled").
Under shadcn/ui it is the bordered Alert card with an outlined (lucide-style) icon; "error" is the destructive variant.
func (*AlertW) Action
func (a *AlertW) Action(fn func()) *AlertWAction builds an operation area at the right of the text (Ant action), e.g. a small button.
func (*AlertW) Banner
func (a *AlertW) Banner() *AlertWBanner styles the alert as a page-top banner: no border or radius, and the icon on unless ShowIcon(false) (antd banner).
func (*AlertW) Center
func (a *AlertW) Center() *AlertWCenter centers the icon and text horizontally (Element center); the close button stays at the end.
func (*AlertW) Closable
func (a *AlertW) Closable() *AlertWClosable adds the close button.
func (*AlertW) CloseDisabled
func (a *AlertW) CloseDisabled(on bool) *AlertWCloseDisabled disables the close button (antd closable.disabled); ConfigProvider.ComponentDisabled disables it too.
func (*AlertW) CloseIcon
func (a *AlertW) CloseIcon(ic *icon.Icon) *AlertWCloseIcon replaces the close icon and makes the alert closable (antd closable.closeIcon).
func (*AlertW) CloseText
func (a *AlertW) CloseText(s string) *AlertWCloseText shows text instead of the close icon and makes the alert closable (EP close-text).
func (*AlertW) Closed
func (a *AlertW) Closed() boolClosed reports a click on the close button.
func (*AlertW) Description
func (a *AlertW) Description(d string) *AlertWfunc (*AlertW) Effect
func (a *AlertW) Effect(e AlertEffect) *AlertWEffect selects the fill: AlertEffectLight (default) or AlertEffectDark, the solid status color with contrasting text (Element effect="dark").
func (*AlertW) Icon
func (a *AlertW) Icon(ic *icon.Icon) *AlertWIcon replaces the status icon (antd icon) and shows it.
func (*AlertW) NoIcon
func (a *AlertW) NoIcon() *AlertWNoIcon hides the status icon (same as ShowIcon(false)).
func (*AlertW) Show
func (a *AlertW) Show() *AlertWShow builds the alert.
func (*AlertW) ShowIcon
func (a *AlertW) ShowIcon(on bool) *AlertWShowIcon shows or hides the status icon (antd showIcon, EP show-icon; default off, on for a Banner).
func (*AlertW) Variant
func (a *AlertW) Variant(v string) *AlertWVariant selects "outlined" (default, status border) or "filled" (no border) (antd 6.4 variant). Element and shadcn alerts are drawn without / with their own border either way.
AnchorItem 实验性
type AnchorItem struct {
Key, Title string
Children []AnchorItem
}AnchorItem is one link of an Anchor; Key matches an AnchorSection.
AnchorSectionW 实验性
type AnchorSectionW struct {
*Box
// contains filtered or unexported fields
}AnchorSectionW is the section AnchorSection returns; it embeds the section's Box.
func AnchorSection 实验性
func AnchorSection(c *Context, key string, fn func(), opts ...layout.Option) *AnchorSectionWAnchorSection wraps a block of page content that an Anchor link with the same key scrolls to and highlights.
AnchorW 实验性
type AnchorW struct {
// contains filtered or unexported fields
}AnchorW is an in-page table of contents that follows scrolling.
func Anchor 实验性
func Anchor(c *Context, items []AnchorItem) *AnchorWAnchor starts a table of contents; call Target with the scroll container holding the AnchorSections, then Show.
func (*AnchorW) Active 实验性
func (a *AnchorW) Active() stringActive returns the highlighted key.
func (*AnchorW) Bounds 实验性
func (a *AnchorW) Bounds(px float32) *AnchorWBounds sets how close (px) a section's top must come to the offset line to become active (antd bounds 5, Element bound 15; default from AnchorToken.Bounds).
func (*AnchorW) Changed 实验性
func (a *AnchorW) Changed() boolChanged reports that the active link changed this frame.
func (*AnchorW) Clicked 实验性
func (a *AnchorW) Clicked() stringClicked returns the key clicked this frame.
func (*AnchorW) CurrentAnchor 实验性
func (a *AnchorW) CurrentAnchor(fn func(active string) string) *AnchorWCurrentAnchor customizes the highlighted link (antd getCurrentAnchor): fn gets the key scrolling selected and returns the key to highlight.
func (*AnchorW) Direction 实验性
func (a *AnchorW) Direction(d string) *AnchorWDirection lays the links out "vertical" (default) or "horizontal" (antd direction, Element direction).
func (*AnchorW) Horizontal 实验性
func (a *AnchorW) Horizontal() *AnchorWHorizontal lays links out in a row with a bottom ink bar.
func (*AnchorW) NoInk 实验性
func (a *AnchorW) NoInk() *AnchorWNoInk hides the ink rail (Element "underline" off).
func (*AnchorW) Show 实验性
func (a *AnchorW) Show() *AnchorWShow builds the anchor.
func (*AnchorW) Target 实验性
func (a *AnchorW) Target(id ID) *AnchorWTarget sets the scroll container (ScrollBox.ID()).
func (*AnchorW) TargetOffset 实验性
func (a *AnchorW) TargetOffset(px float32) *AnchorWTargetOffset scrolls sections this far below the container top (fixed headers) and uses it for the active test.
func (*AnchorW) Type 实验性
func (a *AnchorW) Type(t string) *AnchorWType picks Element's look: "underline" draws the rail with a thin marker, "default" only a rounded marker. "" follows the theme (Ant and shadcn draw the rail, Element does not).
AppAPI 实验性
type AppAPI struct {
// contains filtered or unexported fields
}AppAPI opens messages, notifications and confirm boxes with the configuration of the enclosing App (Ant App.useApp()).
func UseApp 实验性
func UseApp(c *Context) AppAPIUseApp returns the API of the innermost App being built (outside an App it opens plain messages with the defaults).
func (AppAPI) Confirm 实验性
func (a AppAPI) Confirm(o ConfirmOptions) *ConfirmRefConfirm opens a confirm box (see Confirm; Ant modal.confirm).
func (AppAPI) InApp 实验性
func (a AppAPI) InApp() boolInApp reports whether the API comes from an enclosing App.
func (AppAPI) Info 实验性
func (a AppAPI) Info(o ConfirmOptions) *ConfirmRefInfo opens an alert box (see MessageBox; Ant modal.info).
func (AppAPI) Message 实验性
func (a AppAPI) Message(status, content string) *MessageRefMessage opens a message (see Message), closing the oldest ones beyond MaxCount.
func (AppAPI) Notification 实验性
func (a AppAPI) Notification(status, title string) *NotificationRefNotification opens a notification (see Notification), closing the oldest cards beyond MaxCount.
AppMessageConfig 实验性
type AppMessageConfig struct {
Duration time.Duration // default display time (0: MessageDuration)
MaxCount int // most messages on screen; the oldest close first (0: no limit)
// contains filtered or unexported fields
}AppMessageConfig configures the messages opened inside an App (Ant App message prop).
AppNotificationConfig 实验性
type AppNotificationConfig struct {
Placement NotifyPlacement
PlacementSet bool // Placement given (NotifyTopEnd is the zero value)
Duration time.Duration // 0: the default
MaxCount int // most cards on screen (0: no limit)
ShowProgress bool
// contains filtered or unexported fields
}AppNotificationConfig configures the notifications opened inside an App (Ant App notification prop).
AppW 实验性
type AppW struct {
// contains filtered or unexported fields
}AppW builds an App.
func App 实验性
func App(c *Context) *AppWApp starts an application root; chain options, then Body.
ConfigProvider.Defaults("App", ...) keys: "messageMaxCount", "notificationMaxCount" (number).
func (*AppW) Body 实验性
func (a *AppW) Body(fn func()) *BoxBody builds fn inside the App.
func (*AppW) Layout 实验性
func (a *AppW) Layout(o ...layout.Option) *AppWLayout applies layout options to the App column.
func (*AppW) Message 实验性
func (a *AppW) Message(cfg AppMessageConfig) *AppWMessage sets the message configuration.
func (*AppW) Notification 实验性
func (a *AppW) Notification(cfg AppNotificationConfig) *AppWNotification sets the notification configuration.
ApprovalChoice 实验性
type ApprovalChoice uint8ApprovalChoice is a decision on an Approval.
const (
ApproveNone ApprovalChoice = iota // undecided
ApproveOnce // allow this request
ApproveSession // allow for the rest of the conversation
ApproveAlways // allow from now on
ApproveDeny
)实验性
ApprovalW 实验性
type ApprovalW struct {
// contains filtered or unexported fields
}ApprovalW is a card asking the user to allow or deny an action (a tool call, a command, a file write) before the assistant goes on.
func Approval 实验性
func Approval(c *Context, title string) *ApprovalWApproval adds a permission card; title "" uses Locale.Chat.ApprovalTitle.
a := ui.Approval(c, "").Description("运行 shell 命令").Command("rm -rf build", "sh")
if d, ok := a.Decided(); ok { resolve(d) }
func (*ApprovalW) Body 实验性
func (w *ApprovalW) Body(fn func()) *ApprovalWBody adds custom content above the buttons.
func (*ApprovalW) Choices 实验性
func (w *ApprovalW) Choices(ch ...ApprovalChoice) *ApprovalWChoices sets the buttons in order (default Deny, Always, Once; the last one is the primary button).
func (*ApprovalW) Command 实验性
func (w *ApprovalW) Command(code, lang string) *ApprovalWCommand shows the command or parameters as a code block in lang.
func (*ApprovalW) Decided 实验性
func (w *ApprovalW) Decided() (ApprovalChoice, bool)Decided returns the choice clicked this frame.
func (*ApprovalW) Decision 实验性
func (w *ApprovalW) Decision(d ApprovalChoice) *ApprovalWDecision shows a decided card: the buttons give way to the outcome.
func (*ApprovalW) Description 实验性
func (w *ApprovalW) Description(s string) *ApprovalWDescription explains what will happen.
func (*ApprovalW) Feedback 实验性
func (w *ApprovalW) Feedback(note *string) *ApprovalWFeedback adds an optional note input bound to *note, sent with the decision.
func (*ApprovalW) Field 实验性
func (w *ApprovalW) Field(label, value string) *ApprovalWField adds a labelled detail row (tool, resource, scope …).
func (*ApprovalW) Layout 实验性
func (w *ApprovalW) Layout(opts ...layout.Option) *ApprovalWLayout applies layout options to the card.
func (*ApprovalW) Risk 实验性
func (w *ApprovalW) Risk(level string) *ApprovalWRisk sets the level: "warning" (default) or "error" (dangerous).
AspectRatioW 实验性
type AspectRatioW struct {
// contains filtered or unexported fields
}AspectRatioW is a container that keeps a fixed width-to-height ratio (shadcn/ui AspectRatio, CSS aspect-ratio): it takes the width its parent gives it and is ratio times less tall; the content fills it.
func AspectRatio 实验性
func AspectRatio(c *Context, ratio float32, fn func(), opts ...layout.Option) *AspectRatioWAspectRatio adds a ratio box (width / height, e.g. 16.0/9) and builds fn inside it, stretched over the whole box:
ui.AspectRatio(c, 16.0/9, func() { ui.Image(c, src).Fill() }).Radius(8)
In a column it spans the column's width; where nothing gives it a width (a row, a stack) it is zero wide unless MaxWidth or layout options set one. A ratio <= 0 is taken as 1.
func (*AspectRatioW) A11yLabel 实验性
func (w *AspectRatioW) A11yLabel(s string) *AspectRatioWA11yLabel exposes the box as a named group (a figure caption).
func (*AspectRatioW) ID 实验性
func (w *AspectRatioW) ID() IDID returns the box ID.
func (*AspectRatioW) MaxWidth 实验性
func (w *AspectRatioW) MaxWidth(px float32) *AspectRatioWMaxWidth limits the width (and with it the height).
func (*AspectRatioW) Radius 实验性
func (w *AspectRatioW) Radius(r float32) *AspectRatioWRadius rounds the corners and clips the content to them.
func (*AspectRatioW) Ratio 实验性
func (w *AspectRatioW) Ratio() float32Ratio returns the width-to-height ratio in effect.
func (*AspectRatioW) Rect 实验性
func (w *AspectRatioW) Rect() geom.RectRect returns the box rectangle of the last frame.
AuditIssue 实验性
type AuditIssue struct {
Kind AuditKind
Role a11y.Role
Name string // accessible name (empty for missing-name)
Label string // the widget's internal label (to locate it)
Rect geom.Rect
Interactive bool // the node is a control (counts toward the zero-missing-name goal)
Detail string // contrast pair, reason
}AuditIssue is one finding of Driver.Audit.
func AuditTheme 实验性
func AuditTheme(th *theme.Theme) []AuditIssueAuditTheme reports the contrast findings of th as audit issues.
func (AuditIssue) String 实验性
func (i AuditIssue) String() stringAuditKind 实验性
type AuditKind uint8AuditKind classifies an accessibility audit finding.
Append-only: never reorder or insert; the zero value stays AuditMissingName.
const (
// AuditMissingName: an interactive (or image / dialog) node without an
// accessible name. Icon-only controls need an A11yLabel / label.
AuditMissingName AuditKind = iota
// AuditNoRole: a pointer target that declares no role; it is exposed
// as a generic button so it stays reachable, but the widget should
// annotate it.
AuditNoRole
// AuditNotKeyboard: an interactive widget that Tab cannot reach and
// that is not an item of a keyboard-operated composite (list, menu,
// tree, grid, popup of a focusable trigger).
AuditNotKeyboard
// AuditContrast: a theme token pair below its WCAG contrast minimum.
AuditContrast
// AuditUnmirroredIcon (warning): a directional icon (an arrow, a
// chevron, text lines) drawn without mirroring in a right-to-left
// scope, so it points against the reading direction. Draw it with the
// direction-aware helper (Context.paintIcon) instead of icon.Draw.
AuditUnmirroredIcon
)实验性
func (AuditKind) String 实验性
func (k AuditKind) String() stringAuditReport 实验性
type AuditReport struct {
Issues []AuditIssue
Nodes int // semantic nodes in the tree
Interactive int // interactive nodes in the tree
}AuditReport is the result of Driver.Audit.
func (AuditReport) Count 实验性
func (r AuditReport) Count(k AuditKind) intCount returns the number of issues of kind k.
func (AuditReport) MissingInteractiveNames 实验性
func (r AuditReport) MissingInteractiveNames() intMissingInteractiveNames counts interactive nodes without a name (the gallery gate keeps it at zero).
func (AuditReport) String 实验性
func (r AuditReport) String() stringString lists the issues, one per line.
AutoCompleteW 实验性
type AutoCompleteW struct {
// contains filtered or unexported fields
}AutoCompleteW is a text input with a suggestion dropdown.
func AutoComplete 实验性
func AutoComplete(c *Context, val *string, opts []Option) *AutoCompleteWAutoComplete adds an input bound to *val that suggests opts (filtered by the typed text). Picking a suggestion writes its Value.
func (*AutoCompleteW) A11yLabel 实验性
func (w *AutoCompleteW) A11yLabel(s string) *AutoCompleteWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*AutoCompleteW) AllowClear 实验性
func (w *AutoCompleteW) AllowClear() *AutoCompleteWfunc (*AutoCompleteW) Changed 实验性
func (w *AutoCompleteW) Changed() boolChanged reports a typed edit or a picked suggestion this frame.
func (*AutoCompleteW) DataVersion 实验性
func (w *AutoCompleteW) DataVersion(v int) *AutoCompleteWDataVersion tells the autocomplete that the options slice was modified in place (a virtual list caches its matches and label widths by slice identity, length and this number): after editing options of the same slice without changing its length, change v (or pass a new slice) so the matches and the list's width are recomputed on the next frame.
func (*AutoCompleteW) Debounce 实验性
func (w *AutoCompleteW) Debounce(d time.Duration) *AutoCompleteWDebounce sets the delay before a Remote call.
func (*AutoCompleteW) Disabled 实验性
func (w *AutoCompleteW) Disabled(on bool) *AutoCompleteWfunc (*AutoCompleteW) Highlight 实验性
func (w *AutoCompleteW) Highlight() *AutoCompleteWHighlight emphasises the matched part of each suggestion.
func (*AutoCompleteW) IsOpen 实验性
func (w *AutoCompleteW) IsOpen() boolIsOpen reports whether the dropdown (suggestions or the loading row) is shown.
func (*AutoCompleteW) Layout 实验性
func (w *AutoCompleteW) Layout(o ...layout.Option) *AutoCompleteWfunc (*AutoCompleteW) Loading 实验性
func (w *AutoCompleteW) Loading(on bool) *AutoCompleteWLoading shows a spinner and the loading text in the dropdown (in place of the suggestions with Remote, or when there are none).
func (*AutoCompleteW) NotFoundContent 实验性
func (w *AutoCompleteW) NotFoundContent(s string) *AutoCompleteWNotFoundContent keeps the dropdown open with text s when nothing matches (Ant notFoundContent; without it an empty list closes).
func (*AutoCompleteW) Open 实验性
func (w *AutoCompleteW) Open() *AutoCompleteWOpen forces the dropdown open (screenshots, tests).
func (*AutoCompleteW) Placeholder 实验性
func (w *AutoCompleteW) Placeholder(s string) *AutoCompleteWfunc (*AutoCompleteW) Placement 实验性
func (w *AutoCompleteW) Placement(p Placement) *AutoCompleteWPlacement sets where the suggestions open: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement, Element placement); they flip when there is no room. ConfigProvider.Defaults("AutoComplete", "placement") takes the Ant names.
func (*AutoCompleteW) Prefix 实验性
func (w *AutoCompleteW) Prefix(ic *icon.Icon) *AutoCompleteWfunc (*AutoCompleteW) Remote 实验性
func (w *AutoCompleteW) Remote(fn func(query string)) *AutoCompleteWRemote turns on server-side suggestions: fn receives the typed text after Debounce (300ms by default) on the UI thread. Start the request in the background, pass Loading(true) while it runs, then replace the options given to AutoComplete (they are shown as-is, not filtered by the typed text) and wake the window with Invalidate. A Source, when set, still computes the options.
ui.AutoComplete(c, &q, hits).Remote(func(s string) { go fetch(s) }).Loading(busy)
func (*AutoCompleteW) Selected 实验性
func (w *AutoCompleteW) Selected() (string, bool)Selected returns the value picked this frame and whether one was picked.
func (*AutoCompleteW) Size 实验性
func (w *AutoCompleteW) Size(s ControlSize) *AutoCompleteWfunc (*AutoCompleteW) Source 实验性
func (w *AutoCompleteW) Source(fn func(q string) []Option) *AutoCompleteWSource computes suggestions from the typed text (replaces filtering of the static options).
func (*AutoCompleteW) Status 实验性
func (w *AutoCompleteW) Status(s string) *AutoCompleteWfunc (*AutoCompleteW) TriggerOnFocus 实验性
func (w *AutoCompleteW) TriggerOnFocus() *AutoCompleteWTriggerOnFocus opens the suggestions as soon as the input gains focus (Element trigger-on-focus), before anything is typed: the options (or Source's result) for the current text, all of them when it is empty. With Remote the callback runs at once for the current text.
func (*AutoCompleteW) Variant 实验性
func (w *AutoCompleteW) Variant(v FieldVariant) *AutoCompleteWVariant sets the frame look (FieldOutlined by default; the inner Input's Variant).
func (*AutoCompleteW) Virtual 实验性
func (w *AutoCompleteW) Virtual(on bool) *AutoCompleteWVirtual forces the virtual suggestion list on or off; by default lists longer than 100 suggestions are virtual (only the visible rows and the keyboard row are built; the dropdown keeps the width, height and scroll range of the full list, but suggestions out of view are not in the accessibility tree). Labels, values and Disabled are always read live. A virtual list of static options keeps which options match while the options slice (identity and length), the typed text and the DataVersion stay the same, and measures label widths once per slice, DataVersion and theme: an option renamed in place (same slice, same length) does not join or leave the matches, nor change the list's width, until the text, the slice or the DataVersion (or the theme pointer) changes. Virtual(false) builds every row.
func (*AutoCompleteW) Width 实验性
func (w *AutoCompleteW) Width(px float32) *AutoCompleteWAvatarGroupW 实验性
type AvatarGroupW struct {
// contains filtered or unexported fields
}AvatarGroupW stacks avatars with overlap.
func AvatarGroup 实验性
func AvatarGroup(c *Context) *AvatarGroupWAvatarGroup starts a group; call Body with the avatars.
ConfigProvider.Defaults("AvatarGroup", ...) keys: "maxCount" (int).
func (*AvatarGroupW) Body 实验性
func (g *AvatarGroupW) Body(fn func()) *BoxBody builds the avatars.
func (*AvatarGroupW) Max 实验性
func (g *AvatarGroupW) Max(n int) *AvatarGroupWMax folds avatars beyond n into a "+k" avatar; hovering it shows the folded avatars in a popover (antd max.count / max.popover).
func (*AvatarGroupW) MaxPopover 实验性
func (g *AvatarGroupW) MaxPopover(on bool, placement, trigger string) *AvatarGroupWMaxPopover shows (default) or hides the popover listing the folded avatars; placement and trigger as in Popover (default "top", "hover"). Element's collapse-avatars-tooltip is MaxPopover(true, "top", "hover").
func (*AvatarGroupW) MoreBg 实验性
func (g *AvatarGroupW) MoreBg(col theme.Color) *AvatarGroupWMoreBg sets the background of the "+k" avatar (antd max.style).
func (*AvatarGroupW) Size 实验性
func (g *AvatarGroupW) Size(px float32) *AvatarGroupWSize sets the size of the "+k" avatar (match your avatars; default 32).
AvatarW
type AvatarW struct {
// contains filtered or unexported fields
}AvatarW is a round user avatar.
func Avatar
func Avatar(c *Context, label string) *AvatarWAvatar shows text initials (or an icon when label is "").
ConfigProvider.Defaults("Avatar", ...) keys: "size" (float32 px or ControlSize), "shape" ("circle" | "square"), "gap" (px, default 4).
func (*AvatarW) A11yLabel
func (a *AvatarW) A11yLabel(s string) *AvatarWA11yLabel sets the accessible name (the person's name; the default is the avatar text, or "avatar" for an icon or image avatar).
func (*AvatarW) Bg
func (a *AvatarW) Bg(col theme.Color) *AvatarWfunc (*AvatarW) Gap
func (a *AvatarW) Gap(px float32) *AvatarWGap sets the space kept on each side of the text; longer text is scaled down to fit (antd gap, default 4).
func (*AvatarW) Icon
func (a *AvatarW) Icon(ic *icon.Icon) *AvatarWIcon shows an icon instead of the text (icon avatar).
func (*AvatarW) Image
func (a *AvatarW) Image(img image.Image) *AvatarWfunc (*AvatarW) Large
func (a *AvatarW) Large() *AvatarWLarge uses the large container size (antd 40px, Element 56px).
func (*AvatarW) Shape
func (a *AvatarW) Shape(s string) *AvatarWShape sets "circle" (default) or "square".
func (*AvatarW) Size
func (a *AvatarW) Size(px float32) *AvatarWfunc (*AvatarW) Small
func (a *AvatarW) Small() *AvatarWSmall uses the small container size (antd size="small": 24px).
func (*AvatarW) Square
func (a *AvatarW) Square() *AvatarWBackTopW 实验性
type BackTopW struct {
// contains filtered or unexported fields
}BackTopW is the "back to top" floating button of a scroll container.
func BackTop 实验性
func BackTop(c *Context, target ID) *BackTopWBackTop adds the button for the scroll container target (ScrollBox.ID()); it appears once scrolled past VisibilityHeight (antd 400, Element 200: FloatButtonToken.BackTop*) and scrolls back smoothly in Duration (450ms, antd duration). Call Show. It is antd's FloatButton.BackTop: Icon, Description, Primary and Square style it like a FloatButton.
func (*BackTopW) Clicked 实验性
func (b *BackTopW) Clicked() boolClicked reports a click this frame.
func (*BackTopW) Content 实验性
func (b *BackTopW) Content(fn func()) *BackTopWContent replaces the default icon with custom content (Element slot).
func (*BackTopW) Description 实验性
func (b *BackTopW) Description(s string) *BackTopWDescription shows a text under the icon in a square button (antd 6 content, description deprecated).
func (*BackTopW) Duration 实验性
func (b *BackTopW) Duration(d time.Duration) *BackTopWDuration sets the scroll animation time.
func (*BackTopW) Icon 实验性
func (b *BackTopW) Icon(ic *icon.Icon) *BackTopWIcon replaces the default icon (antd icon).
func (*BackTopW) Position 实验性
func (b *BackTopW) Position(right, bottom float32) *BackTopWPosition sets the distance from the right and bottom window edges.
func (*BackTopW) Primary 实验性
func (b *BackTopW) Primary() *BackTopWPrimary uses the primary button type (antd type="primary").
func (*BackTopW) Show 实验性
func (b *BackTopW) Show() *BackTopWShow builds the button.
func (*BackTopW) Square 实验性
func (b *BackTopW) Square() *BackTopWSquare uses the square shape (antd shape="square").
func (*BackTopW) VisibilityHeight 实验性
func (b *BackTopW) VisibilityHeight(px float32) *BackTopWVisibilityHeight sets the scroll distance after which it shows.
BackWindow 实验性
type BackWindow interface {
SetBackHandling(on bool)
}BackWindow is implemented by windows on platforms with a system Back action. The runner calls SetBackHandling after a frame whenever Context.WantBack changes (never twice with the same value; the first call is SetBackHandling(true)). While on, the host delivers Back as KeyEscape down and up; while off, Back does what the platform does without the UI (go back in the page stack, leave the app). UI thread.
BadgeRibbonW 实验性
type BadgeRibbonW struct {
*Box
// contains filtered or unexported fields
}BadgeRibbonW is the ribbon wrapper BadgeRibbon returns; it embeds the wrapper's Box.
func BadgeRibbon 实验性
func BadgeRibbon(c *Context, label, color, placement string, fn func()) *BadgeRibbonWBadgeRibbon wraps fn's content (usually a card) with a corner ribbon. placement is "end" (default) or "start" (logical: mirrored in RTL); color as in Badge.Color. With placement "", the "placement" key of ConfigProvider.Defaults("BadgeRibbon", ...) applies.
BadgeW
type BadgeW struct {
// contains filtered or unexported fields
}BadgeW is a badge: count / dot / text bubble, overflow, show-zero, preset or custom color, offset, small size, standalone use and the status form with the "processing" ripple.
func Badge
func Badge(c *Context) *BadgeWBadge adds a badge. Body(fn) wraps content and draws the bubble at its top-end corner (top-right; top-left in RTL); without Body the badge stands alone (an inline bubble, or a status dot with a label when Status is set).
ui.Badge(c).Count(5).Body(func() { ui.Avatar(c, "U") })
ui.Badge(c).Status("success", "成功")
ConfigProvider.Defaults("Badge", ...) keys: "size" ("small" / Small), "overflowCount" (int), "showZero" (bool), "color" (string), "dot" (bool).
func (*BadgeW) Body
func (b *BadgeW) Body(fn func()) *BoxBody wraps fn's content and draws the bubble at its top-end corner.
func (*BadgeW) Color
func (b *BadgeW) Color(col string) *BadgeWColor: status name ("success", "warning", "processing", ...), Ant preset ("pink", "green", ...) or hex.
func (*BadgeW) Count
func (b *BadgeW) Count(n int) *BadgeWCount sets the number. Zero hides the bubble unless ShowZero; negative numbers are shown as they are (antd, Element).
func (*BadgeW) Dot
func (b *BadgeW) Dot() *BadgeWDot shows a small dot.
func (*BadgeW) Hidden
func (b *BadgeW) Hidden(on bool) *BadgeWHidden hides the bubble or dot (Element hidden).
func (*BadgeW) Layout
func (b *BadgeW) Layout(o ...layout.Option) *BadgeWLayout applies layout options to the badge.
func (*BadgeW) Max
func (b *BadgeW) Max(n int) *BadgeWMax sets the overflow count (99 → "99+").
func (*BadgeW) Offset
func (b *BadgeW) Offset(x, y float32) *BadgeWOffset moves the bubble by (x, y) from the top-end corner; x points away from the content (mirrored in RTL).
func (*BadgeW) ShowZero
func (b *BadgeW) ShowZero() *BadgeWShowZero shows a zero count.
func (*BadgeW) Small
func (b *BadgeW) Small() *BadgeWSmall uses the 14px bubble.
func (*BadgeW) Status
func (b *BadgeW) Status(status, label string) *BadgeWStatus turns a standalone badge into a status dot with a label ("success", "processing" (ripples), "default", "error", "warning", or "custom" with Color).
func (*BadgeW) Text
func (b *BadgeW) Text(s string) *BadgeWText shows a word instead of a number (Element value="new").
func (*BadgeW) Title
func (b *BadgeW) Title(s string) *BadgeWTitle sets the text announced for the bubble instead of the count (antd title).
BeamStop 实验性
type BeamStop struct {
Color theme.Color
Percent float32
}BeamStop is a color stop of a BorderBeam gradient (Percent 0..100 from tail to head).
BorderBeamW 实验性
type BorderBeamW struct {
// contains filtered or unexported fields
}BorderBeamW decorates its body with moving border beams.
func BorderBeam 实验性
func BorderBeam(c *Context) *BorderBeamWBorderBeam starts a beam decoration; add the content with Body.
ui.BorderBeam(c).Duration(3 * time.Second).Body(func() { ui.Card(c, "AI").Body(...) })
func (*BorderBeamW) Active 实验性
func (w *BorderBeamW) Active(on bool) *BorderBeamWActive shows or hides the beam (e.g. only while hovered).
func (*BorderBeamW) Body 实验性
func (w *BorderBeamW) Body(fn func()) *BoxBody builds the decorated content and returns the wrapper box.
func (*BorderBeamW) Color 实验性
func (w *BorderBeamW) Color(col theme.Color) *BorderBeamWColor sets a single beam color (fading to transparent at the tail).
func (*BorderBeamW) Count 实验性
func (w *BorderBeamW) Count(n int) *BorderBeamWCount spaces n beams evenly (default 1).
func (*BorderBeamW) Duration 实验性
func (w *BorderBeamW) Duration(d time.Duration) *BorderBeamWDuration sets the time of one loop (default 6s).
func (*BorderBeamW) Gradient 实验性
func (w *BorderBeamW) Gradient(stops ...BeamStop) *BorderBeamWGradient sets the beam colors from tail (0) to head (100).
func (*BorderBeamW) Layout 实验性
func (w *BorderBeamW) Layout(o ...layout.Option) *BorderBeamWLayout applies layout options to the wrapper.
func (*BorderBeamW) LineWidth 实验性
func (w *BorderBeamW) LineWidth(px float32) *BorderBeamWLineWidth sets the beam thickness (default 1px).
func (*BorderBeamW) Outset 实验性
func (w *BorderBeamW) Outset(px float32) *BorderBeamWOutset moves the beam outside (positive) or inside (negative) the edge.
func (*BorderBeamW) Radius 实验性
func (w *BorderBeamW) Radius(px float32) *BorderBeamWRadius sets the corner radius the beam follows (default th.RadiusLG, the Card radius).
func (*BorderBeamW) Size 实验性
func (w *BorderBeamW) Size(px float32) *BorderBeamWSize sets the beam length (default 100px).
Box
type Box struct {
// contains filtered or unexported fields
}Box is a styled layout container.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func Column
func Column(c *Context, fn func(), opts ...layout.Option) *BoxColumn lays out children vertically.
func Content
func Content(c *Context, fn func(), opts ...layout.Option) *BoxContent is the main area; it takes the free space.
func Custom
func Custom(c *Context, measure func(maxW, maxH float32) geom.Size, p PaintFunc, opts ...layout.Option) *BoxCustom adds a leaf with a measure and paint function.
func Div
func Div(c *Context, opts ...layout.Option) *BoxDiv creates an empty styled box (Column by default); add children with Body.
func Footer
func Footer(c *Context, fn func(), opts ...layout.Option) *BoxFooter is the bottom bar (Ant: 24px/50px padding on the layout background; Element: 60px high, 20px padding). Its content starts at the inline start like Ant's and Element's footers (neither centres it; pass layout.Center() for the centred footer of the Ant demos).
func Header
func Header(c *Context, fn func(), opts ...layout.Option) *BoxHeader is the top bar.
func Layout
func Layout(c *Context, fn func(), opts ...layout.Option) *BoxLayout is the page frame holding Header / Sider / Content / Footer (or nested Layouts). It fills the free space of its parent.
func Overlay 实验性
func Overlay(c *Context, o OverlayOptions, fn func(), opts ...layout.Option) *BoxOverlay builds fn in a new layer above everything built so far. Layers swallow pointer input over their area (and over the whole window for ScreenFill). The overlay is placed during layout of the current frame, using its measured size, so it never needs a frame to settle.
Dismissible overlays close through Dismissed (or EscapeAt and PressedOutside) with the returned box's ID: Escape and outside presses then reach only the top-most open layer.
func Row
func Row(c *Context, fn func(), opts ...layout.Option) *BoxRow lays out children horizontally.
func StackBox
func StackBox(c *Context, fn func(), opts ...layout.Option) *BoxStackBox overlaps children.
func (*Box) A11y
func (b *Box) A11y(fn func(s *a11y.Node)) *BoxA11y sets a function that completes the box's semantics node (description, value, range, relations) while the tree is built. fn runs only when accessibility is on.
func (*Box) A11yHidden
func (b *Box) A11yHidden() *BoxA11yHidden hides the box and its subtree from the semantics tree (decoration, or content another node already describes).
func (*Box) A11yKeyboard
func (b *Box) A11yKeyboard() *BoxA11yKeyboard declares that a pointer-only box has a keyboard equivalent elsewhere (arrow keys of its composite, a focusable twin), so Audit does not report it as unreachable.
func (*Box) A11yScroller 实验性
func (b *Box) A11yScroller() *BoxA11yScroller declares that the box is a scroll container that moves its content itself (a touch scroll view with its own scroller) rather than a ui scroll container. Semantic nodes inside it get the ScrollIntoView action, and the container reads a request for it with Context.A11yScrollRequest and scrolls the widget into view. Such a container normally clips (Clip), which also marks content scrolled out of it Offscreen.
func (*Box) A11yState
func (b *Box) A11yState(s a11y.State) *BoxA11yState adds accessibility states to the box (Selected, Expanded …).
func (*Box) Bg
func (b *Box) Bg(col theme.Color) *BoxBg sets the background color.
func (*Box) Body
func (b *Box) Body(fn func()) *BoxBody adds children.
func (*Box) Border
func (b *Box) Border(w float32, col theme.Color) *BoxBorder draws a border inside the box.
func (*Box) Clicked
func (b *Box) Clicked() boolClicked reports a click on the box.
func (*Box) Clip
func (b *Box) Clip() *BoxClip clips children to the (rounded) box.
func (*Box) Cursor 实验性
func (b *Box) Cursor(cursor input.Cursor) *BoxCursor sets the pointer cursor for an interactive box. It can be set during custom painting when hit geometry depends on layout.
func (*Box) DashedBorder
func (b *Box) DashedBorder(w float32, col theme.Color) *BoxDashedBorder draws a dashed border.
func (*Box) Focusable
func (b *Box) Focusable(cursor input.Cursor) InteractionFocusable makes the box a keyboard focus stop (Tab, focus ring state, Enter / Space activate it) and returns its interaction, like Interact.
func (*Box) Hovered
func (b *Box) Hovered() boolHovered reports pointer hover (registers the box for hit testing).
func (*Box) ID
func (b *Box) ID() IDID returns the box's widget ID.
func (*Box) Interact
func (b *Box) Interact(cursor input.Cursor) InteractionInteract makes the box hoverable/clickable and returns its state.
func (*Box) Label
func (b *Box) Label(s string) *BoxLabel gives a box (Custom, Div, Row …) a text label: Driver.Find, FindText and ClickLabel locate it by that text, and it is the box's accessible name unless Semantics set another. The widget ID is not affected (it was computed when the box was created).
func (*Box) Opacity
func (b *Box) Opacity(a float32) *BoxOpacity fades the box and its children.
func (*Box) Paint
func (b *Box) Paint(fn PaintFunc) *BoxPaint adds a custom painter drawn above the background, below children.
func (*Box) PaintOver
func (b *Box) PaintOver(fn PaintFunc) *BoxPaintOver adds a painter drawn above children.
func (*Box) Radii
func (b *Box) Radii(r geom.Radii) *BoxRadii sets per-corner radii.
func (*Box) Radius
func (b *Box) Radius(r float32) *BoxRadius rounds the corners.
func (*Box) RawTouch 实验性
func (b *Box) RawTouch() *BoxRawTouch stops the fingers that go down inside b from being turned into pointer events: b handles them through Touches alone (drawing surfaces, maps, custom multi-finger gestures).
func (*Box) Rect
func (b *Box) Rect() geom.RectRect returns the box's absolute rect from the previous frame.
func (*Box) Scale
func (b *Box) Scale(k float32) *BoxScale scales the box and its subtree by k about its centre (enter / leave motion); 1 removes the transform.
func (*Box) ScrollShift 实验性
func (b *Box) ScrollShift(r geom.Rect, d geom.Point)ScrollShift is Context.ScrollShift for a widget that paints scrolled content itself (the lines of a code editor): it declares that what b paints, with b's subtree, moved by d inside r. Unlike Context.ScrollShift it may also be called from b's paint function, once the widget knows where it scrolled to; the rules are the same (the backgrounds behind r must look the same everywhere in r, nodes that do not move with b are damaged by the Runner, and an unclassifiable region is redrawn whole).
UI thread only, during the page build or b's paint.
func (*Box) Semantics
func (b *Box) Semantics(role a11y.Role, name string) *BoxSemantics sets the box's role and accessible name (an empty name is computed from the text inside for roles such as buttons and cells).
func (*Box) Shadow
func (b *Box) Shadow(s []paint.Shadow) *BoxShadow sets layered box shadows.
func (*Box) Style
func (b *Box) Style(opts ...layout.Option) *BoxStyle tweaks layout after creation.
func (*Box) TakePointer 实验性
func (b *Box) TakePointer(axes PanAxis) *BoxTakePointer makes b take over drags that start on widgets inside it and move along axes (see the package notes above on pointer takeover). b should register a hit (Interact, Focusable) so that it can also be dragged directly. Declare it every frame, like other modifiers.
func (*Box) Touches 实验性
func (b *Box) Touches() []input.TouchEventTouches makes b receive touch events and returns those of this frame for the fingers bound to b (see the notes on multi-touch above), in the order they happened. Call it every frame: fingers are routed by the last frame's geometry, so b receives fingers that go down inside it from the frame after its first call. Single-finger pointer emulation keeps running unless b also sets RawTouch.
func (*Box) Transform
func (b *Box) Transform(m geom.Affine) *BoxTransform draws the box and its subtree through m, given in the box's own coordinates (origin at its top-left corner), like a CSS transform with transform-origin 0 0. Layout is unaffected; hit testing and Rect use the transformed bounding box. Combine with geom.ScaleAround / RotateAround for other origins, e.g. scaling about the centre:
b.Transform(geom.ScaleAround(k, k, geom.Pt(w/2, h/2)))
BreadcrumbItem
type BreadcrumbItem struct {
Label string
Icon *icon.Icon // shown before the label (alone when Label is "")
Href string // reported by ClickedHref; the app navigates
OnClick func() // runs when the item is clicked
Menu []MenuItem // dropdown menu on the item (read MenuClicked)
// Separator replaces the separator after this item (antd items[]
// {type: "separator", separator}); "" keeps the breadcrumb's.
Separator string
}BreadcrumbItem is a structured breadcrumb entry.
BreadcrumbW
type BreadcrumbW struct {
// contains filtered or unexported fields
}BreadcrumbW is a breadcrumb with structured items: icons, dropdown menus, click handlers and a custom separator.
func Breadcrumb
func Breadcrumb(c *Context, items ...string) *BreadcrumbWBreadcrumb shows a path of plain labels; Clicked on the result returns the index of the item clicked this frame, or -1. BreadcrumbItems builds the structured form.
func BreadcrumbItems
func BreadcrumbItems(c *Context, items []BreadcrumbItem) *BreadcrumbWBreadcrumbItems starts a breadcrumb of structured items; chain options, then Show.
ConfigProvider.Defaults("Breadcrumb", ...) keys: "separator" (string).
func (*BreadcrumbW) Clicked
func (b *BreadcrumbW) Clicked() intClicked returns the index of the item clicked this frame, or -1.
func (*BreadcrumbW) ClickedHref
func (b *BreadcrumbW) ClickedHref() stringClickedHref returns the Href of the item clicked this frame ("" when none was clicked or it has no Href).
func (*BreadcrumbW) DropdownIcon
func (b *BreadcrumbW) DropdownIcon(ic *icon.Icon) *BreadcrumbWDropdownIcon replaces the down arrow of items with a Menu (antd dropdownIcon).
func (*BreadcrumbW) MenuClicked
func (b *BreadcrumbW) MenuClicked() stringMenuClicked returns the key chosen in an item's dropdown menu this frame.
func (*BreadcrumbW) Separator
func (b *BreadcrumbW) Separator(s string) *BreadcrumbWSeparator replaces the "/" between items (Ant separator, Element separator).
func (*BreadcrumbW) SeparatorIcon
func (b *BreadcrumbW) SeparatorIcon(ic *icon.Icon) *BreadcrumbWSeparatorIcon uses an icon between items (Element separator-icon).
func (*BreadcrumbW) Show
func (b *BreadcrumbW) Show() *BreadcrumbWShow builds the breadcrumb.
Breakpoint
type Breakpoint uint8Breakpoint names a window width range.
Append-only: never reorder or insert; the zero value stays XS.
const (
XS Breakpoint = iota
SM
MD
LG
XL
XXL
)func ScreenBreakpoint 实验性
func ScreenBreakpoint(c *Context) BreakpointScreenBreakpoint returns the breakpoint of the current window width.
func (Breakpoint) String
func (b Breakpoint) String() stringString returns "xs" ... "xxl".
BubbleAction 实验性
type BubbleAction uint8BubbleAction is a set of built-in message actions (bit flags).
const (
BubbleCopy BubbleAction = 1 << iota // copy the content to the clipboard
BubbleRetry // ask for a new answer (Retried)
BubbleEdit // edit the message in place (Edited)
)实验性
BubbleListW 实验性
type BubbleListW struct {
// contains filtered or unexported fields
}BubbleListW is a scrolling message stream that only builds the messages near the viewport (heights are measured and cached by key), keeps the bottom in view while new content streams in, and stops following when the user scrolls up, showing a "back to bottom" button instead.
func BubbleList 实验性
func BubbleList(c *Context, n int, key func(i int) string, item func(i int), opts ...layout.Option) *BubbleListWBubbleList adds a message list of n items; key(i) must be a stable, unique key of message i (heights and widget state are kept by key) and item(i) builds it (usually a Bubble). Give the list a bounded height (Grow inside a sized parent, or layout.H).
ui.BubbleList(c, len(msgs), func(i int) string { return msgs[i].ID }, func(i int) {
ui.Bubble(c, msgs[i].Role, msgs[i].Text)
}, layout.Grow(1))
func (*BubbleListW) A11yLabel 实验性
func (w *BubbleListW) A11yLabel(s string) *BubbleListWA11yLabel sets the accessible name (default Locale.Chat.Messages).
func (*BubbleListW) Following 实验性
func (w *BubbleListW) Following() boolFollowing reports whether the list sticks to the bottom.
func (*BubbleListW) Gap 实验性
func (w *BubbleListW) Gap(px float32) *BubbleListWGap sets the space between messages (default 8; the action row under a message reserves its own space).
func (*BubbleListW) ID 实验性
func (w *BubbleListW) ID() IDID returns the scroll container's ID.
func (*BubbleListW) NoAutoScroll 实验性
func (w *BubbleListW) NoAutoScroll() *BubbleListWNoAutoScroll stops following new content at the bottom.
func (*BubbleListW) Overscan 实验性
func (w *BubbleListW) Overscan(px float32) *BubbleListWOverscan sets how far beyond the viewport messages are built, in px (default 600).
func (*BubbleListW) Padding 实验性
func (w *BubbleListW) Padding(px float32) *BubbleListWPadding sets the space around the messages (default 16).
func (*BubbleListW) Range 实验性
func (w *BubbleListW) Range() (first, end int)Range returns the half-open range of messages built this frame.
func (*BubbleListW) ScrollToBottom 实验性
func (w *BubbleListW) ScrollToBottom() *BubbleListWScrollToBottom jumps to the end and resumes following new content.
func (*BubbleListW) TopReached 实验性
func (w *BubbleListW) TopReached() boolTopReached reports the frame the user scrolled to the very top (load earlier messages then; the view keeps its place when they are prepended).
BubbleVariant 实验性
type BubbleVariant uint8BubbleVariant is the look of a Bubble.
const (
BubbleAuto BubbleVariant = iota // user filled, assistant borderless
BubbleFilled // tinted background
BubbleOutlined // border, no fill
BubbleShadow // elevated card
BubbleBorderless // content only (full width)
)实验性
BubbleW 实验性
type BubbleW struct {
// contains filtered or unexported fields
}BubbleW is one chat message: avatar, optional name, content and actions.
func Bubble 实验性
func Bubble(c *Context, role ChatRole, content string) *BubbleWBubble adds a chat message of role with content (Markdown for the assistant, plain text for the user; see Markdown/Plain).
ui.Bubble(c, ui.ChatAssistant, reply).Typing(streaming).Actions(ui.BubbleCopy | ui.BubbleRetry)
func (*BubbleW) Actions 实验性
func (w *BubbleW) Actions(a BubbleAction) *BubbleWActions shows the built-in action buttons under the bubble. They appear while the pointer is over the message or focus is inside it (see ActionsAlways) and stay reachable with Tab.
func (*BubbleW) ActionsAlways 实验性
func (w *BubbleW) ActionsAlways() *BubbleWActionsAlways keeps the action buttons visible (the last answer).
func (*BubbleW) Avatar 实验性
func (w *BubbleW) Avatar(fn func()) *BubbleWAvatar replaces the default avatar with custom content.
func (*BubbleW) AvatarIcon 实验性
func (w *BubbleW) AvatarIcon(ic *icon.Icon) *BubbleWAvatarIcon sets the icon of the default avatar.
func (*BubbleW) AvatarText 实验性
func (w *BubbleW) AvatarText(s string) *BubbleWAvatarText shows initials in the default avatar.
func (*BubbleW) ClickedLink 实验性
func (w *BubbleW) ClickedLink() stringClickedLink returns the URL of a Markdown link clicked this frame.
func (*BubbleW) Copied 实验性
func (w *BubbleW) Copied() boolCopied reports that the copy action put the content on the clipboard this frame.
func (*BubbleW) Edited 实验性
func (w *BubbleW) Edited() (string, bool)Edited returns the new text when an in-place edit was saved this frame.
func (*BubbleW) Editing 实验性
func (w *BubbleW) Editing() boolEditing reports whether the in-place editor is open.
func (*BubbleW) Extra 实验性
func (w *BubbleW) Extra(fn func()) *BubbleWExtra adds content under the bubble (tool cards, thought chains, attachments, custom actions).
func (*BubbleW) ID 实验性
func (w *BubbleW) ID() IDID returns the message row's ID.
func (*BubbleW) Layout 实验性
func (w *BubbleW) Layout(opts ...layout.Option) *BubbleWLayout applies layout options to the message row.
func (*BubbleW) Loading 实验性
func (w *BubbleW) Loading(on bool) *BubbleWLoading shows animated dots while the content is still empty.
func (*BubbleW) Markdown 实验性
func (w *BubbleW) Markdown() *BubbleWMarkdown renders the content as Markdown (default for the assistant).
func (*BubbleW) Meta 实验性
func (w *BubbleW) Meta(s string) *BubbleWMeta shows a footer text after the actions (time, model, tokens).
func (*BubbleW) Name 实验性
func (w *BubbleW) Name(s string) *BubbleWName shows the author's name above the bubble (also its accessible name).
func (*BubbleW) NoAvatar 实验性
func (w *BubbleW) NoAvatar() *BubbleWNoAvatar hides the avatar column.
func (*BubbleW) Plain 实验性
func (w *BubbleW) Plain() *BubbleWPlain renders the content as plain text keeping line breaks (default for the user and system).
func (*BubbleW) Retried 实验性
func (w *BubbleW) Retried() boolRetried reports a click on the retry action.
func (*BubbleW) Typing 实验性
func (w *BubbleW) Typing(on bool) *BubbleWTyping marks the content as still streaming: it is revealed at TypingSpeed (catching up quickly when far behind) with a caret at the end. Turning it off shows the whole content.
func (*BubbleW) TypingSpeed 实验性
func (w *BubbleW) TypingSpeed(cps float32) *BubbleWTypingSpeed sets the reveal speed in characters per second (default 60).
func (*BubbleW) Variant 实验性
func (w *BubbleW) Variant(v BubbleVariant) *BubbleWVariant sets the look (default BubbleAuto).
ButtonAppearance
type ButtonAppearance stringButtonAppearance is how a button wears its color (Ant v6 variant, plus Element's plain).
const (
ButtonSolid ButtonAppearance = "solid" // filled with the color
ButtonOutlined ButtonAppearance = "outlined" // colored border and label
ButtonDashed ButtonAppearance = "dashed" // outlined with a dashed border
ButtonFilled ButtonAppearance = "filled" // light tint, no border
ButtonText ButtonAppearance = "text" // label only, tint under the pointer
ButtonLink ButtonAppearance = "link" // link-styled label
ButtonPlain ButtonAppearance = "plain" // Element plain: tint + tinted border, solid on hover
)ButtonColor
type ButtonColor stringButtonColor names a button color: a role (default, primary, danger, success, warning, info), an Ant Design preset (blue … gold) or a hex color such as "#13c2c2". The set is open; unknown names fall back to primary.
const (
ButtonColorDefault ButtonColor = "default"
ButtonColorPrimary ButtonColor = "primary"
ButtonColorDanger ButtonColor = "danger"
ButtonColorSuccess ButtonColor = "success" // Element type="success"
ButtonColorWarning ButtonColor = "warning" // Element type="warning"
ButtonColorInfo ButtonColor = "info" // Element type="info"
ButtonColorBlue ButtonColor = "blue"
ButtonColorPurple ButtonColor = "purple"
ButtonColorCyan ButtonColor = "cyan"
ButtonColorGreen ButtonColor = "green"
ButtonColorMagenta ButtonColor = "magenta"
ButtonColorPink ButtonColor = "pink"
ButtonColorRed ButtonColor = "red"
ButtonColorOrange ButtonColor = "orange"
ButtonColorYellow ButtonColor = "yellow"
ButtonColorVolcano ButtonColor = "volcano"
ButtonColorGeekblue ButtonColor = "geekblue"
ButtonColorLime ButtonColor = "lime"
ButtonColorGold ButtonColor = "gold"
)ButtonGroupW 实验性
type ButtonGroupW struct {
// contains filtered or unexported fields
}ButtonGroupW joins buttons into one group (Ant Button.Group, Element el-button-group, shadcn ButtonGroup): neighbours share a one-pixel border, only the outer corners stay rounded, and size, color, appearance or variant can be set once for every button. Buttons keep their own modifiers, which win over the group's.
ui.ButtonGroup(c).Variant(ui.VariantPrimary).Body(func() {
ui.Button(c, "上一页").Icon(icon.Left)
ui.Button(c, "下一页").IconRight(icon.Right)
})
Buttons that are direct children join, and so does a button that is the whole trigger of a Dropdown placed directly in the group (Element split-button: a main button and a menu caret sharing one seam). Each button stays its own Tab stop.
func ButtonGroup 实验性
func ButtonGroup(c *Context) *ButtonGroupWButtonGroup starts a button group; chain options, then Body.
ConfigProvider.Defaults("ButtonGroup", ...) keys: "size", "type" (a Button type / variant name such as "primary").
func (*ButtonGroupW) A11yLabel 实验性
func (g *ButtonGroupW) A11yLabel(s string) *ButtonGroupWA11yLabel names the group for screen readers.
func (*ButtonGroupW) Appearance 实验性
func (g *ButtonGroupW) Appearance(a ButtonAppearance) *ButtonGroupWAppearance sets the appearance of every button (see ButtonW.Appearance).
func (*ButtonGroupW) Body 实验性
func (g *ButtonGroupW) Body(fn func()) *ButtonGroupWBody adds the buttons.
func (*ButtonGroupW) Color 实验性
func (g *ButtonGroupW) Color(col ButtonColor) *ButtonGroupWColor sets the color of every button (see ButtonW.Color).
func (*ButtonGroupW) ID 实验性
func (g *ButtonGroupW) ID() IDID returns the group's widget ID (valid after Body).
func (*ButtonGroupW) Layout 实验性
func (g *ButtonGroupW) Layout(o ...layout.Option) *ButtonGroupWLayout applies layout options to the group.
func (*ButtonGroupW) Size 实验性
func (g *ButtonGroupW) Size(s ControlSize) *ButtonGroupWSize sets the size of every button.
func (*ButtonGroupW) Variant 实验性
func (g *ButtonGroupW) Variant(v ButtonVariant) *ButtonGroupWVariant sets the variant of every button (Element group type="primary" is Variant(ui.VariantPrimary)).
func (*ButtonGroupW) Vertical 实验性
func (g *ButtonGroupW) Vertical() *ButtonGroupWVertical stacks the buttons (joined top / bottom edges).
ButtonVariant
type ButtonVariant uint8ButtonVariant is the visual type of a button.
Append-only: never reorder or insert; the zero value stays VariantDefault.
const (
VariantDefault ButtonVariant = iota
VariantPrimary
VariantDashed
VariantText
VariantLink
// VariantSecondary is a neutral filled button (shadcn "secondary", Ant
// variant="filled", Element type="info" plain).
VariantSecondary
)ButtonW
type ButtonW struct {
// contains filtered or unexported fields
}ButtonW is a button under construction; chain modifiers then query.
func Button
func Button(c *Context, label string) *ButtonWButton adds a button.
func (*ButtonW) A11yLabel
func (b *ButtonW) A11yLabel(s string) *ButtonWA11yLabel sets the accessible name read by screen readers. Icon-only buttons (no label) must set one, from the Locale: Button(c, "").Icon(ic).A11yLabel(loc.Search).
func (*ButtonW) Appearance
func (b *ButtonW) Appearance(a ButtonAppearance) *ButtonWAppearance sets how the button wears its color (Ant v6 variant, plus Element's plain).
func (*ButtonW) AutoInsertSpace
func (b *ButtonW) AutoInsertSpace(on bool) *ButtonWAutoInsertSpace sets whether a label of exactly two Chinese characters is drawn with a space between them ("确定" shows as "确 定"; Ant / Element ConfigProvider button.autoInsertSpace). It applies only to buttons without an icon whose appearance is not text or link; the accessible name keeps the label as given. The default follows the design system (ButtonToken.AutoInsertSpace: on for Ant, off for Element and shadcn); Defaults("Button", Props{"autoInsertSpace": …}) overrides it for a scope and this method for one button.
func (*ButtonW) Block
func (b *ButtonW) Block() *ButtonWBlock stretches the button to the container width.
func (*ButtonW) Circle
func (b *ButtonW) Circle() *ButtonWCircle makes an icon-only round button.
func (*ButtonW) Clicked
func (b *ButtonW) Clicked() boolClicked reports activation (never when disabled or loading).
func (*ButtonW) Color
func (b *ButtonW) Color(col ButtonColor) *ButtonWColor sets the button color (Ant v6 color): a role, an Ant preset or a hex color ("#13c2c2"). Combine it with Appearance, or with the variant modifiers: Primary is solid, Dashed dashed, Text text, Link link, Secondary filled. With neither, the success / warning / info colors are solid (Element type="success") and the other colors outlined.
ui.Button(c, "紫色").Color(ui.ButtonColorPurple).Appearance(ui.ButtonFilled)
func (*ButtonW) Danger
func (b *ButtonW) Danger() *ButtonWfunc (*ButtonW) Dashed
func (b *ButtonW) Dashed() *ButtonWfunc (*ButtonW) Disabled
func (b *ButtonW) Disabled(on bool) *ButtonWDisabled disables the button when on.
func (*ButtonW) Ghost
func (b *ButtonW) Ghost() *ButtonWfunc (*ButtonW) Hovered
func (b *ButtonW) Hovered() boolHovered reports hover.
func (*ButtonW) ID
func (b *ButtonW) ID() IDID returns the widget ID.
func (*ButtonW) Icon
func (b *ButtonW) Icon(ic *icon.Icon) *ButtonWIcon puts an icon before the label.
func (*ButtonW) IconPlacement
func (b *ButtonW) IconPlacement(p string) *ButtonWIconPlacement places the icon at the inline "start" of the label (default) or at its "end" (Ant v6 iconPlacement, which replaces iconPosition). Both are logical: "end" is on the left in a right-to-left scope. Other values are ignored.
ui.Button(c, "下一步").Icon(icon.Right).IconPlacement("end")
func (*ButtonW) IconRight
func (b *ButtonW) IconRight(ic *icon.Icon) *ButtonWIconRight puts the icon after the label (Icon(ic).IconPlacement("end")).
func (*ButtonW) Info
func (b *ButtonW) Info() *ButtonWInfo makes a solid info button (Element type="info").
func (*ButtonW) Large
func (b *ButtonW) Large() *ButtonWfunc (*ButtonW) Layout
func (b *ButtonW) Layout(opts ...layout.Option) *ButtonWLayout applies layout options.
func (*ButtonW) Link
func (b *ButtonW) Link() *ButtonWfunc (*ButtonW) Loading
func (b *ButtonW) Loading(on bool) *ButtonWLoading shows a spinner and blocks clicks.
func (*ButtonW) LoadingDelay
func (b *ButtonW) LoadingDelay(d time.Duration) *ButtonWLoadingDelay postpones the loading state (Ant loading.delay): after Loading(true) the button stays clickable and shows no spinner until d has passed; a loading that ends sooner never shows.
func (*ButtonW) LoadingIcon
func (b *ButtonW) LoadingIcon(ic *icon.Icon) *ButtonWLoadingIcon replaces the loading spinner with ic, drawn spinning (Ant loading.icon, Element loading-icon).
func (*ButtonW) Plain
func (b *ButtonW) Plain() *ButtonWPlain uses Element's plain style: a light tint of the color with a tinted border, filled with the color under the pointer. It combines with every color: Plain() alone, Primary().Plain(), Success().Plain(), Danger().Plain(), Color(ui.ButtonColorPurple).Plain() …
func (*ButtonW) Primary
func (b *ButtonW) Primary() *ButtonWfunc (*ButtonW) Round
func (b *ButtonW) Round() *ButtonWfunc (*ButtonW) Secondary
func (b *ButtonW) Secondary() *ButtonWSecondary makes a neutral filled button (shadcn "secondary").
func (*ButtonW) Size
func (b *ButtonW) Size(s ControlSize) *ButtonWSize sets the control size.
func (*ButtonW) Small
func (b *ButtonW) Small() *ButtonWfunc (*ButtonW) Success
func (b *ButtonW) Success() *ButtonWSuccess makes a solid success button (Element type="success"); add Plain for the plain style.
func (*ButtonW) Text
func (b *ButtonW) Text() *ButtonWfunc (*ButtonW) Variant
func (b *ButtonW) Variant(v ButtonVariant) *ButtonWVariant sets the variant explicitly.
func (*ButtonW) Warning
func (b *ButtonW) Warning() *ButtonWWarning makes a solid warning button (Element type="warning").
CalendarLocale 实验性
type CalendarLocale struct {
Month, Year string
// contains filtered or unexported fields
}CalendarLocale holds the Calendar mode switch.
CalendarW 实验性
type CalendarW struct {
// contains filtered or unexported fields
}CalendarW is a calendar.
func Calendar 实验性
func Calendar(c *Context, val *time.Time) *CalendarWCalendar adds a calendar bound to *val (zero means today, nothing selected). Modifiers apply until the end of the build; the content is built then (or at Changed/PanelChanged).
ui.Calendar(c, &day).CellRender(func(d time.Time) { ... })
ui.Calendar(c, &day).Card().DisabledDate(isWeekend)
func (*CalendarW) Card 实验性
func (w *CalendarW) Card() *CalendarWCard uses Ant's compact card mode (fullscreen=false).
func (*CalendarW) CellHeight 实验性
func (w *CalendarW) CellHeight(px float32) *CalendarWCellHeight overrides the fullscreen cell height.
func (*CalendarW) CellRender 实验性
func (w *CalendarW) CellRender(fn func(d time.Time)) *CalendarWCellRender adds content below the date in month view.
func (*CalendarW) Changed 实验性
func (w *CalendarW) Changed() boolChanged reports a date pick.
func (*CalendarW) ControllerType 实验性
func (w *CalendarW) ControllerType(t string) *CalendarWControllerType sets the Element header's month navigation: "button" (previous / today / next, default) or "select" (year and month selects; Element controller-type). The Ant header always uses selects.
func (*CalendarW) DisabledDate 实验性
func (w *CalendarW) DisabledDate(fn func(d time.Time) bool) *CalendarWDisabledDate greys out and blocks dates.
func (*CalendarW) Formatter 实验性
func (w *CalendarW) Formatter(fn func(v int, kind string) string) *CalendarWFormatter formats the labels of the header's year and month selects: fn(v, kind) gets the year or the month number (1-12) and kind "year" or "month" (Element formatter); empty results fall back to the default.
func (*CalendarW) Layout 实验性
func (w *CalendarW) Layout(o ...layout.Option) *CalendarWLayout applies layout options to the calendar.
func (*CalendarW) Mode 实验性
func (w *CalendarW) Mode(m *string) *CalendarWMode binds the view mode ("month" or "year").
func (*CalendarW) MonthCellRender 实验性
func (w *CalendarW) MonthCellRender(fn func(m time.Time)) *CalendarWMonthCellRender adds content below the month in year view.
func (*CalendarW) NoHeader 实验性
func (w *CalendarW) NoHeader() *CalendarWNoHeader hides the header.
func (*CalendarW) PanelChanged 实验性
func (w *CalendarW) PanelChanged() boolPanelChanged reports a month/year/mode navigation.
func (*CalendarW) Range 实验性
func (w *CalendarW) Range(start, end time.Time) *CalendarWRange shows only the weeks from start to end (Element range): the grid starts with start's week and ends with end's week, the header shows the range instead of the month navigation, days outside [start, end] are greyed out and cannot be picked, and the year view is off. Element asks for a start on the first day of a week and an end on the last day, at most two months apart; other ranges are padded to whole weeks.
func (*CalendarW) ShowWeek 实验性
func (w *CalendarW) ShowWeek(on bool) *CalendarWShowWeek adds a column of week numbers (ISO weeks) before the days of the month view (Ant showWeek).
func (*CalendarW) ValidRange 实验性
func (w *CalendarW) ValidRange(start, end time.Time) *CalendarWValidRange limits the dates that can be picked and shown (Ant validRange): days outside [start, end] are disabled, the header's year and month choices and the month navigation stay inside the range.
CardActionW 实验性
type CardActionW struct {
// contains filtered or unexported fields
}CardActionW is the action slot CardAction returns.
func CardAction 实验性
func CardAction(c *Context, ic *icon.Icon, label string) *CardActionWCardAction is a convenience action slot: a clickable icon (e.g. icon.Setting, icon.Edit, icon.More, icon.Like) in the secondary text color that turns primary on hover. Clicked on the result reports an activation.
func (*CardActionW) Clicked 实验性
func (a *CardActionW) Clicked() boolClicked reports whether the action was activated this frame.
CardMetaW 实验性
type CardMetaW struct {
*Box
// contains filtered or unexported fields
}CardMetaW is the Card.Meta block CardMeta returns; it embeds the row's Box.
func CardMeta 实验性
func CardMeta(c *Context, avatar func(), title, desc string) *CardMetaWCardMeta lays out Card.Meta: avatar on the left, title and description.
CardW
type CardW struct {
// contains filtered or unexported fields
}CardW is a bordered container: cover, header with extra, body, action bar, footer, loading skeleton, inner type, hover/always/never shadow.
func Card
func Card(c *Context, title string) *CardWCard starts a card ("" title = no header); set options then call Body.
ConfigProvider.Defaults("Card", ...) keys: "size" ("small" / Small), "variant" ("outlined" | "borderless"; the deprecated "bordered" bool is still read), "hoverable" (bool), "shadow" (Element: "always" | "hover" | "never"), "type" ("inner").
func (*CardW) Actions
func (w *CardW) Actions(fns ...func()) *CardWActions adds the bottom action bar; each fn builds one equal-width slot.
func (*CardW) Body
func (w *CardW) Body(fn func()) *CardWBody builds the card.
func (*CardW) Borderless
func (w *CardW) Borderless() *CardWBorderless removes the border.
Deprecated: use Variant("borderless") (antd 6 replaced bordered with variant).
func (*CardW) Clicked
func (w *CardW) Clicked() boolClicked reports a click on a hoverable card.
func (*CardW) Cover
func (w *CardW) Cover(fn func()) *CardWCover places content (usually an image) above the header, edge to edge.
func (*CardW) Extra
func (w *CardW) Extra(fn func()) *CardWfunc (*CardW) Footer
func (w *CardW) Footer(fn func()) *CardWFooter adds an Element-style footer below the body.
func (*CardW) Hoverable
func (w *CardW) Hoverable() *CardWHoverable lifts the card with a shadow on hover.
func (*CardW) Inner
func (w *CardW) Inner() *CardWInner uses Ant's inner-card header (grey header band).
func (*CardW) Layout
func (w *CardW) Layout(o ...layout.Option) *CardWLayout applies layout options to the card.
func (*CardW) Loading
func (w *CardW) Loading(on bool) *CardWLoading shows an active skeleton instead of the body.
func (*CardW) Padding
func (w *CardW) Padding(in geom.Insets) *CardWPadding overrides the body padding.
func (*CardW) Shadow
func (w *CardW) Shadow(mode string) *CardWShadow sets the shadow mode: "always", "hover" or "never" (Element's el-card shadow prop). The default comes from the theme (CardToken.ShadowAlways: never for Ant, except a borderless card, which keeps a soft shadow; always for Element and shadcn).
func (*CardW) Small
func (w *CardW) Small() *CardWSmall uses the compact header and padding.
func (*CardW) TabBarExtra
func (w *CardW) TabBarExtra(fn func()) *CardWTabBarExtra builds content at the end of the card's tab bar (Ant tabBarExtraContent).
func (*CardW) TabChanged
func (w *CardW) TabChanged() boolTabChanged reports that the user switched tabs this frame (Ant onTabChange). Call it after Body.
func (*CardW) Tabs
func (w *CardW) Tabs(active *string, items []TabItem) *CardWTabs adds a tab bar under the title (Ant tabList / activeTabKey): it switches *active, and the body is built as the active tab's panel, so Body's fn shows the content for *active. Without a title the tab bar is the whole header.
func (*CardW) Variant
func (w *CardW) Variant(v string) *CardWVariant sets the card variant (antd 6 variant): "outlined" (the default, a 1px outline) or "borderless" (no outline; an Ant card then keeps a soft shadow, antd .ant-card:not(.ant-card-bordered)).
CarouselLocale 实验性
type CarouselLocale struct {
Prev, Next string
// contains filtered or unexported fields
}CarouselLocale holds the accessible names of the Carousel arrows.
CarouselW 实验性
type CarouselW struct {
// contains filtered or unexported fields
}CarouselW is a slideshow: scroll or fade transitions, autoplay with pause on hover, indicator dots/lines and arrows.
func Carousel 实验性
func Carousel(c *Context, n int, slide func(i int)) *CarouselWCarousel adds a slideshow of n slides; slide(i) builds slide i.
ConfigProvider.Defaults("Carousel", ...) keys: "autoplay" (time.Duration), "dots" (bool), "arrows" (string), "dotPlacement" ("top" | "bottom" | "start" | "end"; the deprecated "dotPosition" also takes "left" | "right" | "outside"), "type" ("card"), "effect" ("fade"), "height" (float32), "trigger" ("click" | "hover"), "pauseOnHover" (bool).
The index bound with Current is clamped to [0, n): an index past the ends shows the first or last slide.
func (*CarouselW) Arrows 实验性
func (w *CarouselW) Arrows(mode string) *CarouselWArrows: "always", "hover" or "never". The arrows sit ArrowOffset px inside the frame (theme token CarouselToken.ArrowOffset); a negative offset (shadcn's -left-12 is -48) puts them outside, which needs that much free room beside the carousel or they are clipped by the parent.
func (*CarouselW) Autoplay 实验性
func (w *CarouselW) Autoplay(d time.Duration) *CarouselWAutoplay advances every d (0 disables).
func (*CarouselW) Card 实验性
func (w *CarouselW) Card() *CarouselWCard shows three slides at once: the current one in the middle and its neighbours scaled down and dimmed at the sides (Element type="card"); clicking a side card moves to it.
func (*CarouselW) CardScale 实验性
func (w *CarouselW) CardScale(k float32) *CarouselWCardScale sets the scale of the side cards of Card mode (Element cards-scale, default 0.83).
func (*CarouselW) Changed 实验性
func (w *CarouselW) Changed() boolChanged reports a slide change in the last Show.
func (*CarouselW) Current 实验性
func (w *CarouselW) Current(i *int) *CarouselWCurrent binds the active slide index.
func (*CarouselW) DotDuration 实验性
func (w *CarouselW) DotDuration(on bool) *CarouselWDotDuration fills the active indicator over the autoplay interval, as a progress bar (Ant autoplay.dotDuration).
func (*CarouselW) DotOutside 实验性
func (w *CarouselW) DotOutside() *CarouselWDotOutside puts the indicators under the frame, on the page (Element indicator-position="outside").
func (*CarouselW) DotPlacement 实验性
func (w *CarouselW) DotPlacement(p string) *CarouselWDotPlacement puts the indicators at the "bottom" (default), "top", "start" or "end" (Ant v6 dotPlacement; logical sides, mirrored in RTL). "start" and "end" also make the slides move vertically, as in Ant.
func (*CarouselW) DotPosition 实验性
func (w *CarouselW) DotPosition(p string) *CarouselWDotPosition: bottom, top, left, right, or outside (below the frame, Element indicator-position="outside").
Deprecated: use DotPlacement (and Dots / DotOutside for "outside").
func (*CarouselW) Dots 实验性
func (w *CarouselW) Dots(on bool) *CarouselWDots shows/hides the indicators.
func (*CarouselW) Draggable 实验性
func (w *CarouselW) Draggable(on bool) *CarouselWDraggable lets a pointer drag or a finger swipe move the slides: the slides follow the pointer, and on release a travel past the swipe threshold (or a quick flick) turns the page, otherwise they spring back. Drags that start on a control inside a slide are taken over once they move sideways.
func (*CarouselW) Fade 实验性
func (w *CarouselW) Fade() *CarouselWFade cross-fades instead of sliding.
func (*CarouselW) Height 实验性
func (w *CarouselW) Height(px float32) *CarouselWHeight sets the frame height.
func (*CarouselW) Loop 实验性
func (w *CarouselW) Loop(on bool) *CarouselWLoop(false) stops at the ends: the first slide has no previous one and the last no next one (arrows and keys do nothing there, the arrows look disabled, autoplay stops at the last slide). Default true.
func (*CarouselW) PauseOnHover 实验性
func (w *CarouselW) PauseOnHover(on bool) *CarouselWPauseOnHover(false) keeps autoplay running while the pointer is over the carousel (default true; Ant / Element pause-on-hover). Keyboard focus inside still pauses it (WAI-ARIA).
func (*CarouselW) Show 实验性
func (w *CarouselW) Show() *BoxShow builds the carousel.
func (*CarouselW) SwipeThreshold 实验性
func (w *CarouselW) SwipeThreshold(frac float32) *CarouselWSwipeThreshold sets the fraction of the slide size a drag must travel to turn the page (default 0.2).
func (*CarouselW) Trigger 实验性
func (w *CarouselW) Trigger(t string) *CarouselWTrigger sets how the indicators select a slide: "click" (Ant) or "hover" (Element's default). The theme picks the default.
func (*CarouselW) Vertical 实验性
func (w *CarouselW) Vertical() *CarouselWVertical slides up/down (indicators on the right).
CascaderOption 实验性
type CascaderOption struct {
Label, Value string
Disabled bool
Children []CascaderOption
IsLeaf bool // never has children (relevant with LoadData)
}CascaderOption is a node of a Cascader tree. With LoadData, a node without Children that is not IsLeaf loads its children when expanded.
CascaderPanelW 实验性
type CascaderPanelW struct {
// contains filtered or unexported fields
}CascaderPanelW is an inline cascader; chain options, read Changed.
func CascaderPanel 实验性
func CascaderPanel(c *Context, val *[]string, opts []CascaderOption) *CascaderPanelWCascaderPanel adds the column menus of a Cascader inline, bound to *val (the selected value path). Clicking a leaf selects it (the menus stay); the panel is one Tab stop whose arrow keys move through the columns (Right / Enter opens the next column, Left goes back; mirrored in RTL), Enter / Space on a leaf selects it.
ui.CascaderPanel(c, &path, options).ChangeOnSelect()
func (*CascaderPanelW) A11yLabel 实验性
func (p *CascaderPanelW) A11yLabel(s string) *CascaderPanelWA11yLabel names the panel and its first column (default: the generic "please select").
func (*CascaderPanelW) Border 实验性
func (p *CascaderPanelW) Border(on bool) *CascaderPanelWBorder toggles the panel frame (default on).
func (*CascaderPanelW) ChangeOnSelect 实验性
func (p *CascaderPanelW) ChangeOnSelect() *CascaderPanelWChangeOnSelect selects parents too (clicking a parent selects it and opens its column).
func (*CascaderPanelW) Changed 实验性
func (p *CascaderPanelW) Changed() boolChanged reports a new selection this frame.
func (*CascaderPanelW) CheckedPaths 实验性
func (p *CascaderPanelW) CheckedPaths() [][]stringCheckedPaths returns the checked paths of multiple mode by the checked strategy.
func (*CascaderPanelW) DataVersion 实验性
func (p *CascaderPanelW) DataVersion(v int) *CascaderPanelWDataVersion tells the panel that the options were modified in place (see CascaderW.DataVersion): change v after editing options of the same slice without changing its length.
func (*CascaderPanelW) Disabled 实验性
func (p *CascaderPanelW) Disabled(on bool) *CascaderPanelWDisabled turns the panel off.
func (*CascaderPanelW) Expand 实验性
func (p *CascaderPanelW) Expand(path ...string) *CascaderPanelWExpand sets the expanded path (by default it follows the value).
func (*CascaderPanelW) ExpandOnHover 实验性
func (p *CascaderPanelW) ExpandOnHover() *CascaderPanelWExpandOnHover opens a parent's column on hover.
func (*CascaderPanelW) Height 实验性
func (p *CascaderPanelW) Height(px float32) *CascaderPanelWHeight sets the column height (default: the Cascader token's DropdownHeight).
func (*CascaderPanelW) ID 实验性
func (p *CascaderPanelW) ID() IDID returns the panel's ID.
func (*CascaderPanelW) LoadData 实验性
func (p *CascaderPanelW) LoadData(fn func(path []string, done func([]CascaderOption))) *CascaderPanelWLoadData loads children lazily (see CascaderW.LoadData).
func (*CascaderPanelW) Multiple 实验性
func (p *CascaderPanelW) Multiple(vals *[][]string) *CascaderPanelWMultiple switches to checkboxes bound to *vals (the checked leaf paths; see ShowCheckedStrategy and StrategyValue).
func (*CascaderPanelW) ShowCheckedStrategy 实验性
func (p *CascaderPanelW) ShowCheckedStrategy(s CheckedStrategy) *CascaderPanelWShowCheckedStrategy sets the checked strategy of multiple mode (see CascaderW.ShowCheckedStrategy); CheckedPaths returns its paths.
func (*CascaderPanelW) StrategyValue 实验性
func (p *CascaderPanelW) StrategyValue(on bool) *CascaderPanelWStrategyValue makes the bound value of multiple mode follow the checked strategy (see CascaderW.StrategyValue).
func (*CascaderPanelW) Virtual 实验性
func (p *CascaderPanelW) Virtual(on bool) *CascaderPanelWVirtual forces virtual columns on or off (see CascaderW.Virtual; by default columns longer than 100 options are virtual).
CascaderW 实验性
type CascaderW struct {
// contains filtered or unexported fields
}CascaderW selects a path in a tree through cascading menus.
func Cascader 实验性
func Cascader(c *Context, val *[]string, opts []CascaderOption) *CascaderWCascader adds a cascading select bound to *val (the selected value path).
func (*CascaderW) A11yLabel 实验性
func (w *CascaderW) A11yLabel(s string) *CascaderWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*CascaderW) AllowClear 实验性
func (w *CascaderW) AllowClear() *CascaderWfunc (*CascaderW) ChangeOnSelect 实验性
func (w *CascaderW) ChangeOnSelect() *CascaderWfunc (*CascaderW) Changed 实验性
func (w *CascaderW) Changed() boolChanged reports a new selection this frame.
func (*CascaderW) CheckedPaths 实验性
func (w *CascaderW) CheckedPaths() [][]stringCheckedPaths returns the checked paths of multiple mode by the checked strategy (the paths shown as tags).
func (*CascaderW) DataVersion 实验性
func (w *CascaderW) DataVersion(v int) *CascaderWDataVersion tells the cascader that the options were modified in place (a virtual column caches its width by slice identity, length and this number): after editing options of the same slice without changing its length, change v (or pass a new slice) so the widths are recomputed on the next frame.
func (*CascaderW) Disabled 实验性
func (w *CascaderW) Disabled(on bool) *CascaderWfunc (*CascaderW) DisplayRender 实验性
func (w *CascaderW) DisplayRender(fn func(labels []string, path []CascaderOption) string) *CascaderWDisplayRender sets the text shown for the selected path (single selection; default the labels joined by " / "): fn receives the labels and the options of the path, root first (Ant displayRender, Element show-all-levels / separator). A value no longer in the tree shows as an option whose Label and Value are the stored value.
ui.Cascader(c, &v, opts).DisplayRender(func(ls []string, _ []ui.CascaderOption) string { return ls[len(ls)-1] })
func (*CascaderW) Expand 实验性
func (w *CascaderW) Expand(path ...string) *CascaderWExpand sets the expanded path of an open menu (screenshots).
func (*CascaderW) ExpandOnHover 实验性
func (w *CascaderW) ExpandOnHover() *CascaderWfunc (*CascaderW) FilterMethod 实验性
func (w *CascaderW) FilterMethod(fn func(query string, path []CascaderOption) bool) *CascaderWFilterMethod replaces the search match (by default the "a / b / c" label path containing the typed text, case-insensitively) with fn: it receives the typed text and the options along a candidate path, root first (Ant showSearch.filter, Element filter-method). Implies Searchable.
ui.Cascader(c, &v, opts).FilterMethod(func(q string, p []ui.CascaderOption) bool {
return strings.HasPrefix(p[len(p)-1].Value, q)
})
func (*CascaderW) IsOpen 实验性
func (w *CascaderW) IsOpen() boolIsOpen reports whether the menus are shown.
func (*CascaderW) Layout 实验性
func (w *CascaderW) Layout(o ...layout.Option) *CascaderWfunc (*CascaderW) LoadData 实验性
func (w *CascaderW) LoadData(fn func(path []string, done func([]CascaderOption))) *CascaderWLoadData enables lazy loading: expanding an option that has no Children and is not IsLeaf calls fn with its value path; fn (now or later, on any goroutine) calls done with the children. A spinner replaces the arrow meanwhile; done(nil) marks the option as a leaf.
ui.Cascader(c, &v, roots).LoadData(func(path []string, done func([]ui.CascaderOption)) {
go func() { done(fetchChildren(path)) }()
})
func (*CascaderW) MaxTagCount 实验性
func (w *CascaderW) MaxTagCount(n int) *CascaderWfunc (*CascaderW) MaxTagPlaceholder 实验性
func (w *CascaderW) MaxTagPlaceholder(fn func(omitted []string) string) *CascaderWMaxTagPlaceholder builds the text of the collapsed tag of multiple mode from the hidden labels (Ant maxTagPlaceholder; default "+ N ...").
func (*CascaderW) Multiple 实验性
func (w *CascaderW) Multiple(vals *[][]string) *CascaderWfunc (*CascaderW) NotFoundContent 实验性
func (w *CascaderW) NotFoundContent(s string) *CascaderWNotFoundContent sets the text shown when a search finds nothing (Ant notFoundContent, Element empty slot).
func (*CascaderW) Open 实验性
func (w *CascaderW) Open() *CascaderWOpen forces the menus open (screenshots, tests).
func (*CascaderW) Placeholder 实验性
func (w *CascaderW) Placeholder(s string) *CascaderWfunc (*CascaderW) Placement 实验性
func (w *CascaderW) Placement(p Placement) *CascaderWPlacement sets where the menus open: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement, Element placement); they flip when there is no room. ConfigProvider.Defaults("Cascader", "placement") takes the Ant names.
func (*CascaderW) Searchable 实验性
func (w *CascaderW) Searchable() *CascaderWfunc (*CascaderW) Separator 实验性
func (w *CascaderW) Separator(s string) *CascaderWSeparator sets the text between path labels in the selected value, tags and search results (Element separator; default " / " as Ant's displayRender). "" joins the labels directly.
func (*CascaderW) ShowCheckedStrategy 实验性
func (w *CascaderW) ShowCheckedStrategy(s CheckedStrategy) *CascaderWShowCheckedStrategy chooses the tags of multiple mode (default ShowParent: a fully checked parent replaces its children; ShowChild: every checked leaf; ShowAll: every checked node). By default the bound value holds the checked leaf paths and CheckedPaths returns the strategy's paths; with StrategyValue(true) the bound value itself follows the strategy (Ant).
func (*CascaderW) Size 实验性
func (w *CascaderW) Size(s ControlSize) *CascaderWfunc (*CascaderW) Status 实验性
func (w *CascaderW) Status(s string) *CascaderWfunc (*CascaderW) StrategyValue 实验性
func (w *CascaderW) StrategyValue(on bool) *CascaderWStrategyValue makes the bound value of multiple mode follow the checked strategy, as Ant's value does (ShowParent, the default, stores a fully checked parent path instead of its leaf paths). Paths written by the application are read the same way: a parent path checks its subtree. Default false: the value holds the checked leaf paths (what earlier versions stored).
func (*CascaderW) Variant 实验性
func (w *CascaderW) Variant(v FieldVariant) *CascaderWVariant sets the frame look (FieldOutlined by default).
func (*CascaderW) Virtual 实验性
func (w *CascaderW) Virtual(on bool) *CascaderWVirtual forces virtual columns on or off; by default a column (or a search result list) longer than 100 options is virtual: only its visible rows and the row on the expanded path are built. The column keeps the width, height and scroll range of the full list (its width is measured once while the column's options slice, identity and length, and the DataVersion stay the same: an option renamed in place does not change the column's width until one of them changes), but options out of view are not in the accessibility tree. Search results are matched and measured every frame. Virtual(false) builds every row.
func (*CascaderW) Width 实验性
func (w *CascaderW) Width(px float32) *CascaderWCellEditorTableW 实验性
type CellEditorTableW[T any] struct {
// contains filtered or unexported fields
}CellEditorTableW is an editable table that edits one cell at a time (Pro Components v3 CellEditorTable): double-click a cell of a column with an Editor (or press Enter on the keyboard-active cell) to edit it; Enter or moving focus away validates that cell and saves the row, Escape cancels and drops the draft. Only the edited column is validated. It is an EditableProTable preset (same editors, validation and OnSave flow), bordered and without pagination by default.
func CellEditorTable 实验性
func CellEditorTable[T any](c *Context, cols []ProColumn[T], rows *[]T) *CellEditorTableW[T]CellEditorTable starts a cell-editing table over *rows; chain options, then Show.
ConfigProvider.Defaults("CellEditorTable", ...) keys: "bordered" (bool, default true), "size", "pagination" (page size or Props{"pageSize": n}; default none).
func (*CellEditorTableW[T]) Bordered 实验性
func (w *CellEditorTableW[T]) Bordered(on bool) *CellEditorTableW[T]Bordered turns the cell borders on or off (default on).
func (*CellEditorTableW[T]) Cancel 实验性
func (w *CellEditorTableW[T]) Cancel()Cancel leaves the edited cell without saving (as Escape does).
func (*CellEditorTableW[T]) Changed 实验性
func (w *CellEditorTableW[T]) Changed() boolChanged reports a change of *rows in the last Show.
func (*CellEditorTableW[T]) Edit 实验性
func (w *CellEditorTableW[T]) Edit(k, col string)Edit starts editing the cell of row key k in column col (valid after Show; ignored for a column without an Editor).
func (*CellEditorTableW[T]) EditingCell 实验性
func (w *CellEditorTableW[T]) EditingCell() (key, col string)EditingCell returns the row key and column key of the edited cell ("" when none).
func (*CellEditorTableW[T]) Errors 实验性
func (w *CellEditorTableW[T]) Errors(k string) map[string]stringErrors returns the validation messages of row k by column key.
func (*CellEditorTableW[T]) ID 实验性
func (w *CellEditorTableW[T]) ID() IDID returns the widget ID (valid after Show).
func (*CellEditorTableW[T]) OnSave 实验性
func (w *CellEditorTableW[T]) OnSave(fn func(row T, index int, done func(error))) *CellEditorTableW[T]OnSave receives the row with the validated cell applied before it is written back (see EditableProTableW.OnSave).
func (*CellEditorTableW[T]) Pagination 实验性
func (w *CellEditorTableW[T]) Pagination(n int) *CellEditorTableW[T]Pagination pages the rows locally, n per page (default: no pagination).
func (*CellEditorTableW[T]) RowEditable 实验性
func (w *CellEditorTableW[T]) RowEditable(fn func(row T) bool) *CellEditorTableW[T]RowEditable limits which rows can be edited.
func (*CellEditorTableW[T]) RowKey 实验性
func (w *CellEditorTableW[T]) RowKey(f func(T) string) *CellEditorTableW[T]RowKey gives rows stable keys (default: the row index).
func (*CellEditorTableW[T]) Save 实验性
func (w *CellEditorTableW[T]) Save()Save validates the edited cell and saves its row (as Enter does).
func (*CellEditorTableW[T]) Saved 实验性
func (w *CellEditorTableW[T]) Saved() boolSaved reports a row written back in the last Show.
func (*CellEditorTableW[T]) ScrollX 实验性
func (w *CellEditorTableW[T]) ScrollX(px float32) *CellEditorTableW[T]ScrollX sets the table's scroll width.
func (*CellEditorTableW[T]) ScrollY 实验性
func (w *CellEditorTableW[T]) ScrollY(maxH float32) *CellEditorTableW[T]ScrollY bounds the table body to maxH (EditableProTableW.ScrollY): only the visible rows are built. The edited cell's row is always built, even scrolled out of view, so its draft and focus survive; starting to edit it (Edit), focus moving into it (Tab), typing in it and a failed validation scroll it into view. Default 0: unbounded, every row is built.
func (*CellEditorTableW[T]) Show 实验性
func (w *CellEditorTableW[T]) Show() *CellEditorTableW[T]Show builds the table.
func (*CellEditorTableW[T]) Size 实验性
func (w *CellEditorTableW[T]) Size(s ControlSize) *CellEditorTableW[T]Size sets the density.
func (*CellEditorTableW[T]) Table 实验性
func (w *CellEditorTableW[T]) Table() *TableWTable returns the inner table of the last Show.
func (*CellEditorTableW[T]) Title 实验性
func (w *CellEditorTableW[T]) Title(s string) *CellEditorTableW[T]Title sets the toolbar title.
func (*CellEditorTableW[T]) ToolBar 实验性
func (w *CellEditorTableW[T]) ToolBar(fn func()) *CellEditorTableW[T]ToolBar adds actions at the right of the toolbar.
func (*CellEditorTableW[T]) Validating 实验性
func (w *CellEditorTableW[T]) Validating(k string) boolValidating reports async validation or a save in flight for row k.
func (*CellEditorTableW[T]) Virtual 实验性
func (w *CellEditorTableW[T]) Virtual() *CellEditorTableW[T]Virtual is TableW.Virtual for the inner table (see EditableProTableW.Virtual): with ScrollY the body is windowed either way; rows keep the height of the density (Size) unless the theme has a Table V2 row height (Element Plus).
ChainItem 实验性
type ChainItem struct {
Key string // stable key (default: the index)
Title string
Description string // secondary line under the title
Status ChainStatus //
Duration time.Duration // shown at the end (0: hidden)
Started time.Time // a running step shows the time elapsed since then
Detail string // collapsible Markdown detail
Content func() // collapsible custom detail (instead of Detail)
// contains filtered or unexported fields
}ChainItem is one step of a ThoughtChain.
ChainStatus 实验性
type ChainStatus uint8ChainStatus is the state of a step or tool call.
const (
ChainPending ChainStatus = iota // not started
ChainRunning // in progress (spinner, live duration)
ChainSuccess
ChainError
)实验性
ChartLocale 实验性
type ChartLocale struct {
Line, Area, Column, Bar, Pie, Donut, Scatter, Radar, Gauge, Funnel, Heatmap, DualAxes, Liquid, Sparkline string
SummaryFmt string // args: kind, series count, point count ("%[1]s,%[2]d 个系列,%[3]d 个数据点")
XRangeFmt string // appended to the summary, args: first, last x (";横轴从 %s 到 %s")
YRangeFmt string // appended to the summary, args: min, max value (";数值从 %s 到 %s")
ValueFmt string // single-value charts, args: kind, value ("%s:%s")
Total string // pie / donut centre title ("总计")
Conversion string // funnel conversion-rate label ("转化率")
// contains filtered or unexported fields
}ChartLocale holds the accessible names and summaries of ui/chart charts: the chart kinds (default names) and the summary read as the description.
ChatAttachment 实验性
type ChatAttachment struct {
Name string
Size int64 // bytes (0: not shown)
Image image.Image // thumbnail of an image (nil: file icon)
Status string // "" ready, "uploading" or "error"
Percent float32 // upload progress 0..100 while uploading
// contains filtered or unexported fields
}ChatAttachment is a file attached to a message being composed.
ChatLocale 实验性
type ChatLocale struct {
User, Assistant, System string // role names (accessible names of bubbles)
Messages string // accessible name of a BubbleList
ScrollToBottom string // BubbleList "back to bottom" button
Thinking string // loading bubble (accessible name)
Generating string // streaming bubble (accessible description)
Placeholder string // Sender placeholder
Send, Stop, Attach string // Sender buttons
Suggestions string // accessible name of the @ / command popup
Uploading, Failed string // attachment states
EditPlaceholder string // inline edit of a user message
Pending, Running string // step states
Done, Error string
StepsFmt string // chain progress, args: done, total ("%d/%d")
SecondsFmt string // duration under a minute, arg: seconds as float ("%.1fs")
MinutesFmt string // longer duration, args: minutes, seconds ("%dm %ds")
ToolCall string // accessible name prefix of a tool card
Arguments, Result string // tool card sections
ApprovalTitle string // default Approval title
AllowOnce string
AllowSession string
AllowAlways string
Deny string
Allowed, Denied string // decided Approval
FeedbackPlaceholder string // optional note sent with a decision
RiskWarning string // risk tag of a warning-level request
RiskDanger string // risk tag of a dangerous request
Conversations string // accessible name of the list
Rename string
Untitled string // conversation without a title
Today, Yesterday string // time groups
Last7Days string
Last30Days string
Earlier string
Prompts string // accessible name of a Prompts group
// contains filtered or unexported fields
}ChatLocale holds the texts of the AI chat components (Bubble, BubbleList, Sender, ThoughtChain, ToolCall, Approval, Conversations, Prompts). Copy, Copied, Retry, Edit, Save and Cancel come from the common Locale fields.
ChatRole 实验性
type ChatRole uint8ChatRole is the author of a chat message.
const (
ChatAssistant ChatRole = iota // start-aligned, Markdown content
ChatUser // end-aligned filled bubble, plain text
ChatSystem // centered notice without avatar
)实验性
CheckAllW 实验性
type CheckAllW struct {
// contains filtered or unexported fields
}CheckAllW is the select-all group CheckAll returns.
func CheckAll 实验性
func CheckAll(c *Context, selected *[]string, opts []Option) *CheckAllWCheckAll renders a "全选" checkbox (indeterminate when only part of the options is selected) above a checkbox group bound to *selected. Disabled options keep their state. Changed on the result reports a selection change.
func (*CheckAllW) Changed 实验性
func (w *CheckAllW) Changed() boolChanged reports whether the selection changed this frame.
CheckCardGroupW 实验性
type CheckCardGroupW struct {
// contains filtered or unexported fields
}CheckCardGroupW builds a single- or multiple-choice card group.
func CheckCardGroup 实验性
func CheckCardGroup(c *Context, opts []CheckCardOption) *CheckCardGroupWCheckCardGroup starts a group. Value / Values bind application state; without a binding the group owns its state, initialized by DefaultValue or DefaultValues. Values also selects multiple-choice mode.
func (*CheckCardGroupW) Body 实验性
func (g *CheckCardGroupW) Body(fn func()) *CheckCardGroupWBody builds custom CheckCards linked to this group by Value.
func (*CheckCardGroupW) Borderless 实验性
func (g *CheckCardGroupW) Borderless() *CheckCardGroupWBorderless removes option card borders.
func (*CheckCardGroupW) Changed 实验性
func (g *CheckCardGroupW) Changed() boolChanged reports a user selection change this frame.
func (*CheckCardGroupW) DefaultValue 实验性
func (g *CheckCardGroupW) DefaultValue(v string) *CheckCardGroupWDefaultValue sets the initial single selection, ignored when bound.
func (*CheckCardGroupW) DefaultValues 实验性
func (g *CheckCardGroupW) DefaultValues(v ...string) *CheckCardGroupWDefaultValues sets initial multiple selections, ignored when bound.
func (*CheckCardGroupW) Disabled 实验性
func (g *CheckCardGroupW) Disabled(on bool) *CheckCardGroupWDisabled disables every card.
func (*CheckCardGroupW) Layout 实验性
func (g *CheckCardGroupW) Layout(opts ...layout.Option) *CheckCardGroupWLayout sets wrapping-row layout options.
func (*CheckCardGroupW) Loading 实验性
func (g *CheckCardGroupW) Loading(on bool) *CheckCardGroupWLoading shows noninteractive, unchecked loading placeholders.
func (*CheckCardGroupW) Multiple 实验性
func (g *CheckCardGroupW) Multiple() *CheckCardGroupWMultiple enables multiple choices with internally owned state.
func (*CheckCardGroupW) Selected 实验性
func (g *CheckCardGroupW) Selected() stringSelected reports the single selection after Show / Body.
func (*CheckCardGroupW) SelectedValues 实验性
func (g *CheckCardGroupW) SelectedValues() []stringSelectedValues reports a copy of the multiple selections after Show / Body.
func (*CheckCardGroupW) Show 实验性
func (g *CheckCardGroupW) Show() *CheckCardGroupWShow renders the configured options.
func (*CheckCardGroupW) Size 实验性
func (g *CheckCardGroupW) Size(s ControlSize) *CheckCardGroupWSize sets the group size.
func (*CheckCardGroupW) Value 实验性
func (g *CheckCardGroupW) Value(v *string) *CheckCardGroupWValue binds the single choice. Re-clicking a selected card clears it.
func (*CheckCardGroupW) Values 实验性
func (g *CheckCardGroupW) Values(v *[]string) *CheckCardGroupWValues binds multiple choices, maintained in option order.
func (*CheckCardGroupW) Width 实验性
func (g *CheckCardGroupW) Width(px float32) *CheckCardGroupWWidth overrides every option card's width.
CheckCardOption 实验性
type CheckCardOption struct {
Value string
Title string
Description string
Avatar string // text avatar (first character)
Icon *icon.Icon // icon avatar
Disabled bool
Size ControlSize // zero without SizeSet: inherit group size
SizeSet bool // allows explicit Middle to override the group size
Cover func()
Children []CheckCardOption
// contains filtered or unexported fields
}CheckCardOption is one card of a CheckCardGroup.
CheckCardW 实验性
type CheckCardW struct {
// contains filtered or unexported fields
}CheckCardW builds a checkable card.
func CheckCard 实验性
func CheckCard(c *Context, title string, checked *bool) *CheckCardWCheckCard starts a checkable card bound to checked; chain options, then Show.
func (*CheckCardW) Actions 实验性
func (w *CheckCardW) Actions(fns ...func()) *CheckCardWActions builds the bottom action bar.
func (*CheckCardW) Avatar 实验性
func (w *CheckCardW) Avatar(s string) *CheckCardWAvatar shows a text avatar (first character) left of the title.
func (*CheckCardW) AvatarIcon 实验性
func (w *CheckCardW) AvatarIcon(ic *icon.Icon) *CheckCardWAvatarIcon shows an icon avatar left of the title.
func (*CheckCardW) Borderless 实验性
func (w *CheckCardW) Borderless() *CheckCardWBorderless removes the border (the checked state still colors it).
func (*CheckCardW) Changed 实验性
func (w *CheckCardW) Changed() boolChanged reports a toggle by the user this frame (after Show).
func (*CheckCardW) Clicked 实验性
func (w *CheckCardW) Clicked() boolClicked reports a click this frame (after Show).
func (*CheckCardW) Content 实验性
func (w *CheckCardW) Content(fn func()) *CheckCardWContent builds body content below the card's metadata.
func (*CheckCardW) Cover 实验性
func (w *CheckCardW) Cover(fn func()) *CheckCardWCover replaces the content with fn (an image or any block).
func (*CheckCardW) DefaultChecked 实验性
func (w *CheckCardW) DefaultChecked(on bool) *CheckCardWDefaultChecked sets the initial checked state when checked is nil.
func (*CheckCardW) Description 实验性
func (w *CheckCardW) Description(s string) *CheckCardWDescription sets the secondary text under the title.
func (*CheckCardW) Disabled 实验性
func (w *CheckCardW) Disabled(on bool) *CheckCardWDisabled disables the card.
func (*CheckCardW) Extra 实验性
func (w *CheckCardW) Extra(fn func()) *CheckCardWExtra builds content at the top right.
func (*CheckCardW) ID 实验性
func (w *CheckCardW) ID() IDID returns the card's widget ID (after Show).
func (*CheckCardW) IsChecked 实验性
func (w *CheckCardW) IsChecked() boolIsChecked reports the current selection after Show.
func (*CheckCardW) Large 实验性
func (w *CheckCardW) Large() *CheckCardWLarge is Size(Large).
func (*CheckCardW) Loading 实验性
func (w *CheckCardW) Loading(on bool) *CheckCardWLoading shows a skeleton instead of the content.
func (*CheckCardW) Show 实验性
func (w *CheckCardW) Show() *CheckCardWShow builds the card and toggles it on click / Enter / Space.
func (*CheckCardW) Size 实验性
func (w *CheckCardW) Size(s ControlSize) *CheckCardWSize sets the size: Small (212px), Middle (320px) or Large (440px).
func (*CheckCardW) Small 实验性
func (w *CheckCardW) Small() *CheckCardWSmall is Size(Small).
func (*CheckCardW) SubTitle 实验性
func (w *CheckCardW) SubTitle(s string) *CheckCardWSubTitle sets text beside the title.
func (*CheckCardW) Value 实验性
func (w *CheckCardW) Value(s string) *CheckCardWValue sets this card's key when built in CheckCardGroup.Body.
func (*CheckCardW) Width 实验性
func (w *CheckCardW) Width(px float32) *CheckCardWWidth overrides the width of the size.
CheckableTagGroupW 实验性
type CheckableTagGroupW struct {
// contains filtered or unexported fields
}CheckableTagGroupW is a row of checkable tags bound to the selected values.
func CheckableTagGroup 实验性
func CheckableTagGroup(c *Context, selected *[]string, opts []Option) *CheckableTagGroupWCheckableTagGroup renders one CheckableTag per option bound to *selected. Single selection by default: checking a tag replaces the value, unchecking it clears the value (antd value null); Multiple toggles each value. Tags wrap with a gap of 8 (antd paddingXS). A nil selected shows nothing checked and ignores clicks.
ConfigProvider.Defaults("CheckableTagGroup", ...) keys: "multiple" (bool).
func (*CheckableTagGroupW) A11yLabel 实验性
func (g *CheckableTagGroupW) A11yLabel(s string) *CheckableTagGroupWA11yLabel names the group for screen readers.
func (*CheckableTagGroupW) Changed 实验性
func (g *CheckableTagGroupW) Changed() boolChanged reports a selection change this frame.
func (*CheckableTagGroupW) Disabled 实验性
func (g *CheckableTagGroupW) Disabled(on bool) *CheckableTagGroupWDisabled disables every tag of the group.
func (*CheckableTagGroupW) Multiple 实验性
func (g *CheckableTagGroupW) Multiple(on bool) *CheckableTagGroupWMultiple allows several checked tags.
CheckableTagW 实验性
type CheckableTagW struct {
// contains filtered or unexported fields
}CheckableTagW is a tag that toggles between checked and unchecked.
func CheckableTag 实验性
func CheckableTag(c *Context, label string, checked *bool) *CheckableTagWCheckableTag adds a tag bound to *checked; clicking (or Enter/Space when focused) toggles it.
func (*CheckableTagW) A11yLabel 实验性
func (w *CheckableTagW) A11yLabel(s string) *CheckableTagWA11yLabel sets the accessible name (needed for an icon-only tag).
func (*CheckableTagW) Changed 实验性
func (w *CheckableTagW) Changed() boolChanged reports a toggle this frame.
func (*CheckableTagW) Checked 实验性
func (w *CheckableTagW) Checked() boolChecked reports the current value.
func (*CheckableTagW) Disabled 实验性
func (w *CheckableTagW) Disabled(on bool) *CheckableTagWDisabled blocks toggling when on.
func (*CheckableTagW) Icon 实验性
func (w *CheckableTagW) Icon(ic *icon.Icon) *CheckableTagWIcon puts an icon before the label.
func (*CheckableTagW) Type 实验性
func (w *CheckableTagW) Type(status string) *CheckableTagWType tints the checked state with a status palette ("primary" default, "success", "warning", "error", "info"). Element Plus also tints the unchecked state.
CheckboxGroupW
type CheckboxGroupW struct {
// contains filtered or unexported fields
}CheckboxGroupW is the checkbox group CheckboxGroup returns.
func CheckboxGroup
func CheckboxGroup(c *Context, selected *[]string, opts []Option) *CheckboxGroupWCheckboxGroup renders one checkbox per option bound to the selected values. Changed on the result reports a selection change; the builder also takes Disabled, Min/Max, Border, Buttons and Size.
func (*CheckboxGroupW) A11yLabel
func (g *CheckboxGroupW) A11yLabel(s string) *CheckboxGroupWA11yLabel names the group for screen readers.
func (*CheckboxGroupW) Border
func (g *CheckboxGroupW) Border() *CheckboxGroupWBorder draws every checkbox with a frame (see CheckboxW.Border).
func (*CheckboxGroupW) Buttons
func (g *CheckboxGroupW) Buttons() *CheckboxGroupWButtons renders the options as a row of joined toggle buttons (Element el-checkbox-button).
func (*CheckboxGroupW) Changed
func (g *CheckboxGroupW) Changed() boolChanged reports a selection change this frame.
func (*CheckboxGroupW) Disabled
func (g *CheckboxGroupW) Disabled(on bool) *CheckboxGroupWDisabled disables every checkbox of the group.
func (*CheckboxGroupW) Max
func (g *CheckboxGroupW) Max(n int) *CheckboxGroupWMax allows at most n selected values: once n are checked the others are disabled (0 = no maximum).
func (*CheckboxGroupW) Min
func (g *CheckboxGroupW) Min(n int) *CheckboxGroupWMin keeps at least n values selected: while only n are checked they cannot be unchecked (0 = no minimum).
func (*CheckboxGroupW) Size
func (g *CheckboxGroupW) Size(s ControlSize) *CheckboxGroupWSize sets the size of the checkboxes.
CheckboxW
type CheckboxW struct {
// contains filtered or unexported fields
}CheckboxW is a checkbox with a label.
func Checkbox
func Checkbox(c *Context, label string, val *bool) *CheckboxWCheckbox adds a checkbox bound to *val.
func (*CheckboxW) A11yLabel
func (w *CheckboxW) A11yLabel(s string) *CheckboxWA11yLabel sets the accessible name of a checkbox without a visible label.
func (*CheckboxW) Border
func (w *CheckboxW) Border() *CheckboxWBorder draws a frame around the box and the label (Element el-checkbox border); a checked one gets a brand-colored frame.
func (*CheckboxW) Button
func (w *CheckboxW) Button() *CheckboxWButton renders the checkbox as a toggle button without a box (Element el-checkbox-button); checked buttons take the brand color. Inside CheckboxGroup(...).Buttons() the buttons join into a segmented row.
func (*CheckboxW) Changed
func (w *CheckboxW) Changed() boolChanged reports a toggle this frame.
func (*CheckboxW) Disabled
func (w *CheckboxW) Disabled(on bool) *CheckboxWfunc (*CheckboxW) Indeterminate
func (w *CheckboxW) Indeterminate(on bool) *CheckboxWfunc (*CheckboxW) Size
func (w *CheckboxW) Size(s ControlSize) *CheckboxWSize sets the checkbox size: the label font, the box (Element shrinks it when small) and the height of the Border / Button styles.
func (*CheckboxW) Status
func (w *CheckboxW) Status(s string) *CheckboxWStatus sets the validation status ("error" marks the box invalid; inside a failing FormItem it is set automatically).
CheckedStrategy 实验性
type CheckedStrategy intCheckedStrategy chooses which checked nodes of a tree-shaped multiple selection (Cascader, TreeSelect) are shown as tags and returned by Checked (Ant showCheckedStrategy).
Append-only: never reorder or insert; the zero value stays ShowChild.
const (
// ShowChild shows every checked leaf.
ShowChild CheckedStrategy = iota
// ShowParent shows a fully checked parent instead of its children.
ShowParent
// ShowAll shows every checked node, parents and children.
ShowAll
)实验性
CodeBlockLocale 实验性
type CodeBlockLocale struct {
Code string // accessible name of a block without title or language
// contains filtered or unexported fields
}CodeBlockLocale holds the CodeBlock texts (the copy button uses Markdown.CopyCode and Markdown.Copied).
CodeBlockMatch 实验性
type CodeBlockMatch struct {
Start, End int
}CodeBlockMatch is a half-open UTF-8 byte range in the code after CRLF and CR line endings have been normalized to LF.
CodeBlockW 实验性
type CodeBlockW struct {
// contains filtered or unexported fields
}CodeBlockW is a read-only code viewer. Long lines scroll sideways; a block taller than its Height / MaxHeight scrolls and only the visible lines are shaped, so it stays fast for files of hundreds of thousands of lines. The text is selectable (drag, double click a word, triple click or click the line number for a line, Cmd/Ctrl+A) and copies with Cmd/Ctrl+C; the copy button copies everything.
func CodeBlock 实验性
func CodeBlock(c *Context, code string, opts ...layout.Option) *CodeBlockWCodeBlock adds a read-only code block for code (lines separated by "\n"; "\r\n" is accepted).
ui.CodeBlock(c, src).Lang("go").LineNumbers(true).MaxHeight(400)
func (*CodeBlockW) A11yLabel 实验性
func (w *CodeBlockW) A11yLabel(s string) *CodeBlockWA11yLabel sets the accessible name of the code area (default: the title or language).
func (*CodeBlockW) ActiveMatch 实验性
func (w *CodeBlockW) ActiveMatch(index int) *CodeBlockWActiveMatch marks and reveals the zero-based search result at index when the index or result set changes. Pass -1 to clear the active highlight.
func (*CodeBlockW) Copied 实验性
func (w *CodeBlockW) Copied() boolCopied reports a click on the copy button this frame.
func (*CodeBlockW) HeaderStyle 实验性
func (w *CodeBlockW) HeaderStyle(style CodeHeaderStyle) *CodeBlockWHeaderStyle styles the header. An untitled block with a copy button also gets a header when this option is set.
func (*CodeBlockW) Height 实验性
func (w *CodeBlockW) Height(px float32) *CodeBlockWHeight fixes the height of the code area (it scrolls).
func (*CodeBlockW) HighlightLines 实验性
func (w *CodeBlockW) HighlightLines(lines ...int) *CodeBlockWHighlightLines tints lines (numbers as shown, see StartLine).
func (*CodeBlockW) Highlighter 实验性
func (w *CodeBlockW) Highlighter(h CodeHighlighter) *CodeBlockWHighlighter sets the highlighter (default DefaultCodeHighlighter; nil: plain text).
func (*CodeBlockW) ID 实验性
func (w *CodeBlockW) ID() IDID returns the block's ID.
func (*CodeBlockW) Lang 实验性
func (w *CodeBlockW) Lang(lang string) *CodeBlockWLang sets the language for highlighting: an id, alias or file extension ("go", "ts", "python" …).
func (*CodeBlockW) Layout 实验性
func (w *CodeBlockW) Layout(opts ...layout.Option) *CodeBlockWLayout applies layout options to the block.
func (*CodeBlockW) LineNumbers 实验性
func (w *CodeBlockW) LineNumbers(on bool) *CodeBlockWLineNumbers shows the line-number gutter.
func (*CodeBlockW) MaxHeight 实验性
func (w *CodeBlockW) MaxHeight(px float32) *CodeBlockWMaxHeight lets the code area grow with its lines up to px, then scroll. Without Height or MaxHeight the block is as tall as its code.
func (*CodeBlockW) NoCopy 实验性
func (w *CodeBlockW) NoCopy() *CodeBlockWNoCopy hides the copy button.
func (*CodeBlockW) Reveal 实验性
func (w *CodeBlockW) Reveal(offset int) *CodeBlockWReveal scrolls to a UTF-8 byte offset in the normalized code. Call this modifier in response to a navigation action. Offsets outside the document are clamped; offsets inside a rune move to its start.
func (*CodeBlockW) Search 实验性
func (w *CodeBlockW) Search(query string, caseSensitive bool) *CodeBlockWSearch highlights non-overlapping literal matches throughout the code. An empty query clears the highlights. Use SearchMatches to read the ranges.
func (*CodeBlockW) SearchLimit 实验性
func (w *CodeBlockW) SearchLimit(limit int) *CodeBlockWSearchLimit caps the number of retained results in document order. Zero keeps all results, as in Search without this option.
func (*CodeBlockW) SearchMatchCount 实验性
func (w *CodeBlockW) SearchMatchCount() (count int, capped bool)SearchMatchCount returns the number of retained matches without copying their ranges. Capped is true if additional matches were found.
func (*CodeBlockW) SearchMatches 实验性
func (w *CodeBlockW) SearchMatches() []CodeBlockMatchSearchMatches returns a copy of the matches in document order.
func (*CodeBlockW) Selection 实验性
func (w *CodeBlockW) Selection() stringSelection returns the selected text ("" if none).
func (*CodeBlockW) StartLine 实验性
func (w *CodeBlockW) StartLine(n int) *CodeBlockWStartLine sets the number of the first line (default 1).
func (*CodeBlockW) TextID 实验性
func (w *CodeBlockW) TextID() IDTextID returns the keyboard focus target for the selectable, read-only text. Call it after configuring the block, then pass the ID to Context.SetFocus to restore focus when a related control, such as a find panel, closes.
func (*CodeBlockW) Title 实验性
func (w *CodeBlockW) Title(s string) *CodeBlockWTitle shows a header row with title (a file name, the language …) and the copy button.
func (*CodeBlockW) VisibleStartByte 实验性
func (w *CodeBlockW) VisibleStartByte() (offset int, ok bool)VisibleStartByte returns the normalized source byte offset of the first visible visual row from the last painted frame. CRLF and CR count as one LF byte. The result is unavailable until the current source and wrap setting have been painted.
func (*CodeBlockW) Wrap 实验性
func (w *CodeBlockW) Wrap(on bool) *CodeBlockWWrap wraps long lines instead of scrolling sideways.
CodeDocument 实验性
type CodeDocument interface {
// Line appends the spans of line i (0-based) to dst[:0]: in order,
// not overlapping, gaps are plain text. It reports whether they are
// final; spans that are not final are a guess made while the lines
// above are still being tokenized, and the viewer asks again in a
// later frame.
Line(i int, dst []CodeSpan) ([]CodeSpan, bool)
}CodeDocument is the highlighting of one immutable piece of code.
CodeHeaderStyle 实验性
type CodeHeaderStyle struct {
Padding geom.Insets // logical pixels around the header contents
Divider theme.Color // 1px separator, omitted when transparent
Mono bool // use monospace for the title or language
TextCopy bool // show the localized Copy label instead of an icon
}CodeHeaderStyle styles the header shared by CodeBlock and Markdown fences.
CodeHighlighter 实验性
type CodeHighlighter interface {
// Document prepares the highlighting of code (lines separated by
// "\n") in language lang: a language id, alias or file extension
// ("go", "ts", "python", "sh" …). It returns nil when the language is
// unknown, and the code is shown as plain text.
Document(lang, code string) CodeDocument
}CodeHighlighter splits code into highlighted spans by language. Implementations must be safe for use from the UI thread of several windows.
func DefaultCodeHighlighter 实验性
func DefaultCodeHighlighter() CodeHighlighterDefaultCodeHighlighter returns the highlighter installed with SetCodeHighlighter (nil if none).
CodeSpan 实验性
type CodeSpan struct {
Start, End int
Kind CodeTokenKind
}CodeSpan is a highlighted piece of one line: bytes [Start, End) of the line (without its "\n").
CodeTokenKind 实验性
type CodeTokenKind uint8CodeTokenKind classifies a span of highlighted code.
Append-only: new kinds go at the end.
const (
CodePlain CodeTokenKind = iota
CodeKeyword
CodeString
CodeNumber
CodeComment
CodeType
CodeFunction
CodeVariable
CodeConstant
CodeOperator
CodePunctuation
CodeTag
CodeAttribute
CodeProperty
CodeRegexp
CodeInvalid
)The token kinds; CodePlain is unhighlighted text.
实验性
CollapseItem
type CollapseItem struct {
Key string
Label string
Extra func() // content at the inline end of the header
Body func()
Disabled bool
NoArrow bool
// Collapsible overrides the group's Collapsible for this panel:
// "header" (only the title and the arrow toggle), "icon" (only the
// arrow toggles) or "disabled"; "" uses the group's mode.
Collapsible string
}CollapseItem is one panel of a Collapse.
CollapseW
type CollapseW struct {
// contains filtered or unexported fields
}CollapseW is an accordion / collapse panel group.
func Collapse
func Collapse(c *Context, active *[]string, items []CollapseItem) *CollapseWCollapse starts a collapse group bound to the app's open panel keys. Configure with chained modifiers and finish with Show.
func (*CollapseW) Accordion
func (w *CollapseW) Accordion() *CollapseWAccordion keeps at most one panel open.
func (*CollapseW) BeforeCollapse
func (w *CollapseW) BeforeCollapse(fn func(key string) bool) *CollapseWBeforeCollapse is asked before a panel opens or closes (Element before-collapse); returning false keeps the panel as it is.
func (*CollapseW) Borderless
func (w *CollapseW) Borderless() *CollapseWBorderless removes the outer border (Ant bordered={false}).
func (*CollapseW) Changed
func (w *CollapseW) Changed() boolChanged reports a panel toggle in the last Show.
func (*CollapseW) Collapsible
func (w *CollapseW) Collapsible(mode string) *CollapseWCollapsible sets which part of every header toggles its panel (antd collapsible): "" the whole header, "header" only the title and the arrow, "icon" only the arrow, "disabled" nothing. CollapseItem.Collapsible overrides it per panel.
func (*CollapseW) ExpandIcon
func (w *CollapseW) ExpandIcon(ic *icon.Icon) *CollapseWExpandIcon replaces the expand arrow (antd expandIcon, Element icon). It points to the inline end when closed and turns 90° when open.
func (*CollapseW) ExpandIconPlacement
func (w *CollapseW) ExpandIconPlacement(p string) *CollapseWExpandIconPlacement places the expand arrow: "start" (before the label, Ant's default) or "end" (Element and shadcn's default); antd expandIconPlacement, Element expand-icon-position ("left" / "right" are accepted too). Other values keep the theme's default.
func (*CollapseW) Ghost
func (w *CollapseW) Ghost() *CollapseWGhost makes the panels transparent and borderless.
func (*CollapseW) IconEnd
func (w *CollapseW) IconEnd() *CollapseWIconEnd puts the expand arrow at the end of the header (Element's default).
Deprecated: use ExpandIconPlacement("end").
func (*CollapseW) IconStart
func (w *CollapseW) IconStart() *CollapseWIconStart puts the expand arrow before the label (Ant's default).
Deprecated: use ExpandIconPlacement("start").
func (*CollapseW) IsOpen
func (w *CollapseW) IsOpen(key string) boolIsOpen reports whether key is open. In accordion mode only the first active key counts (rc-collapse useItems: activeKey[0]).
func (*CollapseW) Layout
func (w *CollapseW) Layout(o ...layout.Option) *CollapseWLayout applies layout options to the group (call after Show).
func (*CollapseW) Show
func (w *CollapseW) Show() *CollapseWShow builds the panels.
func (*CollapseW) Size
func (w *CollapseW) Size(s ControlSize) *CollapseWSize sets header padding (Small / Middle / Large).
ColorPickerLocale 实验性
type ColorPickerLocale struct {
Presets, None, ClearColor, Clear, Saturation, Hue, Alpha string
Format string // accessible name of the HEX / RGB format select
Value string // accessible name of the value input of ColorPickerPanel ("颜色值")
Gradient string // the gradient stop bar of ColorPickerGradient ("渐变色标")
Angle string // the gradient angle input ("角度")
// contains filtered or unexported fields
}ColorPickerLocale holds the ColorPicker panel texts.
ColorPickerPanelW 实验性
type ColorPickerPanelW struct {
// contains filtered or unexported fields
}ColorPickerPanelW is an inline color panel bound to a color.
func ColorPickerPanel 实验性
func ColorPickerPanel(c *Context, val *theme.Color) *ColorPickerPanelWColorPickerPanel adds an inline color panel bound to *val; changes apply immediately in every design system (there is no confirm step).
ui.ColorPickerPanel(c, &col).Presets(theme.Hex("#409eff"), theme.Hex("#67c23a"))
func ColorPickerPanelGradient 实验性
func ColorPickerPanelGradient(c *Context, val *theme.Gradient) *ColorPickerPanelWColorPickerPanelGradient adds an inline panel bound to a linear gradient: the stop bar and angle input of ColorPickerGradient above the editors of the selected stop's color. ColorPickerPanel (single color) is unchanged.
ui.ColorPickerPanelGradient(c, &g).NoAlpha()
func (*ColorPickerPanelW) AllowClear 实验性
func (w *ColorPickerPanelW) AllowClear() *ColorPickerPanelWAllowClear adds the "no color" control (Ant).
func (*ColorPickerPanelW) Border 实验性
func (w *ColorPickerPanelW) Border(on bool) *ColorPickerPanelWBorder toggles the panel border (default on).
func (*ColorPickerPanelW) Changed 实验性
func (w *ColorPickerPanelW) Changed() boolChanged reports a new color this frame.
func (*ColorPickerPanelW) Disabled 实验性
func (w *ColorPickerPanelW) Disabled(on bool) *ColorPickerPanelWDisabled turns the panel off.
func (*ColorPickerPanelW) DisabledFormat 实验性
func (w *ColorPickerPanelW) DisabledFormat(on bool) *ColorPickerPanelWDisabledFormat leaves the format select out (Ant disabledFormat).
func (*ColorPickerPanelW) Format 实验性
func (w *ColorPickerPanelW) Format(f string) *ColorPickerPanelWFormat sets the value text format: "hex" (default), "rgb", "hsb" or "hsv".
func (*ColorPickerPanelW) ID 实验性
func (w *ColorPickerPanelW) ID() IDID returns the panel's ID.
func (*ColorPickerPanelW) NoAlpha 实验性
func (w *ColorPickerPanelW) NoAlpha() *ColorPickerPanelWNoAlpha hides the alpha bar and input.
func (*ColorPickerPanelW) PresetGroups 实验性
func (w *ColorPickerPanelW) PresetGroups(groups ...ColorPresetGroup) *ColorPickerPanelWPresetGroups shows several titled preset groups (see ColorPickerW.PresetGroups).
func (*ColorPickerPanelW) PresetLabel 实验性
func (w *ColorPickerPanelW) PresetLabel(s string) *ColorPickerPanelWPresetLabel names the preset group (Ant).
func (*ColorPickerPanelW) Presets 实验性
func (w *ColorPickerPanelW) Presets(cols ...theme.Color) *ColorPickerPanelWPresets adds preset swatches (Element predefine, Ant presets).
ColorPickerW 实验性
type ColorPickerW struct {
// contains filtered or unexported fields
}ColorPickerW is a color input with a picker panel.
func ColorPicker 实验性
func ColorPicker(c *Context, val *theme.Color) *ColorPickerWColorPicker adds a color picker bound to *val. The zero Color means "no color" (cleared).
func ColorPickerGradient 实验性
func ColorPickerGradient(c *Context, val *theme.Gradient) *ColorPickerWColorPickerGradient adds a color picker bound to a linear gradient (Ant mode="gradient"): the trigger shows the gradient, and the panel adds a stop bar and an angle input above the usual editors, which edit the color of the selected stop. On the stop bar a press on empty rail adds a stop (with the gradient's color there), dragging a handle moves it and dragging it away from the bar removes it (at least two stops stay); from the keyboard Left / Right move the selected stop, Up / Down select the previous / next one, Enter or Insert adds one after it and Delete / Backspace removes it. Changes apply at once in every design system. The zero Gradient means "no color"; editing a color then creates two stops of that color. The single-color ColorPicker is unchanged.
g := theme.Gradient{Angle: 90, Stops: []theme.GradientStop{{0, theme.Hex("#1677ff")}, {1, theme.Hex("#722ed1")}}}
ui.ColorPickerGradient(c, &g).ShowText()
func (*ColorPickerW) A11yLabel 实验性
func (w *ColorPickerW) A11yLabel(s string) *ColorPickerWA11yLabel sets the accessible name (default: the Locale's A11y.Color; inside a FormItem the item label).
func (*ColorPickerW) AllowClear 实验性
func (w *ColorPickerW) AllowClear() *ColorPickerWAllowClear adds a clear control (Element always has one).
func (*ColorPickerW) Changed 实验性
func (w *ColorPickerW) Changed() boolChanged reports a new color this frame (Element: on confirm or clear).
func (*ColorPickerW) Cleared 实验性
func (w *ColorPickerW) Cleared() boolCleared reports that the value was cleared this frame.
func (*ColorPickerW) Disabled 实验性
func (w *ColorPickerW) Disabled(on bool) *ColorPickerWfunc (*ColorPickerW) DisabledFormat 实验性
func (w *ColorPickerW) DisabledFormat(on bool) *ColorPickerWDisabledFormat leaves the format select out of the panel (Ant disabledFormat): the value is edited in the current Format only.
func (*ColorPickerW) Format 实验性
func (w *ColorPickerW) Format(f string) *ColorPickerWFormat sets the value text and input format: "hex", "rgb", or "hsb" / "hsv" (the same color space, written "hsb(220, 75%, 80%)" / "hsv(...)"; Ant's panel then edits hue, saturation and brightness). Typed text is accepted in any of these forms.
func (*ColorPickerW) IsOpen 实验性
func (w *ColorPickerW) IsOpen() boolIsOpen reports whether the panel is shown.
func (*ColorPickerW) NoAlpha 实验性
func (w *ColorPickerW) NoAlpha() *ColorPickerWNoAlpha hides the alpha slider and input.
func (*ColorPickerW) Open 实验性
func (w *ColorPickerW) Open() *ColorPickerWOpen forces the panel open (screenshots, tests).
func (*ColorPickerW) Placement 实验性
func (w *ColorPickerW) Placement(p Placement) *ColorPickerWPlacement sets where the panel opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement "bottomLeft" …); it flips when there is no room.
func (*ColorPickerW) PresetGroups 实验性
func (w *ColorPickerW) PresetGroups(groups ...ColorPresetGroup) *ColorPickerWPresetGroups shows several titled preset groups instead of Presets. In Ant / shadcn the titles are buttons that collapse / expand their group (Closed starts collapsed); Element shows each title above its swatches.
func (*ColorPickerW) PresetLabel 实验性
func (w *ColorPickerW) PresetLabel(s string) *ColorPickerWPresetLabel names the preset group (Ant; default "推荐").
func (*ColorPickerW) Presets 实验性
func (w *ColorPickerW) Presets(cols ...theme.Color) *ColorPickerWPresets adds preset swatches (Ant presets, Element predefine).
func (*ColorPickerW) ShowText 实验性
func (w *ColorPickerW) ShowText() *ColorPickerWShowText shows the color value next to the swatch.
func (*ColorPickerW) Size 实验性
func (w *ColorPickerW) Size(s ControlSize) *ColorPickerWfunc (*ColorPickerW) Status 实验性
func (w *ColorPickerW) Status(s string) *ColorPickerWfunc (*ColorPickerW) Trigger 实验性
func (w *ColorPickerW) Trigger(t Trigger) *ColorPickerWTrigger chooses what opens the panel: TriggerClick (default) or TriggerHover (Ant trigger="hover"): the panel opens when the pointer rests on the swatch and closes shortly after it leaves both; a click (or Enter / Space) pins it open until an outside press or Escape. TriggerContextMenu is treated as TriggerClick.
ColorPresetGroup 实验性
type ColorPresetGroup struct {
Label string
Colors []theme.Color
Closed bool // Ant / shadcn: the group starts collapsed
}ColorPresetGroup is a titled group of preset swatches (PresetGroups).
ColumnsStateFuncs 实验性
type ColumnsStateFuncs struct {
Load func(key string) (TableColumnState, bool)
Save func(key string, s TableColumnState)
}ColumnsStateFuncs adapts two functions to ColumnsStateStore.
func (ColumnsStateFuncs) LoadColumnsState 实验性
func (f ColumnsStateFuncs) LoadColumnsState(key string) (TableColumnState, bool)LoadColumnsState calls Load (nil: nothing stored).
func (ColumnsStateFuncs) SaveColumnsState 实验性
func (f ColumnsStateFuncs) SaveColumnsState(key string, s TableColumnState)SaveColumnsState calls Save (nil: dropped).
ColumnsStateStore 实验性
type ColumnsStateStore interface {
LoadColumnsState(key string) (TableColumnState, bool)
SaveColumnsState(key string, s TableColumnState)
}ColumnsStateStore keeps ProTable column states where the application wants them (memory, a settings file, a database): ProTable loads the state once by key and saves it on every change. It never touches the disk itself.
CommandItem 实验性
type CommandItem struct {
Value string
Label string
Group string // heading the item is listed under ("" = none)
Icon *icon.Icon // optional leading icon
Shortcut string // right-aligned hint such as "⌘P"
Keywords []string // extra search terms
Disabled bool
}CommandItem is one entry of a Command palette.
CommandLocale 实验性
type CommandLocale struct {
Placeholder, Empty string
// contains filtered or unexported fields
}CommandLocale holds the Command palette texts.
CommandW 实验性
type CommandW struct {
// contains filtered or unexported fields
}CommandW is a command palette under construction (shadcn/ui Command): a search field over a filtered, grouped list navigated with the arrow keys. It renders in every design system with the active theme's tokens.
func Command 实验性
func Command(c *Context, items []CommandItem) *CommandWCommand adds a command palette over items. Typing filters and ranks the list like cmdk: an item matches when the search letters appear in order in its label, value or keywords (case-insensitive); whole-word and prefix matches rank first and groups follow their best item. Up/Down (and Ctrl+N/J, Ctrl+P/K) move the active row, Home/End jump to the first / last, Enter or a click picks it (Selected).
ConfigProvider.Defaults("Command", ...) keys: "placeholder", "emptyText" (string), "loop" (bool, default false), "shouldFilter" (bool, default true), "vimBindings" (bool, default true).
func (*CommandW) DataVersion 实验性
func (w *CommandW) DataVersion(v int) *CommandWDataVersion tells the palette that the items slice was modified in place (a virtual list caches its matches, layout and width by slice identity, length and this number): after editing items of the same slice without changing its length, change v (or pass a new slice) so they are recomputed on the next frame.
func (*CommandW) DisablePointerSelection 实验性
func (w *CommandW) DisablePointerSelection(on bool) *CommandWDisablePointerSelection stops hovering from moving the active item (cmdk disablePointerSelection); clicks still pick.
func (*CommandW) Empty 实验性
func (w *CommandW) Empty(s string) *CommandWEmpty replaces the "no results" text.
func (*CommandW) Filter 实验性
func (w *CommandW) Filter(fn func(value, search string, keywords []string) float64) *CommandWFilter replaces the matching and ranking (cmdk filter): fn returns 0 to hide an item, else its rank (higher first) for the item's value (Label when Value is empty), the trimmed search and its keywords.
func (*CommandW) ID 实验性
func (w *CommandW) ID() IDID returns the palette box ID.
func (*CommandW) Layout 实验性
func (w *CommandW) Layout(opts ...layout.Option) *CommandWLayout applies layout options to the palette box.
func (*CommandW) Loop 实验性
func (w *CommandW) Loop(on bool) *CommandWLoop lets the arrow keys wrap from the last item to the first and back (cmdk loop; default false).
func (*CommandW) MaxHeight 实验性
func (w *CommandW) MaxHeight(h float32) *CommandWMaxHeight limits the list height (default 300).
func (*CommandW) Placeholder 实验性
func (w *CommandW) Placeholder(s string) *CommandWPlaceholder replaces the search placeholder.
func (*CommandW) Query 实验性
func (w *CommandW) Query() stringQuery returns the current search text.
func (*CommandW) Search 实验性
func (w *CommandW) Search(q *string) *CommandWSearch binds the search text (cmdk CommandInput value / onValueChange).
func (*CommandW) Selected 实验性
func (w *CommandW) Selected() (CommandItem, bool)Selected returns the item picked this frame.
func (*CommandW) Shadow 实验性
func (w *CommandW) Shadow() *CommandWShadow gives the palette a floating shadow (as in a dialog).
func (*CommandW) ShouldFilter 实验性
func (w *CommandW) ShouldFilter(on bool) *CommandWShouldFilter(false) lists every item whatever the search (cmdk shouldFilter): the app filters items itself, for example from a server, reading Query.
func (*CommandW) Value 实验性
func (w *CommandW) Value(v *string) *CommandWValue binds the value of the active item (cmdk value / onValueChange): the palette highlights the item whose Value (Label when empty) equals *v and writes the active item's value back as it moves. A value that is not listed leaves the first item active.
func (*CommandW) ValueChanged 实验性
func (w *CommandW) ValueChanged() boolValueChanged reports that the active item changed this frame.
func (*CommandW) VimBindings 实验性
func (w *CommandW) VimBindings(on bool) *CommandWVimBindings(false) turns off Ctrl+N/J (next) and Ctrl+P/K (previous) (cmdk vimBindings; default true).
func (*CommandW) Virtual 实验性
func (w *CommandW) Virtual(on bool) *CommandWVirtual forces the virtual list on or off; by default lists showing more than 100 items are virtual: only the rows in view and the active item are built (groups only for their visible part), the list keeps the width, height and scroll range of the full list and follows the active item when it moves with the keyboard, but items out of view are not in the accessibility tree. Without a Filter function the matches, their order and the width are reused while the items slice (identity and length), the search and the DataVersion stay the same: an item edited in place (same slice, same length) does not join or leave the matches, nor change the list's width, until one of them changes. Virtual(false) builds every row.
CompactW 实验性
type CompactW struct {
// contains filtered or unexported fields
}CompactW joins its direct child controls (Input, Select, Button, InputNumber, DatePicker, Addon, ...) into one group: neighbours overlap by one pixel and only the outer corners stay rounded (Ant Space.Compact / Input.Group, Element input prepend/append and button groups).
The children are drawn by their own painters; Compact squares the joined corners by repainting the joined edge columns with a widened rectangle, so it works with any control without changing it.
func Compact 实验性
func Compact(c *Context) *CompactWCompact starts a compact group; chain options, then Body.
ui.Compact(c).Body(func() { ui.Input(c, &v); ui.Button(c, "提交").Primary() })
ConfigProvider.Defaults("Compact", ...) keys: "block" (bool).
func (*CompactW) Block 实验性
func (w *CompactW) Block() *CompactWBlock stretches the group to the container width.
func (*CompactW) Body 实验性
func (w *CompactW) Body(fn func()) *BoxBody adds the controls.
func (*CompactW) Layout 实验性
func (w *CompactW) Layout(o ...layout.Option) *CompactWLayout applies layout options to the group.
func (*CompactW) Orientation 实验性
func (w *CompactW) Orientation(o string) *CompactWOrientation sets the direction: "horizontal" (default) or "vertical" (antd 6 orientation; Vertical is the shorthand). Other values are ignored.
func (*CompactW) Size 实验性
func (w *CompactW) Size(s ControlSize) *CompactWSize sets the size of the controls in the group that do not set their own (antd Space.Compact size): it scopes the component size like ConfigProvider.Size.
func (*CompactW) Vertical 实验性
func (w *CompactW) Vertical() *CompactWVertical stacks the controls (joined top/bottom edges).
ConfigProviderW
type ConfigProviderW struct {
// contains filtered or unexported fields
}ConfigProviderW configures every component built inside its Body: size, locale, component default properties, disabled state and theme.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func ConfigProvider
func ConfigProvider(c *Context) *ConfigProviderWConfigProvider starts a configuration scope; chain options, then Body.
func (*ConfigProviderW) Body
func (p *ConfigProviderW) Body(fn func())Body builds fn inside the configuration scope.
func (*ConfigProviderW) Compact
func (p *ConfigProviderW) Compact(on bool) *ConfigProviderWCompact selects the compact size algorithm.
func (*ConfigProviderW) ComponentDisabled
func (p *ConfigProviderW) ComponentDisabled(on bool) *ConfigProviderWComponentDisabled disables every widget inside.
func (*ConfigProviderW) Components 实验性
func (p *ConfigProviderW) Components(cs theme.Components) *ConfigProviderWComponents layers component token overrides (theme.Components; zero fields inherit) over the scope's theme. Repeated calls merge. Like Theme, it themes the window from the root provider and only the scope from a nested one.
func (*ConfigProviderW) Dark
func (p *ConfigProviderW) Dark(on bool) *ConfigProviderWDark switches between the light and dark algorithm.
func (*ConfigProviderW) Defaults 实验性
func (p *ConfigProviderW) Defaults(component string, props Props) *ConfigProviderWDefaults sets default properties of a component; keys merge with outer providers.
func (*ConfigProviderW) Direction
func (p *ConfigProviderW) Direction(d Direction) *ConfigProviderWDirection sets the inline direction of the scope: LTR, RTL, or DirAuto to derive it from the scope's Locale again (overriding an explicit direction of an outer provider). Without a provider that sets one, the direction follows the Locale, then SetDefaultDirection.
func (*ConfigProviderW) Flavor
func (p *ConfigProviderW) Flavor(f theme.Flavor) *ConfigProviderWFlavor switches the design language (theme.Ant / theme.Element / theme.StyleShadcn) keeping dark mode and primary color settings of this provider.
func (*ConfigProviderW) HighContrast
func (p *ConfigProviderW) HighContrast(on bool) *ConfigProviderWHighContrast fixes the contrast of the scope: true draws theme.HighContrast of the scope's theme (WCAG AA for every required pair, docs/accessibility.md), false the standard variant. Without it the scope inherits: a theme rebuilt by Flavor, Dark, PrimaryColor or Compact stays high-contrast when the outer theme is (for example while uihost follows the system preference). Like Theme, the root provider applies it to the window; uihost then stops following the system theme for that window.
HighContrast(false) inside a high-contrast scope regenerates the theme from its flavor, dark mode and component overrides, as Dark does: token customizations of the outer theme that the generator cannot reproduce are lost.
func (*ConfigProviderW) Locale
func (p *ConfigProviderW) Locale(l *Locale) *ConfigProviderWLocale sets the language.
func (*ConfigProviderW) LocaleCode
func (p *ConfigProviderW) LocaleCode(code string) *ConfigProviderWLocaleCode sets the language by registered code ("en-US").
func (*ConfigProviderW) PrimaryColor
func (p *ConfigProviderW) PrimaryColor(col theme.Color) *ConfigProviderWPrimaryColor overrides the brand color (derived shades follow).
func (*ConfigProviderW) Size
func (p *ConfigProviderW) Size(s ControlSize) *ConfigProviderWSize sets the default control size (small / middle / large).
func (*ConfigProviderW) Theme
func (p *ConfigProviderW) Theme(th *theme.Theme) *ConfigProviderWTheme sets the theme of the scope. A provider called directly by the page function outside any other provider (the root provider) switches the window theme: background, global layers (Message, Notification) and everything built before it. A nested provider only themes the widgets built inside its Body, including their paint. The same applies to Flavor, Dark, PrimaryColor and Compact.
ConfirmAction
type ConfirmAction stringConfirmAction is how a Confirm / MessageBox / Prompt dialog was closed.
const (
// ConfirmActionConfirm: the OK button (or Enter in a Prompt).
ConfirmActionConfirm ConfirmAction = "confirm"
// ConfirmActionCancel: the Cancel button, or with
// DistinguishCancelAndClose unset also the close button, Escape and
// a mask click.
ConfirmActionCancel ConfirmAction = "cancel"
// ConfirmActionClose: the close button, Escape or a mask click when
// DistinguishCancelAndClose is set.
ConfirmActionClose ConfirmAction = "close"
)ConfirmOptions
type ConfirmOptions struct {
Title string
Content string
// Status picks the leading icon: "info", "success", "warning", "error"
// or "none". Confirm/Prompt default to "warning"/"none", MessageBox to
// "info".
Status string
OkText string // default "确定" ("知道了" for Ant MessageBox)
CancelText string // default "取消"
Danger bool // red OK button (destructive actions)
Width float32
// MaskClosable closes the dialog (as a cancel) on a mask click.
MaskClosable bool
// OnOk runs on the UI thread when OK is activated. The dialog closes
// after it returns unless it called d.Loading(true); then it stays open
// with a spinning OK button until d.Close().
OnOk func(d *ConfirmRef)
// OnCancel runs on Cancel, the close button, Escape or a mask click.
OnCancel func()
// DistinguishCancelAndClose tells the close button, Escape and a
// mask click apart from Cancel: they run OnClose (not OnCancel) and
// ConfirmRef.Action reports ConfirmActionClose.
DistinguishCancelAndClose bool
// OnClose runs when the dialog is closed without Cancel or OK
// (close button, Escape, mask) and DistinguishCancelAndClose is set.
OnClose func()
// Center centers the icon, title, content and buttons.
Center bool
// Draggable lets the user move the dialog by dragging its title.
Draggable bool
// Icon replaces the status icon; it is drawn in the status color
// (the primary color for Status "none").
Icon *icon.Icon
// AutoFocusButton picks the button focused when the dialog opens:
// "" or "ok" (default), "cancel", or "none" (antd autoFocusButton,
// null for none). A Prompt focuses its input.
AutoFocusButton string
// NoKeyboard keeps Escape from closing the dialog (antd keyboard
// false, Element close-on-press-escape false).
NoKeyboard bool
// Prompt only.
InputValue string
InputPlaceholder string
// Validate returns an error message ("" = valid); OK is refused while
// it fails.
Validate func(v string) string
}ConfirmOptions configure Confirm, MessageBox and Prompt.
ConfirmRef
type ConfirmRef struct {
// contains filtered or unexported fields
}ConfirmRef is a handle to an open dialog.
func Confirm
func Confirm(c *Context, o ConfirmOptions) *ConfirmRefConfirm opens a confirmation dialog with Cancel and OK buttons.
func MessageBox 实验性
func MessageBox(c *Context, o ConfirmOptions) *ConfirmRefMessageBox opens an information dialog with a single OK button (Ant Modal.info/success/warning/error, Element ElMessageBox.alert). Set o.Status to pick the icon.
func Prompt 实验性
func Prompt(c *Context, o ConfirmOptions) *ConfirmRefPrompt opens a dialog with a text input; read the value in OnOk with d.Value().
func (*ConfirmRef) Action
func (d *ConfirmRef) Action() ConfirmActionAction reports how the dialog was closed by the user ("" while open or after Close).
func (*ConfirmRef) Close
func (d *ConfirmRef) Close()Close closes the dialog without calling any callback. It is safe to call from any goroutine (e.g. when async work started in OnOk finishes): the state is atomic and a frame is requested through Window.Invalidate, which the Window contract makes thread-safe.
func (*ConfirmRef) IsOpen
func (d *ConfirmRef) IsOpen() boolIsOpen reports whether the dialog is still shown.
func (*ConfirmRef) Loading
func (d *ConfirmRef) Loading(on bool)Loading shows (or clears) the spinner on the OK button. While loading, OK is inert and the dialog stays open after OnOk returns. Safe to call from another goroutine.
func (*ConfirmRef) Value
func (d *ConfirmRef) Value() stringValue returns the Prompt input.
ContentKind 实验性
type ContentKind intContentKind says what a window mostly shows (RunnerOptions.Content). The window host uses it to decide when a window leaves its default renderer: on Apple Silicon macOS, uihost starts every window, of any size and any ContentKind, on native Core Animation layers, whose memory footprint is well below Metal's, and switches a window to Metal at most once. TANGO_RENDERER and RunnerOptions.Renderer still take precedence, and hosts without such a choice ignore it.
const (
// ContentGeneral is the default. On Apple Silicon macOS the window
// switches itself to Metal on the frame after its first keyboard input
// (a non-modifier key press, committed text or an IME composition),
// because Metal shows input about two frames sooner, or after six
// consecutive frames over 8 ms or six consecutive frames of full-window
// software fallback. Scrolling and pointer input alone keep it on native
// layers. Intel Macs default to Metal.
ContentGeneral ContentKind = iota
// ContentData is for windows that mostly display data changing on its
// own: tables, grids, quote boards, lists and dashboards. On Apple
// Silicon macOS they ignore keyboard input, so browsing with arrow or
// page keys keeps their memory footprint low (list and quote windows:
// 39-54 vs 135-147 MB on Metal; an 800x600 grid redrawing 600 cells
// every frame: about 69 MB), and switch to Metal only under the same
// frame-cost rules as ContentGeneral. Their input
// reaches the screen about two frames later than on Metal, so editors,
// terminals and drawing canvases should stay ContentGeneral.
ContentData
)实验性
Context
type Context struct {
Theme *theme.Theme
// contains filtered or unexported fields
}Context is passed to page functions; it builds the frame's widget tree and answers interaction queries. It is only valid on the UI goroutine during a frame.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func (*Context) A11yAction 实验性
func (c *Context) A11yAction(id ID) (a11y.Action, string, bool)A11yAction returns an accessibility action requested for id this frame (Runner.PerformAction): widgets whose activation does not go through Interact (gesture areas, custom hit testing) read it to react to Press, Expand, SetValue … Press is also delivered as a click to Interact.
func (*Context) A11yEnabled
func (c *Context) A11yEnabled() boolA11yEnabled reports whether the semantics tree is built this frame (a host or the Driver asked for it). Widgets may skip work that only feeds the tree (formatting descriptions, closures) when it is false.
func (*Context) A11yScrollRequest 实验性
func (c *Context) A11yScrollRequest(container ID) (ID, bool)A11yScrollRequest returns the widget a screen reader asked to scroll into view this frame (the ScrollIntoView action) when container is the nearest scroll container around it that is not a ui scroll container (Box.A11yScroller); the container scrolls the minimum amount that shows the widget's rectangle of the last frame (Context.RectOf) inside its visible part. ui scroll containers further out are scrolled by the runner itself.
func (*Context) Anim
func (c *Context) Anim(id ID, slot string, target float32, dur time.Duration) float32Anim returns a value that eases towards target over dur, retained per (id, slot). The first call returns target immediately. While moving it keeps frames coming; when settled no frames are requested.
func (*Context) AnimDone
func (c *Context) AnimDone(id ID, slot string) boolAnimDone reports whether the (id, slot) animation has settled at target.
func (*Context) AnimFrom
func (c *Context) AnimFrom(id ID, slot string, initial, target float32, dur time.Duration) float32AnimFrom is Anim with an explicit initial value (enter transitions).
func (*Context) Announce
func (c *Context) Announce(text string, live a11y.Live)Announce asks the screen reader to speak text once (a polite or assertive announcement not tied to a node, e.g. "3 results"). It is ignored when accessibility is off.
func (*Context) CaptureTab
func (c *Context) CaptureTab(id ID)CaptureTab makes Tab and Shift+Tab reach widget id (in KeysFor) instead of moving focus, while id has keyboard focus. Call it during the build of every frame in which id wants Tab. Ctrl+Tab, or Esc then Tab, still moves focus out of it.
func (*Context) ClaimBack
func (c *Context) ClaimBack()ClaimBack asks for the system Back action in this frame: while some frame calls it, Back arrives as an Escape key press, read with Context.Escape (on the page it is not consumed by overlays, which are above it and take Escape first). Call it every frame the page has something Back should undo, typically an in-page navigation stack that is not at its root.
func (*Context) ClaimEscape 实验性
func (c *Context) ClaimEscape(id ID)ClaimEscape makes keyboard Esc reach widget id (in KeysFor and EventsFor) instead of closing overlays, while id has keyboard focus. Call it during the build of every frame in which id wants Esc. Android's system Back (Esc with Code input.KeyBack) is not claimed and still closes overlays.
func (*Context) ClaimKeyboardReveal 实验性
func (c *Context) ClaimKeyboardReveal()ClaimKeyboardReveal marks the pending keyboard avoidance request as handled (see PendingKeyboardReveal). The frame is redrawn completely.
func (*Context) ComponentSize
func (c *Context) ComponentSize() (ControlSize, bool)ComponentSize returns the size set by the innermost ConfigProvider and whether one was set; components use it when the caller gave no size.
func (*Context) CompositionFor 实验性
func (c *Context) CompositionFor(id ID) (string, int)CompositionFor returns the current IME pre-edit string for focused id.
func (*Context) ConfigProp
func (c *Context) ConfigProp(component, key string) (any, bool)ConfigProp returns a default property for component (nil, false when unset). Nested providers inherit and override per key.
func (*Context) ContextMenu 实验性
func (c *Context) ContextMenu() (geom.Point, bool)ContextMenu reports a secondary-button (right) press this frame and its position.
func (*Context) ContextMenuFor 实验性
func (c *Context) ContextMenuFor(id ID) (geom.Point, bool)ContextMenuFor reports a secondary-button press this frame inside id's last-frame rectangle that did not land on a layer above id.
func (*Context) Damage 实验性
func (c *Context) Damage(r geom.Rect)Damage tells the renderer that the pixels inside r (window logical pixels, the space of RectOf and Box.Rect) change this frame. Once any widget declares damage (or a ScrollShift) in a frame, the renderer may redraw only the declared regions plus what the Runner detects itself: running Anim/AnimFrom transitions (old and new rect of the animation's widget ID), overlays opening, closing or moving, the focus ring and the hovered/pressed widget. Everything else that looks different must be covered by a declaration. Frames without declarations are redrawn completely, and so are frames in which time-driven drawing may have changed (the clock passed a WakeAt timer of the last frame, such as a text caret's blink, or the last frame was animating; WakeAtDamaged timers excepted).
UI thread only, during the page build or a paint function (before the Runner collects the hints at the end of the frame).
func (*Context) Direction
func (c *Context) Direction() DirectionDirection reports the resolved direction of the current scope: LTR or RTL, never DirAuto.
func (*Context) Dismissed 实验性
func (c *Context) Dismissed(panel ID, also ...ID) boolDismissed reports whether an open overlay panel should close this frame: Escape routed to it (EscapeAt) or a press outside it and the extra widgets, typically its anchor (PressedOutside). Call it every frame the panel is open.
func (*Context) Dragging
func (c *Context) Dragging(id ID) boolDragging reports whether id holds the pointer capture.
func (*Context) Escape
func (c *Context) Escape() boolEscape reports (and consumes) an Escape press not handled by a focused widget, routed like EscapeAt using the layer the caller is being built in. Overlays that check Escape outside their own content (after building the panel) must use EscapeAt with the panel ID instead.
func (*Context) EscapeAt 实验性
func (c *Context) EscapeAt(panel ID) boolEscapeAt reports (and consumes) an Escape press meant for the overlay panel: it is true only when panel is the top-most layer that listened for Escape in the last frame, so Escape closes stacked popups one at a time. Call it every frame the panel is open (calling it is what registers the panel as a listener). panel is the overlay's box ID (Overlay(...).ID()); before the panel was first painted the caller's own layer is used.
func (*Context) EventsFor
func (c *Context) EventsFor(id ID) []input.EventEventsFor returns, in arrival order, the keyboard input of this frame for widget id while it has focus: input.KeyEvent (Key folded with Key.Base, Code the physical key), input.TextInput and input.Composition, interleaved as they happened. Use it when order matters (a text editor: Backspace then "a" is not "a" then Backspace); KeysFor and TextFor give the same events split by kind.
It also carries Esc (which overlays consume through Escape) and Tab when id declared CaptureTab. Like KeysFor it hands the events over once: later calls in the same frame return nil.
func (*Context) FileDrag 实验性
func (c *Context) FileDrag() (geom.Point, bool)FileDrag reports a file drag over the window and its position in UI logical pixels. It is read-only: use DropZone for hit testing and highlighting.
func (*Context) Focused
func (c *Context) Focused() IDFocused returns the focused widget.
func (*Context) Inline 实验性
func (c *Context) Inline(r geom.Rect) InlineSpanInline returns the inline span of r in the current scope's direction. Call it during build, or during paint (the node's own scope is current).
func (*Context) InlineKey 实验性
func (c *Context) InlineKey(k input.Key) (prev, next bool)InlineKey reports whether k means "previous" or "next" along the inline axis: Left/Right swap in RTL scopes.
func (*Context) Invalidate
func (c *Context) Invalidate()Invalidate requests another build pass of the current frame (e.g. after changing state that widgets built earlier in this frame read). It must be called on the UI goroutine during a frame; from other goroutines use the function returned by Invalidator.
func (*Context) InvalidateImage 实验性
func (c *Context) InvalidateImage(img image.Image)InvalidateImage drops the renderer's cached copies of img. Call it on the UI goroutine during building or painting, before rendering, after changing image pixels or discarding a private derived image. A later draw of the same image value prepares it again. Renderers without image caches may ignore this hint.
This does not declare redraw damage. In-place pixel changes also need Damage (or a full redraw); replacing a drawn image value changes its paint fingerprint normally. Recorded image pixels remain caller-owned.
func (*Context) Invalidator
func (c *Context) Invalidator() func()Invalidator returns a function that requests a new frame. Unlike Invalidate it is safe to call from any goroutine (background loaders, network callbacks) and after the frame that obtained it has ended.
func (*Context) IsRTL
func (c *Context) IsRTL() boolIsRTL reports whether the current scope lays out right to left. During paint and measure callbacks it reports the direction of the node being painted or measured.
func (*Context) KeepPointer 实验性
func (c *Context) KeepPointer(id ID)KeepPointer stops enclosing containers from taking the pointer over from id while it holds it (CSS touch-action: none). Call it during the build of each frame in which id drags by itself.
func (*Context) KeyboardCover
func (c *Context) KeyboardCover(r geom.Rect) float32KeyboardCover returns how much of the bottom of r (window logical pixels) the soft keyboard hides; 0 while it is hidden.
func (*Context) KeyboardInset
func (c *Context) KeyboardInset() geom.InsetsKeyboardInset returns the part of the window covered by the soft keyboard, in logical pixels: usually only Bottom, zero while the keyboard is hidden and on desktops. Views that must stay visible pad or lift themselves by it (with SafeArea, take the larger bottom of the two). A change redraws the whole frame.
func (*Context) KeysFor
func (c *Context) KeysFor(id ID) []input.KeyEventKeysFor returns the key events delivered to id this frame when it has focus, and marks them consumed.
func (*Context) Locale
func (c *Context) Locale() *LocaleLocale returns the active locale (innermost ConfigProvider, else the default set by SetDefaultLocale, zh-CN out of the box). In paint and measure callbacks it is the locale of the scope the node was built in.
func (*Context) MiddlePressed 实验性
func (c *Context) MiddlePressed(id ID) boolMiddlePressed reports a middle-button press on the visible hit region of id. The topmost overlay wins and clipped content does not receive presses.
func (*Context) Now
func (c *Context) Now() time.TimeNow returns the frame time (use it for timers, not time.Now).
func (*Context) PaintIcon
func (c *Context) PaintIcon(l *paint.List, ic *icon.Icon, r geom.Rect, col theme.Color, angle float64)PaintIcon draws ic in r, mirroring directional icons in RTL scopes (rotation first, then the mirror).
func (*Context) PendingKeyboardReveal 实验性
func (c *Context) PendingKeyboardReveal() (KeyboardReveal, bool)PendingKeyboardReveal returns the keyboard avoidance request of this frame, if any. A scroll container that moves its content itself (not a ui scroll container) checks that Field lies in its content, scrolls so that Target ends above Limit and calls ClaimKeyboardReveal. Unclaimed requests go to the innermost ui scroll container around the field after the build.
func (*Context) PixelScale 实验性
func (c *Context) PixelScale() float32PixelScale returns device pixels per UI logical pixel in the current frame, including both UI scale and the host window's device-pixel ratio.
func (*Context) Pointer
func (c *Context) Pointer() (geom.Point, bool)Pointer returns the pointer position and whether it is inside the window.
func (*Context) PointerCancelled 实验性
func (c *Context) PointerCancelled(id ID) boolPointerCancelled reports whether id lost the pointer this frame without a release: an enclosing container took the drag over, or the system cancelled the gesture (input.Cancel, a cancelled touch, the window lost focus). The widget should drop any drag in progress without committing it.
func (*Context) PointerDownOutside 实验性
func (c *Context) PointerDownOutside(rs ...geom.Rect) boolPointerDownOutside reports whether a press happened this frame outside all of the given rectangles. It ignores layering; popups should use PressedOutside or Dismissed with widget IDs instead.
func (*Context) PointerEvents 实验性
func (c *Context) PointerEvents() []input.PointerPointerEvents returns every pointer event of the frame (Move, Press, Release, Leave), in arrival order, in the same coordinates as Pointer. Pointer reports only where the frame ended; apps that forward the pointer elsewhere, such as a remote desktop, read the whole path here. Like keys, the events reach the first build of the frame only; a rebuild of the same frame sees none. The slice is valid until the next build.
func (*Context) PointerMods
func (c *Context) PointerMods() input.ModifiersPointerMods returns the modifiers held at the latest pointer event (move, press, release, wheel) or key event, whichever came last. Unlike PressMods it follows modifier changes during a drag, so a drag source can switch between move and copy (Alt/Option) while the pointer moves or when only the modifier key changes.
func (*Context) PointerTaken 实验性
func (c *Context) PointerTaken(id ID) (from geom.Point, ok bool)PointerTaken reports whether id took the pointer over from a widget inside it this frame, and where that press started (id is now the holder: Dragging(id) is true).
func (*Context) PressCount
func (c *Context) PressCount() intPressCount returns the click count of the current (or last) primary press: 1 single, 2 double, 3 triple... It follows the host's count when the platform reports one (system double-click settings), otherwise the UI's own 400 ms rule. Read it while handling a press or a drag that started with one (word / line selection by double / triple click).
func (*Context) PressMods
func (c *Context) PressMods() input.ModifiersPressMods returns the modifier keys held at the last primary press (Shift+click to extend a selection, Alt+click for a column cursor).
func (*Context) PressPos 实验性
func (c *Context) PressPos() geom.PointPressPos returns the position of the latest primary press, even if more pointer events followed it in the same frame.
func (*Context) PressedOutside 实验性
func (c *Context) PressedOutside(ids ...ID) boolPressedOutside reports whether the primary button went down this frame outside the last-frame rectangles of all ids and not on a layer above them: a press inside a popup stacked over the panel (a Select list opened from a Modal) is not "outside" the panel. The highest layer among ids (usually the panel; anchors on the page do not raise it) is the panel's.
func (*Context) RectOf
func (c *Context) RectOf(id ID) (geom.Rect, bool)RectOf returns the absolute rectangle id had in the last painted frame, in UI logical pixels.
func (*Context) ReduceMotion
func (c *Context) ReduceMotion() boolReduceMotion reports whether the user asked for reduced motion (RunnerOptions.ReduceMotion). Anim and AnimFrom already jump to their targets; widgets check it for motion they drive themselves (shimmer, pulsing dots, marquees, autoplay).
func (*Context) ReleasePos
func (c *Context) ReleasePos(id ID) (geom.Point, bool)ReleasePos returns where the primary button was released over the press that id held, this frame. Unlike Pointer (the last pointer event of the frame) it is the release event's own position, so a move that arrives in the same frame after the release does not shift it. ok is false when id was not released this frame.
func (*Context) SafeArea
func (c *Context) SafeArea() geom.InsetsSafeArea returns the safe-area insets of the window in logical pixels (zero on desktops). Edge-to-edge widgets (navigation and tab bars, bottom sheets, full-screen pages) pad themselves by it. A change redraws the whole frame.
func (*Context) ScrollIntoView
func (c *Context) ScrollIntoView(scrollID, id ID) boolScrollIntoView scrolls container scrollID (a ScrollBox or another scroll container's ID) the minimum amount that makes widget id fully visible, using both widgets' rectangles from the last painted frame. It returns false when either was not painted yet (call it again next frame).
func (*Context) ScrollIntoViewInset 实验性
func (c *Context) ScrollIntoViewInset(scrollID, id ID, inset geom.Insets) boolScrollIntoViewInset is ScrollIntoView for a window partly covered by system UI: inset (window logical pixels, such as KeyboardInset or SafeArea) is removed from the window before it clips the container's viewport, so the widget ends up in the part of the container that is still visible. A widget taller than that part is aligned to its top. While the soft keyboard covers the container it may scroll past its content's end by the covered height. Like ScrollIntoView it returns false when either widget was not painted yet.
func (*Context) ScrollShift 实验性
func (c *Context) ScrollShift(r geom.Rect, d geom.Point)ScrollShift declares that the content being built moved by d inside r (window logical pixels; a pixel at p is now at p+d) since the last frame, so the renderer may copy those pixels instead of redrawing them. Call it inside the Body of the scrolled content: the current parent node is recorded as the scrolled content (for a Scroll container, its children). The Runner damages, inside r, the strip the copy uncovers and every node that does not move with the content (sticky headers, summary rows, Affix, overlays, fixed-column shadows), at its new place and where the copy carried its old pixels. The backgrounds of the content's ancestors must look the same everywhere in r. When the nodes in r cannot be classified (the content was not laid out, a node straddles r's edge, an ancestor paints over r or is transformed) the shift is withdrawn and r is redrawn as a whole.
UI thread only, during the page build.
func (*Context) Semantics
func (c *Context) Semantics(id ID, role a11y.Role, name string, states ...a11y.State)Semantics annotates the widget id (built this frame) with a role, an accessible name and states, overriding what the widget declared; use it for custom widgets built from Div/Custom or to rename a control:
b := ui.Custom(c, measure, paint)
c.Semantics(b.ID(), a11y.RoleImage, loc.Logo)
An empty name keeps the widget's own name. It costs nothing when accessibility is off.
func (*Context) SetFocus
func (c *Context) SetFocus(id ID)SetFocus moves keyboard focus to id (0 clears it).
func (*Context) Size
func (c *Context) Size() geom.SizeSize returns the viewport size in UI logical pixels, after UI scaling.
func (*Context) TerminalEvents 实验性
func (c *Context) TerminalEvents(id ID, fn func(input.Event) bool)TerminalEvents declares an experimental fast input path for a focused terminal-like control. The handler runs when Runner.HandleEvent receives an event, before the event is queued for the next frame. Returning true claims the event; returning false leaves it for ordinary frame processing.
The handler must not mutate retained UI state from another goroutine. It may enqueue work into a thread-safe application queue such as a terminal's input writer.
func (*Context) TextEditsFor 实验性
func (c *Context) TextEditsFor(id ID) []input.EventTextEditsFor returns, in arrival order, the input.TextEdit and input.SelectionChange events of this frame for widget id while it has focus, and records that id applies them itself: from the next frame on they reach it unconverted. Like KeysFor it hands them over once.
func (*Context) TextFor
func (c *Context) TextFor(id ID) []stringTextFor returns committed text input for focused id.
func (*Context) TextOpts
func (c *Context) TextOpts(o text.Options) text.OptionsTextOpts sets the paragraph base direction of interface text (labels, titles) from the scope: RTL scopes get text.DirRTL, LTR scopes keep the options unchanged. User content should keep text.DirAuto instead.
func (*Context) TextStyle 实验性
func (c *Context) TextStyle(size float32, weight text.Weight) text.StyleTextStyle returns a style using the current theme's family and line height. Custom widgets can use it for both measuring and painting text.
func (*Context) ThemeFor 实验性
func (c *Context) ThemeFor(k theme.Comp) *theme.ThemeThemeFor returns the theme component k reads: the current theme with k's Alias overrides applied (theme.Components.X.Alias), or c.Theme itself when k has none. Components capture it when they are built and paint from it.
func (*Context) Token 实验性
func (c *Context) Token() *theme.ComponentsToken returns the resolved component tokens of the current theme.
func (*Context) TouchCount
func (c *Context) TouchCount() intTouchCount returns how many fingers are on the screen.
func (*Context) TrapFocus
func (c *Context) TrapFocus(panel ID)TrapFocus makes the overlay panel (Overlay(...).ID()) a modal focus scope for this frame: Tab and Shift+Tab cycle inside it and the layers above it, keyboard focus moves into it when it opens and returns to the previously focused widget when it closes, and the semantics tree hides the layers below. Call it every frame the panel is open; Modal, Drawer and the confirm boxes do so already.
func (*Context) WakeAt
func (c *Context) WakeAt(t time.Time)WakeAt asks for a frame at t (timers, auto-dismiss, caret blink).
func (*Context) WakeAtDamaged 实验性
func (c *Context) WakeAtDamaged(t time.Time)WakeAtDamaged asks for a frame at t like WakeAt, for a time-driven change the widget declares itself, with Damage, in the frame it wakes (a text caret's blink): reaching t does not make that frame a full redraw, as reaching a WakeAt timer does (see Damage). The widget must declare everything the clock changed in its drawing.
UI thread only, during the page build or paint.
func (*Context) WantBack
func (c *Context) WantBack() boolWantBack reports whether the system Back action has something to close in the last frame: a dismissible overlay above the page (anything that listened for Escape on a layer above the page) or a ClaimBack call.
func (*Context) WantImagePaste 实验性
func (c *Context) WantImagePaste()WantImagePaste tells the host that the focused text field can handle image-only Paste. Call alongside WantTextInput on each active frame. The host still delivers the regular Paste shortcut.
func (*Context) WantTextInput 实验性
func (c *Context) WantTextInput(caret geom.Rect)WantTextInput tells the host that a text field has focus and where its caret is (for IME candidate windows). Called while painting, caret is in the space being painted; it is mapped to window coordinates.
func (*Context) WantTextInputState 实验性
func (c *Context) WantTextInputState(caret geom.Rect, st input.TextInputState)WantTextInputState is WantTextInput for a field that describes its text to the input method: st carries the text around the selection (rune offsets, see input.TextInputState) and the field's hints. Call it every frame the field has focus, like WantTextInput.
func (*Context) WheelFor
func (c *Context) WheelFor(id ID) (dx, dy float32, ok bool)WheelFor returns the wheel delta that landed on widget id this frame and was not consumed by a scroll container inside it (or by a nested WheelFor listener). Use it for wheel-driven widgets that do not scroll: zoom in an image preview, a carousel, stepping a number. id must be registered for hit testing (any interact/Hovered call); delivery starts the frame after the first call. Wheel over a widget that never asks keeps scrolling the containers around it.
func (*Context) Window
func (c *Context) Window() WindowWindow returns the host window.
func (*Context) WindowFocused
func (c *Context) WindowFocused() boolWindowFocused reports whether the window has key focus (false after the host reported input.WindowFocus{Focused: false}). Stop caret blinking and other focus-only animations while it is false.
ContextMenuOptions 实验性
type ContextMenuOptions struct {
// NoAutoSelect opens the menu with no item highlighted, like the
// context menus of code editors: keyboard focus moves to the menu
// panel itself (role menu, not a Tab stop), Down/Home highlight the
// first enabled item, Up/End the last, a letter or digit the first
// item starting with it, and Enter/Space do nothing until an item is
// highlighted. Pointer hover, Escape and closing work as usual.
NoAutoSelect bool
// Width specifies the root panel width in logical pixels. It is
// capped to the window width minus the edge margins. A non-positive
// value uses the content width. Submenus still size to their content.
Width float32
// contains filtered or unexported fields
}ContextMenuOptions configure ContextMenuAtWith.
ControlSize
type ControlSize uint8ControlSize is the size variant of form controls.
Append-only: never reorder or insert; the zero value stays Middle.
const (
Middle ControlSize = iota
Small
Large
)Conversation 实验性
type Conversation struct {
Key string
Title string // "" shows Locale.Chat.Untitled
Time time.Time // last activity: groups the list by day unless Group is set
Group string // explicit group label
Icon *icon.Icon // leading icon (nil: none)
Running bool // a reply is being generated (spinner)
Disabled bool
// contains filtered or unexported fields
}Conversation is one entry of a Conversations list.
ConversationsW 实验性
type ConversationsW struct {
// contains filtered or unexported fields
}ConversationsW is a list of conversations grouped by time (today, yesterday, previous 7 / 30 days, earlier) with selection and hover actions to rename (F2) and delete (Delete).
func Conversations 实验性
func Conversations(c *Context, items []Conversation, active *string) *ConversationsWConversations adds a conversation list; *active holds the selected key. Put it in a Scroll for long lists, or give it Height (and Virtual for thousands of conversations).
cv := ui.Conversations(c, convs, &cur)
if k, t, ok := cv.Renamed(); ok { rename(k, t) }
if k, ok := cv.Deleted(); ok { remove(k) }
func (*ConversationsW) A11yLabel 实验性
func (w *ConversationsW) A11yLabel(s string) *ConversationsWA11yLabel sets the accessible name (default Locale.Chat.Conversations).
func (*ConversationsW) Deleted 实验性
func (w *ConversationsW) Deleted() (string, bool)Deleted returns the key whose delete action was used this frame.
func (*ConversationsW) Height 实验性
func (w *ConversationsW) Height(px float32) *ConversationsWHeight fixes the list's height; longer lists scroll inside it. Default 0: the list grows with its rows (put it in a Scroll), as before. Call it, Virtual and ScrollToKey before Selected, Renamed and Deleted.
func (*ConversationsW) Layout 实验性
func (w *ConversationsW) Layout(opts ...layout.Option) *ConversationsWLayout applies layout options to the list.
func (*ConversationsW) NoDelete 实验性
func (w *ConversationsW) NoDelete() *ConversationsWNoDelete hides the delete action.
func (*ConversationsW) NoGroups 实验性
func (w *ConversationsW) NoGroups() *ConversationsWNoGroups lists the conversations without group headers.
func (*ConversationsW) NoRename 实验性
func (w *ConversationsW) NoRename() *ConversationsWNoRename hides the rename action.
func (*ConversationsW) Renamed 实验性
func (w *ConversationsW) Renamed() (key, title string, ok bool)Renamed returns the key and new title of a rename committed this frame.
func (*ConversationsW) ScrollToKey 实验性
func (w *ConversationsW) ScrollToKey(key string, align string, offset float64) *ConversationsWScrollToKey scrolls the list (needs Height) to the conversation with key using align (AlignTop, AlignBottom or AlignAuto) plus offset pixels.
func (*ConversationsW) Selected 实验性
func (w *ConversationsW) Selected() (string, bool)Selected returns the key selected this frame.
func (*ConversationsW) Virtual 实验性
func (w *ConversationsW) Virtual() *ConversationsWVirtual builds only the rows in view (and a few past each edge) instead of every conversation; it needs Height and is ignored without it. The selected row and the row being renamed are always built, and the focused row is built on the frame it leaves the view, but focus inside a row clipped out of view is lost, as in the non-virtual Height form; Up / Down / Home / End move over every conversation and scroll the target into view. Rows out of view are missing from the accessibility tree (each option reports its position in the whole list) and FindText. The group layout is cached by the list's length, its first element and the day, and checked against the conversations in view every frame, so Time or Group edited in place (a conversation moved to today, the slice sorted in place) shows right as it comes into view. When the selected key is not in the list (a filtered list without the current conversation), every frame scans the list once for it.
CountdownW 实验性
type CountdownW struct {
// contains filtered or unexported fields
}CountdownW counts down to a deadline (Statistic.Countdown / el-countdown) or, made by StatisticTimer with TimerCountup, counts up from a start time (Ant Statistic.Timer).
func Countdown 实验性
func Countdown(c *Context, title string, deadline time.Time) *CountdownWCountdown adds a countdown to deadline. Format tokens: D, HH, mm, ss, SSS (default "HH:mm:ss"); text in [brackets] is literal.
func StatisticTimer 实验性
func StatisticTimer(c *Context, title string, typ TimerType, at time.Time) *CountdownWStatisticTimer adds a timer statistic (Ant Statistic.Timer): with TimerCountdown it counts down to at like Countdown; with TimerCountup it shows the time elapsed since at (zero before at) and never finishes. Format, Prefix, Suffix, Color and OnChange apply to both.
func (*CountdownW) Color 实验性
func (w *CountdownW) Color(col theme.Color) *CountdownWColor sets the value color.
func (*CountdownW) Finished 实验性
func (w *CountdownW) Finished() boolFinished reports (once) that the deadline passed this frame.
func (*CountdownW) Format 实验性
func (w *CountdownW) Format(f string) *CountdownWFormat sets the display format (see Countdown).
func (*CountdownW) OnChange 实验性
func (w *CountdownW) OnChange(fn func(d time.Duration)) *CountdownWOnChange runs fn with the time left (counting up: the time elapsed) whenever the displayed value changes, e.g. every second with the default format. It does not run on the first frame.
func (*CountdownW) Prefix 实验性
func (w *CountdownW) Prefix(s string) *CountdownWPrefix / Suffix add text around the value.
func (*CountdownW) Suffix 实验性
func (w *CountdownW) Suffix(s string) *CountdownWDamagePresenter 实验性
type DamagePresenter interface {
PresentDamage(img *image.RGBA, dirty []image.Rectangle) error
}DamagePresenter is implemented by windows that can present only the changed parts of a CPU frame. Runner calls it instead of Present when the frame carries damage and the renderer is the CPU renderer.
img is the complete frame (the CPU renderer still rasterizes every pixel); dirty lists the device-pixel rectangles, within img.Bounds(), that differ from the previous frame presented through this window, so a host that keeps its own copy of the last frame may copy only those. Ownership of img is the same as for Present. Frames without damage hints (the first frame, resizes, scale/theme/reduced-motion changes, frames whose widgets declared nothing) still go through Present.
DatePickerLocale
type DatePickerLocale struct {
SelectWeek, SelectMonth, SelectQuarter, SelectYear string // placeholders by granularity
// RangePicker placeholders by granularity (date ranges use the
// top-level StartDate / EndDate).
StartWeek, EndWeek string
StartMonth, EndMonth string
StartQuarter, EndQuarter string
StartYear, EndYear string
PrevDecade, NextDecade string // year panel arrows
WeekFmt string // week value, args: week-based year, week number, English ordinal suffix ("%[1]d-第%[2]d周")
QuarterFmt string // quarter value, args: year, quarter ("%[1]d-Q%[2]d")
QuarterCellFmt string // quarter cell of the panel, arg: quarter ("Q%d")
// contains filtered or unexported fields
}DatePickerLocale holds the texts of the week / month / quarter / year pickers and DatePickerPanel.
DatePickerPanelW 实验性
type DatePickerPanelW struct {
// contains filtered or unexported fields
}DatePickerPanelW is an inline date panel.
func DatePickerPanel 实验性
func DatePickerPanel(c *Context, val *time.Time) *DatePickerPanelWDatePickerPanel adds an inline date panel bound to *val. Picked values are UTC midnights normalized to the start of their period (week start per Locale.WeekStart, first day of the month, quarter or year).
ui.DatePickerPanel(c, &day)
ui.DatePickerPanel(c, &from).Range(&to).Picker(ui.PickerMonth)
func (*DatePickerPanelW) Border 实验性
func (w *DatePickerPanelW) Border(on bool) *DatePickerPanelWBorder toggles the panel border (default on).
func (*DatePickerPanelW) Changed 实验性
func (w *DatePickerPanelW) Changed() boolChanged reports a new value (both ends in range mode) this frame.
func (*DatePickerPanelW) Disabled 实验性
func (w *DatePickerPanelW) Disabled(on bool) *DatePickerPanelWDisabled turns the whole panel off.
func (*DatePickerPanelW) DisabledDate 实验性
func (w *DatePickerPanelW) DisabledDate(fn func(time.Time) bool) *DatePickerPanelWDisabledDate marks periods that cannot be picked (called with the first day of the period).
func (*DatePickerPanelW) MaxDate 实验性
func (w *DatePickerPanelW) MaxDate(t time.Time) *DatePickerPanelWMaxDate limits the pickable dates (Ant maxDate): periods wholly after t are disabled and the header arrows stop at t's page. Zero = no limit.
func (*DatePickerPanelW) MinDate 实验性
func (w *DatePickerPanelW) MinDate(t time.Time) *DatePickerPanelWMinDate limits the pickable dates (Ant minDate): periods wholly before t are disabled and the header arrows stop at t's page. Zero = no limit.
func (*DatePickerPanelW) Picker 实验性
func (w *DatePickerPanelW) Picker(t PickerType) *DatePickerPanelWPicker sets the granularity: PickerDate (default), PickerWeek, PickerMonth, PickerQuarter or PickerYear.
func (*DatePickerPanelW) Range 实验性
func (w *DatePickerPanelW) Range(end *time.Time) *DatePickerPanelWRange turns on range selection: *val holds the start and *end the end (both set by the second click; two panels side by side).
func (*DatePickerPanelW) ShowWeek 实验性
func (w *DatePickerPanelW) ShowWeek(on bool) *DatePickerPanelWShowWeek adds the ISO week-number column to the day grid (Ant showWeek; the week picker always shows it).
func (*DatePickerPanelW) View 实验性
func (w *DatePickerPanelW) View() PickerTypeView returns the view level shown (PickerDate means the day grid).
DatePickerW
type DatePickerW struct {
// contains filtered or unexported fields
}DatePickerW is an input that opens a date panel (days, or weeks, months, quarters or years with Picker).
func DatePicker
func DatePicker(c *Context, val *time.Time) *DatePickerWDatePicker adds a date input bound to *val. Picked values are UTC midnights (with Picker: the first day of the week, month, quarter or year).
The value can also be typed: printable keys edit the text in place and open the panel, which follows a valid date; Enter (or leaving the field) commits it, invalid or disabled text is dropped.
ConfigProvider.Defaults("DatePicker", ...) keys: "format", "placeholder", "picker" (PickerType), "allowClear", "width", "size", "variant", "placement", "showNow", "showWeek", "needConfirm".
func (*DatePickerW) A11yLabel
func (w *DatePickerW) A11yLabel(s string) *DatePickerWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*DatePickerW) AllowClear
func (w *DatePickerW) AllowClear(on bool) *DatePickerWAllowClear toggles the clear button shown on hover (on by default).
func (*DatePickerW) Changed
func (w *DatePickerW) Changed() boolfunc (*DatePickerW) Disabled
func (w *DatePickerW) Disabled(on bool) *DatePickerWfunc (*DatePickerW) DisabledDate
func (w *DatePickerW) DisabledDate(fn func(time.Time) bool) *DatePickerWDisabledDate marks dates that cannot be picked (with Picker: called with the first day of the period).
func (*DatePickerW) Format
func (w *DatePickerW) Format(f string) *DatePickerWFormat sets the Go layout of the value (date, month and year pickers; week and quarter values use the Locale labels "2026-46th" / "2026-Q4").
func (*DatePickerW) IsOpen
func (w *DatePickerW) IsOpen() boolIsOpen reports whether the panel is shown.
func (*DatePickerW) Layout
func (w *DatePickerW) Layout(o ...layout.Option) *DatePickerWLayout applies layout options to the input.
func (*DatePickerW) MaxDate
func (w *DatePickerW) MaxDate(t time.Time) *DatePickerWMaxDate limits the pickable dates (Ant maxDate), like MinDate.
func (*DatePickerW) MinDate
func (w *DatePickerW) MinDate(t time.Time) *DatePickerWMinDate limits the pickable dates (Ant minDate): periods wholly before t cannot be picked or typed, and the panel arrows stop at t's page. Zero = no limit.
func (*DatePickerW) NeedConfirm
func (w *DatePickerW) NeedConfirm(on bool) *DatePickerWNeedConfirm keeps a picked date as a draft until the footer's OK button (or Enter on the picked cell, or Enter after typing) commits it (Ant needConfirm); closing the panel otherwise drops the draft. Presets still commit immediately.
func (*DatePickerW) Open
func (w *DatePickerW) Open() *DatePickerWOpen forces the panel open (screenshots, tests).
func (*DatePickerW) Picker
func (w *DatePickerW) Picker(p PickerType) *DatePickerWPicker sets the granularity: PickerDate (default), PickerWeek, PickerMonth, PickerQuarter or PickerYear (Ant picker, Element type). Clicking the panel titles switches between the year, month and day views.
func (*DatePickerW) Placeholder
func (w *DatePickerW) Placeholder(s string) *DatePickerWfunc (*DatePickerW) Placement
func (w *DatePickerW) Placement(p Placement) *DatePickerWPlacement sets where the panel opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement "bottomLeft" / "bottomRight" / "topLeft" / "topRight"); it flips when there is no room.
func (*DatePickerW) Presets
func (w *DatePickerW) Presets(p ...DatePreset) *DatePickerWPresets adds a side list of named dates (DatePreset.Value) that pick immediately.
func (*DatePickerW) ShowNow
func (w *DatePickerW) ShowNow(on bool) *DatePickerWShowNow toggles the Today link in the panel footer (Ant showNow, on by default for the date picker).
func (*DatePickerW) ShowWeek
func (w *DatePickerW) ShowWeek(on bool) *DatePickerWShowWeek adds the ISO week-number column to the day grid (Ant showWeek; the week picker always shows it).
func (*DatePickerW) Size
func (w *DatePickerW) Size(s ControlSize) *DatePickerWfunc (*DatePickerW) Status
func (w *DatePickerW) Status(s string) *DatePickerWStatus sets the validation look: "error" or "warning".
func (*DatePickerW) Variant
func (w *DatePickerW) Variant(v string) *DatePickerWVariant sets the frame look: "outlined" (default), "filled", "borderless" or "underlined" (Ant variant).
func (*DatePickerW) Width
func (w *DatePickerW) Width(px float32) *DatePickerWWidth sets the input width in pixels (default 180).
DatePreset
type DatePreset struct {
Label string
Range [2]time.Time
Value time.Time
// contains filtered or unexported fields
}DatePreset is a named value shown beside the picker panels: Range for RangePicker, Value for DatePicker (Range[0] when Value is zero).
DateTimePickerW 实验性
type DateTimePickerW struct {
// contains filtered or unexported fields
}DateTimePickerW is an input whose dropdown combines a month calendar with time columns; the value is committed with "确定" or Enter.
func DateTimePicker 实验性
func DateTimePicker(c *Context, val *time.Time) *DateTimePickerWDateTimePicker adds a date-time input bound to *val (zero = empty).
func (*DateTimePickerW) A11yLabel 实验性
func (w *DateTimePickerW) A11yLabel(s string) *DateTimePickerWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*DateTimePickerW) AllowClear 实验性
func (w *DateTimePickerW) AllowClear(on bool) *DateTimePickerWfunc (*DateTimePickerW) Changed 实验性
func (w *DateTimePickerW) Changed() boolChanged reports a committed value this frame.
func (*DateTimePickerW) DefaultTime 实验性
func (w *DateTimePickerW) DefaultTime(t time.Time) *DateTimePickerWDefaultTime is the clock given to a day picked while no time is set (Element default-time, Ant showTime.defaultValue; default 00:00:00). Only its hour, minute and second are used.
func (*DateTimePickerW) Disabled 实验性
func (w *DateTimePickerW) Disabled(on bool) *DateTimePickerWDisabled disables the picker.
func (*DateTimePickerW) DisabledDate 实验性
func (w *DateTimePickerW) DisabledDate(fn func(time.Time) bool) *DateTimePickerWDisabledDate marks days that cannot be picked (called with UTC midnights); typed or preset values on such a day are not committed.
func (*DateTimePickerW) DisabledTime 实验性
func (w *DateTimePickerW) DisabledTime(fn func(day time.Time) DisabledTimes) *DateTimePickerWDisabledTime disables hours, minutes and seconds per day (Ant disabledTime): fn receives the drafted day (UTC midnight) and returns the options to grey out in the time columns. A value whose clock is disabled cannot be confirmed.
func (*DateTimePickerW) Format 实验性
func (w *DateTimePickerW) Format(f string) *DateTimePickerWFormat sets the Go layout (default "2006-01-02 15:04:05"); omitting the seconds hides the second column.
func (*DateTimePickerW) IsOpen 实验性
func (w *DateTimePickerW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*DateTimePickerW) Layout 实验性
func (w *DateTimePickerW) Layout(o ...layout.Option) *DateTimePickerWfunc (*DateTimePickerW) MaxDate 实验性
func (w *DateTimePickerW) MaxDate(t time.Time) *DateTimePickerWMaxDate limits the pickable days (Ant maxDate), like MinDate.
func (*DateTimePickerW) MinDate 实验性
func (w *DateTimePickerW) MinDate(t time.Time) *DateTimePickerWMinDate limits the pickable days (Ant minDate): earlier days cannot be picked, typed or confirmed and the month arrows stop at t's month.
func (*DateTimePickerW) Open 实验性
func (w *DateTimePickerW) Open() *DateTimePickerWOpen forces the dropdown open (screenshots, tests).
func (*DateTimePickerW) Placeholder 实验性
func (w *DateTimePickerW) Placeholder(s string) *DateTimePickerWfunc (*DateTimePickerW) Placement 实验性
func (w *DateTimePickerW) Placement(p Placement) *DateTimePickerWPlacement sets where the dropdown opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement); it flips when there is no room.
func (*DateTimePickerW) Presets 实验性
func (w *DateTimePickerW) Presets(p ...DatePreset) *DateTimePickerWPresets adds a side list of named date-times (DatePreset.Value, else Range[0]) that commit immediately.
func (*DateTimePickerW) ShowNow 实验性
func (w *DateTimePickerW) ShowNow(on bool) *DateTimePickerWShowNow toggles the Now action in the footer (Ant showNow, on by default).
func (*DateTimePickerW) Size 实验性
func (w *DateTimePickerW) Size(s ControlSize) *DateTimePickerWfunc (*DateTimePickerW) Status 实验性
func (w *DateTimePickerW) Status(s string) *DateTimePickerWfunc (*DateTimePickerW) Steps 实验性
func (w *DateTimePickerW) Steps(h, m, s int) *DateTimePickerWfunc (*DateTimePickerW) Variant 实验性
func (w *DateTimePickerW) Variant(v string) *DateTimePickerWVariant sets the frame look: "outlined" (default), "filled", "borderless" or "underlined".
func (*DateTimePickerW) Width 实验性
func (w *DateTimePickerW) Width(px float32) *DateTimePickerWDefaultFooterW 实验性
type DefaultFooterW struct {
// contains filtered or unexported fields
}DefaultFooterW is the Pro page footer: a row of links above a copyright line, centred (Ant Design Pro DefaultFooter).
ui.DefaultFooter(c).Links(links).Copyright("© 2026 Tango").Show()
func DefaultFooter 实验性
func DefaultFooter(c *Context) *DefaultFooterWDefaultFooter starts a footer; chain options, then Show.
func (*DefaultFooterW) Clicked 实验性
func (f *DefaultFooterW) Clicked() stringClicked returns the Key of the link clicked in the last Show ("" if none).
func (*DefaultFooterW) Copyright 实验性
func (f *DefaultFooterW) Copyright(s string) *DefaultFooterWCopyright sets the line under the links (shown as given, so include the © sign yourself).
func (*DefaultFooterW) Links 实验性
func (f *DefaultFooterW) Links(links []FooterLink) *DefaultFooterWLinks sets the link row.
func (*DefaultFooterW) Show 实验性
func (f *DefaultFooterW) Show() *DefaultFooterWShow builds the footer.
DescItem 实验性
type DescItem struct {
Label, Value string
Span int
Render func()
// Spans sets the span from a breakpoint upwards (antd span={{ xs: 1,
// md: 2 }}); the largest set breakpoint not above the window width
// wins, Span is the fallback.
Spans map[Breakpoint]int
// Filled makes the item take the rest of its row and ends the row
// (antd span: 'filled').
Filled bool
}DescItem is one label/value pair; Render replaces Value with custom content, Span takes several columns.
DescriptionsW 实验性
type DescriptionsW struct {
// contains filtered or unexported fields
}DescriptionsW is a description list: title, extra, columns, bordered, sizes, vertical layout, label width, per-item span and custom render.
func Descriptions 实验性
func Descriptions(c *Context, items []DescItem) *DescriptionsWDescriptions adds a description list (no border). Without Column or a "column" default the column count follows antd's DEFAULT_COLUMN_MAP: 1 on xs, 2 on sm, 3 from md up. Modifiers apply until the end of the build; the content is built then.
ConfigProvider.Defaults("Descriptions", ...) keys: "column" (int or map[Breakpoint]int), "bordered", "size", "layout" ("vertical"), "colon" (bool).
func (*DescriptionsW) Bordered 实验性
func (d *DescriptionsW) Bordered() *DescriptionsWfunc (*DescriptionsW) Column 实验性
func (d *DescriptionsW) Column(n int) *DescriptionsWfunc (*DescriptionsW) ColumnAt 实验性
func (d *DescriptionsW) ColumnAt(bp Breakpoint, n int) *DescriptionsWColumnAt sets the column count from breakpoint bp upwards (Ant column={{ xs: 1, sm: 2, md: 3 }}); the largest set breakpoint not above the window width wins, Column (default DEFAULT_COLUMN_MAP) is the fallback.
func (*DescriptionsW) Columns 实验性
func (d *DescriptionsW) Columns(m map[Breakpoint]int) *DescriptionsWColumns sets several breakpoint column counts at once.
func (*DescriptionsW) Extra 实验性
func (d *DescriptionsW) Extra(fn func()) *DescriptionsWfunc (*DescriptionsW) LabelBg 实验性
func (d *DescriptionsW) LabelBg(col theme.Color) *DescriptionsWLabelBg overrides the bordered label background.
func (*DescriptionsW) LabelWidth 实验性
func (d *DescriptionsW) LabelWidth(px float32) *DescriptionsWfunc (*DescriptionsW) Layout 实验性
func (d *DescriptionsW) Layout(o ...layout.Option) *DescriptionsWLayout applies layout options to the list.
func (*DescriptionsW) NoColon 实验性
func (d *DescriptionsW) NoColon() *DescriptionsWfunc (*DescriptionsW) Size 实验性
func (d *DescriptionsW) Size(s ControlSize) *DescriptionsWfunc (*DescriptionsW) Title 实验性
func (d *DescriptionsW) Title(s string) *DescriptionsWfunc (*DescriptionsW) Vertical 实验性
func (d *DescriptionsW) Vertical() *DescriptionsWDirection
type Direction uint8Direction is the inline (horizontal) layout direction of a scope: left-to-right or right-to-left. It is unrelated to layout.Direction (Row / Column) and text.Direction (paragraph base direction).
Append-only: never reorder or insert; the zero value stays DirAuto.
const (
// DirAuto derives the direction from the scope's Locale.
DirAuto Direction = iota
// LTR lays out from left to right.
LTR
// RTL lays out from right to left: rows start at the right edge,
// Padding/Margin Left act as the start side, directional icons mirror.
RTL
)func DefaultDirection
func DefaultDirection() DirectionDefaultDirection returns the value set by SetDefaultDirection.
DisabledTimes 实验性
type DisabledTimes struct {
Hours func(h int) bool
Minutes func(h, m int) bool
Seconds func(h, m, s int) bool
// contains filtered or unexported fields
}DisabledTimes lists the clock options that cannot be picked on one day (the result of a DisabledTime callback: Ant disabledTime). Nil fields disable nothing; values are 24-hour.
DividerW
type DividerW struct {
*Box
// contains filtered or unexported fields
}DividerW is the Box of a Divider with its line options; it embeds the *Box, so code using the returned box keeps working.
ConfigProvider.Defaults("Divider", ...) keys: "dashed" (bool), "variant" ("solid" | "dashed" | "dotted"), "orientation" ("horizontal" | "vertical"; a title placement is still accepted), "vertical" (bool), "titlePlacement" ("start" | "end" | "left" | "right" | "center"), "plain" (bool), "size" (ControlSize).
func Divider
func Divider(c *Context, title ...string) *DividerWDivider draws a horizontal rule, optionally with a title.
func (*DividerW) Dashed
func (d *DividerW) Dashed() *DividerWDashed draws a dashed line (Variant("dashed")).
func (*DividerW) Orientation
func (d *DividerW) Orientation(s string) *DividerWOrientation sets the direction: "horizontal" (default) or "vertical" (Ant v6 orientation). A title placement ("left", "right", "center", "start", "end") is still accepted here and sets TitlePlacement, as Ant does for the pre-v6 meaning; new code sets the title placement with TitlePlacement.
func (*DividerW) Plain
func (d *DividerW) Plain() *DividerWPlain shows the title in the normal text style (Ant plain).
func (*DividerW) Size
func (d *DividerW) Size(s ControlSize) *DividerWSize sets the block margin of a horizontal divider (Ant size): Small 8px, Middle 16px; Large keeps the default.
func (*DividerW) TitlePlacement
func (d *DividerW) TitlePlacement(s string) *DividerWTitlePlacement places the title: "start", "end" (logical), "left", "right" (physical) or "center" (default; Ant titlePlacement, Element content-position). Other values are ignored.
func (*DividerW) Variant
func (d *DividerW) Variant(v string) *DividerWVariant sets the line style: "solid" (default), "dashed" or "dotted" (Ant variant, Element border-style). Other values are ignored.
func (*DividerW) Vertical
func (d *DividerW) Vertical() *DividerWVertical turns the divider into an inline vertical separator like VDivider (Ant vertical / orientation="vertical", Element direction="vertical"); a title is not shown.
DockAxis 实验性
type DockAxis stringDockAxis is the direction of a DockNode split: DockRow lays its children side by side (in the reading direction), DockColumn stacks them.
const (
DockRow DockAxis = "row"
DockColumn DockAxis = "column"
)实验性
DockLayout 实验性
type DockLayout struct {
Root *DockNode `json:"root"`
Focus string `json:"focus,omitempty"` // ID of the focused group (new tabs go there)
Maximized string `json:"maximized,omitempty"` // ID of the group filling the dock ("" when none)
// contains filtered or unexported fields
}DockLayout is the state of a Dock: a tree of splits whose leaves are tab groups, the focused group and the maximized one. The application owns it; Dock edits it in place as the user drags, closes, splits or resizes. It marshals to JSON with encoding/json (save it when DockW.Changed reports) and loads back with ParseDockLayout.
Methods keep the invariants (call Normalize after editing the tree by hand): every tab key appears once, splits have at least two children and never a child split of the same axis, sizes are positive fractions, group IDs are unique and only the root may be an empty group.
func NewDockLayout 实验性
func NewDockLayout(tabs ...string) *DockLayoutNewDockLayout returns a layout with one group holding tabs (the first one active).
func ParseDockLayout 实验性
func ParseDockLayout(data []byte) (*DockLayout, error)ParseDockLayout decodes a layout saved with json.Marshal and repairs whatever breaks the invariants (unknown axes, missing IDs, repeated keys, wrong sizes), so a hand-edited or older file still loads.
func (*DockLayout) Activate 实验性
func (l *DockLayout) Activate(key string) boolActivate makes key the active tab of its group and focuses the group. It reports whether the layout holds key.
func (*DockLayout) AddTab 实验性
func (l *DockLayout) AddTab(key, group string)AddTab adds key to the group with ID group ("" for the focused group), after its active tab, and activates it. A key already in the layout is only activated.
func (*DockLayout) FocusGroup 实验性
func (l *DockLayout) FocusGroup() *DockNodeFocusGroup returns the focused group (the first one when Focus names none).
func (*DockLayout) Group 实验性
func (l *DockLayout) Group(id string) *DockNodeGroup returns the group with the given ID (nil when none).
func (*DockLayout) GroupOf 实验性
func (l *DockLayout) GroupOf(key string) *DockNodeGroupOf returns the group holding the tab key (nil when none).
func (*DockLayout) Groups 实验性
func (l *DockLayout) Groups() []*DockNodeGroups returns the tab groups in reading order (depth first).
func (*DockLayout) MoveTab 实验性
func (l *DockLayout) MoveTab(key, group string, index int) boolMoveTab moves key into the group with ID group at index (clamped; < 0 appends) and activates it there. Moving within a group reorders it. It reports whether anything moved.
func (*DockLayout) Normalize 实验性
func (l *DockLayout) Normalize()Normalize restores the invariants after the tree was edited by hand: it drops nil children, repeated tab keys and empty groups (keeping one group), collapses splits with a single child, merges a split into a parent of the same axis, fixes sizes, unknown axes, missing or repeated group IDs and active tabs, and clears Focus / Maximized when they name no group.
func (*DockLayout) RemoveTab 实验性
func (l *DockLayout) RemoveTab(key string) boolRemoveTab removes key. A group left empty is removed (unless it is the last one) and its neighbours take its space; the group's next tab (or previous) becomes active. It reports whether the layout held key.
func (*DockLayout) SplitTab 实验性
func (l *DockLayout) SplitTab(key, group string, side DockSide) (string, bool)SplitTab moves key into a new group on side of the group with ID group (DockCenter appends it to that group instead) and returns the new group's ID. Splitting a group's only tab off itself does nothing.
DockLocale 实验性
type DockLocale struct {
Maximize, Restore, Split string // header buttons (accessible names, tooltips)
Empty string // hint shown in a group without tabs
Group string // accessible name of a tab group
// contains filtered or unexported fields
}DockLocale holds the Dock texts: the group header buttons, the hint of an empty group and the accessible name of a group.
DockNode 实验性
type DockNode struct {
// Group (leaf).
ID string `json:"id,omitempty"`
Tabs []string `json:"tabs,omitempty"`
Active string `json:"active,omitempty"`
// Split.
Axis DockAxis `json:"axis,omitempty"`
Children []*DockNode `json:"children,omitempty"`
Sizes []float64 `json:"sizes,omitempty"` // fractions of the split, one per child, summing to 1
// contains filtered or unexported fields
}DockNode is a node of a dock layout: a split (Axis set, Children with their Sizes) or a tab group (a leaf: ID, Tabs and the Active tab). Tabs holds application keys; Dock asks the application for each key's title and content.
func (*DockNode) IsGroup 实验性
func (n *DockNode) IsGroup() boolIsGroup reports whether n is a tab group (not a split).
DockSide 实验性
type DockSide uint8DockSide is where a tab lands relative to a group: in it (DockCenter) or in a new group beside it. DockLeft and DockRight are logical: in a right-to-left scope DockLeft is the right (start) side.
Append-only: never reorder or insert; existing values never change.
const (
DockCenter DockSide = iota
DockLeft
DockRight
DockTop
DockBottom
)实验性
DockW 实验性
type DockW struct {
// contains filtered or unexported fields
}DockW is a docking layout (IDE workbench): nested horizontal / vertical splits whose leaves are tab groups, edited by the user and kept in a DockLayout the application owns.
func Dock 实验性
func Dock(c *Context, l *DockLayout) *DockWDock adds a docking layout editing l: tab groups in nested splits. Drag a tab onto another group's tab bar to move it there, onto the left, right, top or bottom part of a group's content to split that group, or onto its middle to merge; a preview shows where it lands. Drag the bars between groups to resize them; the header buttons split the active tab to the right and maximize / restore the group. Tabs close with their x (or Delete), and a group left empty disappears.
Tab supplies each key's label and icon (TabItem.NoClose keeps a tab open), Content builds the active tab of each group. Call Show after the options, then read Changed (save l) and Closed. The layout is edited in place; the content of a tab keeps its widget state when the tab moves to another group.
Experimental: the API may change in any 0.x release.
func (*DockW) BeforeClose 实验性
func (d *DockW) BeforeClose(fn func(key string) bool) *DockWBeforeClose is asked before a tab closes; returning false keeps it (an unsaved document).
func (*DockW) Changed 实验性
func (d *DockW) Changed() boolChanged reports an edit of the layout this frame (a move, split, close, resize, maximize, focus or active tab change): the moment to save it.
func (*DockW) Closed 实验性
func (d *DockW) Closed() stringClosed returns the key of the tab closed this frame ("" when none).
func (*DockW) Content 实验性
func (d *DockW) Content(fn func(key string)) *DockWContent sets the function that builds the content of a group's active tab. It runs once per visible group.
func (*DockW) OnTearOff 实验性
func (d *DockW) OnTearOff(fn func(key string, pos geom.Point)) *DockWOnTearOff lets a tab be dragged out of the window: released outside, the tab leaves the layout and fn runs with its key and the release point (window coordinates; see TabsW.OnTearOff). The application opens it in a new window.
func (*DockW) Show 实验性
func (d *DockW) Show() *DockWShow builds the dock.
func (*DockW) Style 实验性
func (d *DockW) Style(opts ...layout.Option) *DockWStyle applies layout options to the dock (give it a size: layout.Grow(1), layout.H(480) ...).
func (*DockW) Tab 实验性
func (d *DockW) Tab(fn func(key string) TabItem) *DockWTab sets how a tab key is shown (label, icon, NoClose, Disabled; Key is ignored). Without it the key is the label.
func (*DockW) TornOff 实验性
func (d *DockW) TornOff() (key string, pos geom.Point, ok bool)TornOff reports the tab torn off this frame (see OnTearOff).
DrawerPlacement
type DrawerPlacement uint8DrawerPlacement selects the edge a Drawer slides from. DrawerEnd (the zero value and default) and DrawerStart are logical: in RTL the end is the left edge. DrawerRight and DrawerLeft always mean that physical edge.
Append-only: never reorder or insert; the zero value stays DrawerEnd.
const (
DrawerEnd DrawerPlacement = iota
DrawerRight
DrawerLeft
DrawerTop
DrawerBottom
DrawerStart
)DrawerW
type DrawerW struct {
// contains filtered or unexported fields
}DrawerW is a panel sliding from a window edge: four placements, nested drawers push their parent aside, header extra, footer, sizes.
func Drawer
func Drawer(c *Context, open *bool, title string) *DrawerWDrawer starts a drawer shown while *open; chain options, then Body. A Drawer opened inside another one's Body pushes the parent aside.
Besides the keys read in shad2c_defaults.go, ConfigProvider.Defaults( "Drawer", ...) reads "keyboard" (bool) and "closablePlacement" ("start" / "end").
func (*DrawerW) AfterOpenChanged
func (d *DrawerW) AfterOpenChanged() boolAfterOpenChanged reports, after Body, that the open or close slide finished this frame (antd afterOpenChange; read *open for the state).
func (*DrawerW) BindSize
func (d *DrawerW) BindSize(px *float32) *DrawerWBindSize binds the size to *px: a positive value overrides Size, and a resize writes the new size back.
func (*DrawerW) Body
func (d *DrawerW) Body(fn func()) *DrawerWBody builds the drawer content.
func (*DrawerW) Closable
func (d *DrawerW) Closable(on bool) *DrawerWfunc (*DrawerW) ClosablePlacement
func (d *DrawerW) ClosablePlacement(p string) *DrawerWClosablePlacement puts the close button "start" (before the title) or "end" (after the title and extra); default from the theme (Ant start, Element and shadcn end; antd closable.placement).
func (*DrawerW) Closed
func (d *DrawerW) Closed() boolClosed reports close / mask / Escape this frame.
func (*DrawerW) CurrentSize
func (d *DrawerW) CurrentSize() float32CurrentSize returns the width / height used this frame (after Body).
func (*DrawerW) Extra
func (d *DrawerW) Extra(fn func()) *DrawerWfunc (*DrawerW) Footer
func (d *DrawerW) Footer(fn func()) *DrawerWfunc (*DrawerW) Keyboard
func (d *DrawerW) Keyboard(on bool) *DrawerWKeyboard sets whether Escape closes the drawer (default true; antd keyboard, Element close-on-press-escape).
func (*DrawerW) Large
func (d *DrawerW) Large() *DrawerWLarge uses the large preset (736).
func (*DrawerW) Loading
func (d *DrawerW) Loading(on bool) *DrawerWLoading shows an active Skeleton instead of the content (antd loading).
func (*DrawerW) Mask
func (d *DrawerW) Mask(on bool) *DrawerWfunc (*DrawerW) MaskBlur
func (d *DrawerW) MaskBlur(radius float32) *DrawerWMaskBlur sets the Gaussian blur radius of the canvas behind the mask, in logical pixels. A zero radius draws the mask without blur.
func (*DrawerW) MaskClosable
func (d *DrawerW) MaskClosable(on bool) *DrawerWfunc (*DrawerW) NoHeader
func (d *DrawerW) NoHeader() *DrawerWfunc (*DrawerW) Placement
func (d *DrawerW) Placement(p DrawerPlacement) *DrawerWPlacement selects the edge (DrawerEnd default: right, left in RTL).
func (*DrawerW) Push
func (d *DrawerW) Push(px float32) *DrawerWPush sets how far a nested drawer pushes this one aside (default 180; 0 turns it off; antd push.distance).
func (*DrawerW) Resizable
func (d *DrawerW) Resizable(on bool) *DrawerWResizable lets the user drag the edge facing the page to change the width (left / right) or height (top / bottom). The edge is also a focusable separator: arrow keys step 10px (Shift: 50px), Home / End go to the limits. The chosen size is kept while the drawer exists; use BindSize to own it.
func (*DrawerW) Resized
func (d *DrawerW) Resized() boolResized reports a size change by the user this frame.
func (*DrawerW) Size
func (d *DrawerW) Size(px float32) *DrawerWSize sets the width (left/right) or height (top/bottom); default from theme.DrawerToken: 378 (Ant), 30% of the window (Element), 384 but at most 75% (shadcn Sheet).
func (*DrawerW) SizeLimits
func (d *DrawerW) SizeLimits(min, max float32) *DrawerWSizeLimits bounds a resizable drawer (px). Zero min means 100; zero max means the window width / height.
Driver
type Driver struct {
// contains filtered or unexported fields
}Driver runs a page without a native window: inject events, run frames and read back the rendered *image.RGBA. It is used by tests, screenshot tools and the ui-gallery example. Time is simulated: it only advances through Advance / Settle, so output is deterministic.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func NewDriver
func NewDriver(page func(*Context), o DriverOptions) *DriverNewDriver creates a headless driver for page.
func (*Driver) A11yFind
func (d *Driver) A11yFind(role a11y.Role, name string) (*a11y.Node, bool)A11yFind returns the first node with role and name in the last tree (a11y.RoleNone matches any role, "" any name).
func (*Driver) A11yFindAll
func (d *Driver) A11yFindAll(role a11y.Role, name string) []*a11y.NodeA11yFindAll returns every node with role and name in the last tree.
func (*Driver) A11yFocused
func (d *Driver) A11yFocused() *a11y.NodeA11yFocused returns the node with keyboard focus (nil if none).
func (*Driver) A11yPerform
func (d *Driver) A11yPerform(role a11y.Role, name string, act a11y.Action, arg string) errorA11yPerform finds the node with role and name and performs act on it.
func (*Driver) A11yUpdates 实验性
func (d *Driver) A11yUpdates() (int, []a11y.NodeID)A11yUpdates returns how many times the host was notified and the changed IDs of the last notification.
func (*Driver) AccessibilityTree 实验性
func (d *Driver) AccessibilityTree() *a11y.TreeAccessibilityTree returns the semantics tree of the last frame (nil until EnableAccessibility).
func (*Driver) Advance
func (d *Driver) Advance(dt time.Duration)Advance moves simulated time forward.
func (*Driver) Audit 实验性
func (d *Driver) Audit() AuditReportAudit enables accessibility, settles and checks the current frame: interactive nodes without an accessible name, pointer targets without a role, controls the keyboard cannot reach, and contrast problems of the current theme (see theme.CheckContrast), and in right-to-left scopes directional icons drawn without mirroring. Drive the page into the state to check (open popups with Click / Key) before calling it.
func (*Driver) AuditNoContrast 实验性
func (d *Driver) AuditNoContrast() AuditReportAuditNoContrast is Audit without the theme contrast checks (when several pages share one theme and contrast is reported once).
func (*Driver) BackHandling 实验性
func (d *Driver) BackHandling() boolBackHandling reports what the runner last told the window through BackWindow: whether the system Back action has something to close.
func (*Driver) Click
func (d *Driver) Click(p geom.Point)Click moves, presses and releases at p, then settles.
func (*Driver) ClickLabel
func (d *Driver) ClickLabel(text string) errorClickLabel clicks the center of the first widget whose label is text.
func (*Driver) Clipboard
func (d *Driver) Clipboard() stringClipboard returns the fake clipboard.
func (*Driver) Compose 实验性
func (d *Driver) Compose(s string, cursor int)Compose sets the IME composition string.
func (*Driver) ContentSize 实验性
func (d *Driver) ContentSize() geom.SizeContentSize returns the extent of the page's top-level widgets in the last frame (useful to size screenshots to their content).
func (*Driver) Cursor 实验性
func (d *Driver) Cursor() input.CursorCursor returns the cursor last requested by the UI.
func (*Driver) Drag
func (d *Driver) Drag(from, to geom.Point)Drag presses at from, moves to to in a few steps (one frame each) and releases there, then settles.
func (*Driver) DropFiles 实验性
func (d *Driver) DropFiles(p geom.Point, paths ...string)DropFiles simulates dropping files at p (after FileDragLeave, as hosts do) and runs a frame.
func (*Driver) EnableAccessibility 实验性
func (d *Driver) EnableAccessibility() *a11y.TreeEnableAccessibility turns the semantics tree on (the fake window acts as an AccessibilityHost that asked for it), settles and returns the tree.
func (*Driver) FileDragLeave 实验性
func (d *Driver) FileDragLeave()FileDragLeave simulates the file drag leaving the window.
func (*Driver) FileDragOver 实验性
func (d *Driver) FileDragOver(p geom.Point)FileDragOver simulates files dragged over the window at p and runs a frame (tests).
func (*Driver) Find
func (d *Driver) Find(label string) (geom.Rect, bool)Find returns the rect of the top-most interactive widget with label.
func (*Driver) FindText
func (d *Driver) FindText(text string) (geom.Rect, bool)FindText returns the rect of a node labelled text in the last frame, including non-interactive ones (Text, Title, Paragraph, labels inside widgets) that Find does not see. Layers are searched top-most first. An exact label match wins; otherwise the first label containing text is used.
func (*Driver) Frame
func (d *Driver) Frame() *image.RGBAFrame runs one frame and returns the image.
func (*Driver) Image
func (d *Driver) Image() *image.RGBAImage returns the last frame.
func (*Driver) Inject 实验性
func (d *Driver) Inject(e input.Event)Inject queues an event (processed on the next Frame).
func (*Driver) Key
func (d *Driver) Key(k input.Key, mods input.Modifiers)Key presses and releases a key.
func (*Driver) MirrorCheck 实验性
func (d *Driver) MirrorCheck(page func(*Context), setup ...func(*Driver)) MirrorReportMirrorCheck renders page left to right and right to left (wrapped in ConfigProvider(c).Direction(...)) at d's size, scale and theme, settles each frame (after the optional setup, e.g. opening a popup) and compares every node drawn in both frames.
Each node is checked relative to its parent: with p the parent's rectangle, the RTL node must sit at x' = p'.X + p.W - (x - p.X) - w, with the same y offset and size (±1px). Checking against the parent instead of the window (|X_rtl − (W − X_ltr − W_n)|) reports only the node at fault, not its whole subtree; for a chain of correctly mirrored parents the two are the same. Nodes without a parent drawn in both frames (overlay roots) are checked against the window.
Skipped: nodes with layout.Physical() (NoMirror) and children of boxes that lay out left to right in the RTL frame (an LTR scope such as a code editor or chart, or the window root outside the page's provider).
Icon check: every icon drawn in the RTL frame is recorded (see paint.List.IconNote); a directional icon drawn unmirrored while its node was painted in a right-to-left scope is reported in Icons, located at the deepest node containing it. Icons in LTR scopes are not reported; icons inside a NoMirror node or subtree are counted in IconsSkipped.
func (*Driver) Move
func (d *Driver) Move(p geom.Point)Move moves the pointer and runs a frame.
func (*Driver) NeedsFrame
func (d *Driver) NeedsFrame() boolNeedsFrame reports whether the UI asked for another frame.
func (*Driver) Now
func (d *Driver) Now() time.TimeNow returns simulated time.
func (*Driver) PerformAction 实验性
func (d *Driver) PerformAction(id a11y.NodeID, act a11y.Action, arg string) errorPerformAction runs an accessibility action like a screen reader would (Runner.PerformAction) and settles.
func (*Driver) Pinch 实验性
func (d *Driver) Pinch(center geom.Point, from, to float32)Pinch puts two fingers down on a horizontal line through center, from apart, moves them symmetrically until they are to apart (to > from zooms in) and lifts them, then settles.
func (*Driver) Presented 实验性
func (d *Driver) Presented() intPresented returns how many frames were presented.
func (*Driver) Resize
func (d *Driver) Resize(w, h float32)Resize changes the logical window size.
func (*Driver) RightClick
func (d *Driver) RightClick(p geom.Point)RightClick presses and releases the secondary button at p (context menus), then settles.
func (*Driver) Runner
func (d *Driver) Runner() *RunnerRunner returns the underlying runner.
func (*Driver) SavePNG
func (d *Driver) SavePNG(path string) errorSavePNG writes the last frame to path, creating directories.
func (*Driver) Scroll
func (d *Driver) Scroll(p geom.Point, dy float32)Scroll scrolls at p by dy.
func (*Driver) SetClipboard
func (d *Driver) SetClipboard(s string)SetClipboard sets the fake clipboard.
func (*Driver) SetKeyboardInset
func (d *Driver) SetKeyboardInset(in geom.Insets)SetKeyboardInset sets the keyboard inset the page sees (Runner.SetKeyboardInset); the next frame picks it up.
func (*Driver) SetSafeArea
func (d *Driver) SetSafeArea(in geom.Insets)SetSafeArea sets the safe-area insets the page sees (Runner.SetSafeArea); the next frame picks them up.
func (*Driver) SetTheme
func (d *Driver) SetTheme(t *theme.Theme)SetTheme switches theme.
func (*Driver) Settle
func (d *Driver) Settle() *image.RGBASettle runs frames, advancing simulated time 16ms per frame, until nothing animates (at most 2 simulated seconds).
func (*Driver) Tap
func (d *Driver) Tap(p geom.Point)Tap touches p with one finger and lifts it in the same frame, then settles.
func (*Driver) TextInputActive 实验性
func (d *Driver) TextInputActive() (bool, geom.Rect)TextInputActive reports whether the UI requested IME input and the caret.
func (*Driver) TextInputState 实验性
func (d *Driver) TextInputState() (input.TextInputState, bool)TextInputState returns the text-input state the Runner last reported and whether one is in effect (tests).
func (*Driver) Touch 实验性
func (d *Driver) Touch(id int64, phase input.TouchPhase, p geom.Point)Touch injects one finger change and runs a frame.
func (*Driver) TouchDrag 实验性
func (d *Driver) TouchDrag(from, to geom.Point)TouchDrag puts one finger down at from, moves it to to in a few steps (one frame and touchStep of simulated time each) and lifts it, then settles.
func (*Driver) Touches 实验性
func (d *Driver) Touches(evs ...input.TouchEvent)Touches injects several finger changes delivered in the same frame and runs it.
func (*Driver) TwoFingerPan 实验性
func (d *Driver) TwoFingerPan(from, to geom.Point, spread float32)TwoFingerPan puts two fingers down around from (spread px apart), moves both to to without changing their distance and lifts them, then settles.
func (*Driver) Type
func (d *Driver) Type(s string)Type delivers committed text to the focused widget.
DriverOptions
type DriverOptions struct {
Width, Height float32 // logical size, default 1024×768
Scale float32 // default 1
Theme *theme.Theme
Animations bool // run transitions (default: jump to end state)
ReduceMotion bool // RunnerOptions.ReduceMotion (use with Animations)
Accessibility bool // build the semantics tree from the first frame
// contains filtered or unexported fields
}DriverOptions configure a Driver.
DropZoneLocale 实验性
type DropZoneLocale struct {
Name, Release string
// contains filtered or unexported fields
}DropZoneLocale holds the DropZone accessible name and drag-over announcement.
DropZoneW 实验性
type DropZoneW struct {
// contains filtered or unexported fields
}DropZoneW is an area that reacts to files dragged over the window (Ant Design Upload.Dragger's hover state, as a standalone wrapper):
z := ui.DropZone(c, func(over bool) {
ui.Upload(c, &files).Dragger().DragOver(over)
}).Highlight(false)
if paths := z.Dropped(); paths != nil { ... }
Nested zones: the innermost (last built) zone under the drag wins.
func DropZone 实验性
func DropZone(c *Context, body func(over bool)) *DropZoneWDropZone builds body in a zone; body receives whether files are dragged over the zone (from the previous build pass, so it is stable within a frame).
func (*DropZoneW) A11yLabel 实验性
func (z *DropZoneW) A11yLabel(s string) *DropZoneWA11yLabel names the zone for screen readers ("" keeps the default).
func (*DropZoneW) Dropped 实验性
func (z *DropZoneW) Dropped() []stringDropped returns the paths of files dropped on the zone (Runner.DropFiles) once, or nil.
func (*DropZoneW) Highlight 实验性
func (z *DropZoneW) Highlight(on bool) *DropZoneWHighlight toggles the built-in highlight (a tinted, dashed overlay; default on). Turn it off when the content shows its own (Upload's Dragger with DragOver).
func (*DropZoneW) ID 实验性
func (z *DropZoneW) ID() IDID returns the zone's widget ID.
func (*DropZoneW) Layout 实验性
func (z *DropZoneW) Layout(o ...layout.Option) *DropZoneWLayout applies layout options to the zone.
func (*DropZoneW) Over 实验性
func (z *DropZoneW) Over() boolOver reports files dragged over the zone.
func (*DropZoneW) TakeDrop 实验性
func (z *DropZoneW) TakeDrop() (FileDrop, bool)TakeDrop returns and consumes the pending drop on this zone. It shares consumption with Dropped, so use either query for a given drop.
DropdownW
type DropdownW struct {
// contains filtered or unexported fields
}DropdownW is a menu attached to a trigger: hover / click / context-menu triggers, nested submenus, placements, arrow, selected key, keyboard navigation, and the split-button form (Button).
func Dropdown
func Dropdown(c *Context, items []MenuItem) *DropdownWDropdown starts a dropdown menu; chain options, then Body with the trigger content, or Button for a split button (Ant Dropdown.Button, Element split-button):
if k := ui.Dropdown(c, items).Trigger(ui.TriggerClick).Body(func() { ui.Button(c, "更多") }).Clicked(); k != "" { ... }
dd := ui.Dropdown(c, items).Primary().Button("提交")
ConfigProvider.Defaults("Dropdown", ...) keys: "trigger", "placement", "arrow", "disabled", "mouseEnterDelay" / "mouseLeaveDelay" (time.Duration; default the Dropdown token: Ant 150 / 100 ms, Element 150 / 150 ms), "autoFocus", "hideOnClick" (bool, default true).
func (*DropdownW) Arrow
func (d *DropdownW) Arrow() *DropdownWArrow draws a pointer towards the trigger.
func (*DropdownW) ArrowPointAtCenter
func (d *DropdownW) ArrowPointAtCenter(on bool) *DropdownWArrowPointAtCenter draws the arrow (Arrow) at the centre of the trigger instead of near its aligned edge (antd arrow.pointAtCenter).
func (*DropdownW) AutoFocus
func (d *DropdownW) AutoFocus(on bool) *DropdownWAutoFocus moves keyboard focus to the first enabled item whenever the menu opens, also by pointer (antd autoFocus; the keyboard always does).
func (*DropdownW) Body
func (d *DropdownW) Body(trigger func()) *DropdownWBody builds the trigger and, when open, the menu.
func (*DropdownW) Button
func (d *DropdownW) Button(label string) *DropdownWButton builds the split-button form: a main button labelled label joined with a menu button (Ant Dropdown.Button, Element split-button). Check ButtonClicked for the main part and Clicked for the chosen item.
Deprecated: use Compact + Button + Dropdown (antd 6 deprecates Dropdown.Button):
ui.Compact(c).Body(func() {
ui.Button(c, "提交")
ui.Dropdown(c, items).Placement(ui.BottomEnd).Body(func() { ui.Button(c, "").Icon(icon.More) })
})
func (*DropdownW) ButtonClicked
func (d *DropdownW) ButtonClicked() boolButtonClicked reports a click on the main part of the Button form.
func (*DropdownW) Check
func (d *DropdownW) Check(key string, on *bool) *DropdownWCheck makes the item keyed key a checkbox item bound to on (shadcn DropdownMenuCheckboxItem): a check mark shows its state and choosing it toggles *on (Clicked still reports the key). The panel reserves an indicator column for it.
func (*DropdownW) Clicked
func (d *DropdownW) Clicked() stringClicked returns the key chosen this frame ("" if none).
func (*DropdownW) Danger
func (d *DropdownW) Danger() *DropdownWDanger styles the Button form as dangerous.
func (*DropdownW) Disabled
func (d *DropdownW) Disabled(on bool) *DropdownWDisabled prevents opening (and disables the Button form).
func (*DropdownW) HideOnClick
func (d *DropdownW) HideOnClick(on bool) *DropdownWHideOnClick(false) keeps the menu open after an item is chosen (Element hide-on-click; default true).
func (*DropdownW) ID
func (d *DropdownW) ID() IDID returns the trigger box ID.
func (*DropdownW) IsOpen
func (d *DropdownW) IsOpen() boolIsOpen reports whether the menu is shown.
func (*DropdownW) MaxHeight
func (d *DropdownW) MaxHeight(px float32) *DropdownWMaxHeight limits the menu panels' height (default: the window height); longer menus scroll and keyboard moves keep the active item visible.
func (*DropdownW) MenuIcon
func (d *DropdownW) MenuIcon(ic *icon.Icon) *DropdownWMenuIcon replaces the menu button icon of the Button form.
func (*DropdownW) MinWidth
func (d *DropdownW) MinWidth(px float32) *DropdownWMinWidth sets the menu's minimum width.
func (*DropdownW) MouseEnterDelay
func (d *DropdownW) MouseEnterDelay(dur time.Duration) *DropdownWMouseEnterDelay waits d before a hover dropdown opens (antd mouseEnterDelay 0.15 s, Element show-timeout).
func (*DropdownW) MouseLeaveDelay
func (d *DropdownW) MouseLeaveDelay(dur time.Duration) *DropdownWMouseLeaveDelay waits d before a hover dropdown closes once the pointer left the trigger and the menu (antd mouseLeaveDelay 0.1 s, Element hide-timeout).
func (*DropdownW) Open
func (d *DropdownW) Open(open *bool) *DropdownWOpen binds the open state.
func (*DropdownW) OpenAt
func (d *DropdownW) OpenAt(p geom.Point) *DropdownWOpenAt opens the menu at a window point (context menus).
func (*DropdownW) OpenChanged
func (d *DropdownW) OpenChanged() boolOpenChanged reports that the menu opened or closed this frame.
func (*DropdownW) OpenSource
func (d *DropdownW) OpenSource() stringOpenSource reports what opened or closed the menu this frame (when OpenChanged): "menu" when choosing an item closed it, else "trigger" (antd onOpenChange info.source).
func (*DropdownW) Placement
func (d *DropdownW) Placement(p Placement) *DropdownWPlacement positions the menu (BottomStart, Bottom, BottomEnd, TopStart, Top, TopEnd).
func (*DropdownW) PopupRender
func (d *DropdownW) PopupRender(fn func(menu func())) *DropdownWPopupRender builds the panel content around the menu (antd popupRender, v6 name of dropdownRender): call menu() where the items go, add other content before or after it.
func (*DropdownW) Primary
func (d *DropdownW) Primary() *DropdownWPrimary styles the Button form as primary.
func (*DropdownW) Radio
func (d *DropdownW) Radio(value *string, keys ...string) *DropdownWRadio makes the items keyed keys a radio group bound to value (shadcn DropdownMenuRadioGroup): the item whose key equals *value shows a dot and choosing an item stores its key.
func (*DropdownW) Selected
func (d *DropdownW) Selected(key string) *DropdownWSelected highlights an item.
func (*DropdownW) Size
func (d *DropdownW) Size(s ControlSize) *DropdownWSize sets the control size of the Button form.
func (*DropdownW) Trigger
func (d *DropdownW) Trigger(t Trigger) *DropdownWTrigger selects hover (default), click or context-menu activation.
EditableProTableW 实验性
type EditableProTableW[T any] struct {
// contains filtered or unexported fields
}EditableProTableW is a table over app-owned rows edited in place (Ant Design Pro EditableProTable): columns with an Editor show the ProField control of their value type while a row is edited; an action column offers edit / save / cancel / delete; "add a row" creates a draft row that joins the data when saved. Rows are validated (Required, Rules, Validate, AsyncValidate of every editor) before they are written back.
ui.EditableProTable(c, cols, &rows).RowKey(func(r Row) string { return r.ID }).
NewRow(func() Row { return Row{ID: newID()} }).
OnSave(func(r Row, i int, done func(error)) { go save(r, done) }).
Show()
func EditableProTable 实验性
func EditableProTable[T any](c *Context, cols []ProColumn[T], rows *[]T) *EditableProTableW[T]EditableProTable starts an editable table over *rows; chain options, then Show.
func (*EditableProTableW[T]) AddAtTop 实验性
func (e *EditableProTableW[T]) AddAtTop() *EditableProTableW[T]AddAtTop puts new rows (and the add button) above the data.
func (*EditableProTableW[T]) AddRow 实验性
func (e *EditableProTableW[T]) AddRow() stringAddRow adds a new draft row in edit mode (as the add button does) and returns its key ("" when NewRow is not set or another row is being edited in single mode).
func (*EditableProTableW[T]) Bordered 实验性
func (e *EditableProTableW[T]) Bordered() *EditableProTableW[T]Bordered draws cell borders.
func (*EditableProTableW[T]) Cancel 实验性
func (e *EditableProTableW[T]) Cancel(k string)Cancel leaves edit mode of row k without saving (a new row is dropped).
func (*EditableProTableW[T]) Changed 实验性
func (e *EditableProTableW[T]) Changed() boolChanged reports any change of *rows in the last Show.
func (*EditableProTableW[T]) Deleted 实验性
func (e *EditableProTableW[T]) Deleted() boolDeleted reports a deleted row in the last Show.
func (*EditableProTableW[T]) DragSort 实验性
func (e *EditableProTableW[T]) DragSort(fn func(from, to int)) *EditableProTableW[T]DragSort adds a drag handle column that reorders *rows; fn (may be nil) is told the move (indices into *rows) after it happened.
func (*EditableProTableW[T]) Edit 实验性
func (e *EditableProTableW[T]) Edit(k string)Edit puts the row with key k into edit mode (valid after Show).
func (*EditableProTableW[T]) EditableKeys 实验性
func (e *EditableProTableW[T]) EditableKeys(keys *[]string) *EditableProTableW[T]EditableKeys binds the keys of the rows being edited (controlled).
func (*EditableProTableW[T]) Editing 实验性
func (e *EditableProTableW[T]) Editing(k string) boolEditing reports whether the row with key k is in edit mode.
func (*EditableProTableW[T]) Errors 实验性
func (e *EditableProTableW[T]) Errors(k string) map[string]stringErrors returns the validation messages of the row with key k by column key (nil when valid).
func (*EditableProTableW[T]) ID 实验性
func (e *EditableProTableW[T]) ID() IDID returns the widget ID (valid after Show).
func (*EditableProTableW[T]) MaxLength 实验性
func (e *EditableProTableW[T]) MaxLength(n int) *EditableProTableW[T]MaxLength hides the add button once there are n rows.
func (*EditableProTableW[T]) Moved 实验性
func (e *EditableProTableW[T]) Moved() boolMoved reports a drag-sort move in the last Show.
func (*EditableProTableW[T]) Multiple 实验性
func (e *EditableProTableW[T]) Multiple() *EditableProTableW[T]Multiple lets several rows be edited at once (default: one; the other rows' edit actions are disabled meanwhile).
func (*EditableProTableW[T]) NewRow 实验性
func (e *EditableProTableW[T]) NewRow(fn func() T) *EditableProTableW[T]NewRow shows the "add a row" button; fn creates the draft row (set its key there). The new row opens in edit mode and joins *rows when saved.
func (*EditableProTableW[T]) NoDelete 实验性
func (e *EditableProTableW[T]) NoDelete() *EditableProTableW[T]NoDelete hides the delete action.
func (*EditableProTableW[T]) OnDelete 实验性
func (e *EditableProTableW[T]) OnDelete(fn func(row T, index int)) *EditableProTableW[T]OnDelete is called after a confirmed delete instead of removing the row from *rows (the app removes it, e.g. after a server call).
func (*EditableProTableW[T]) OnSave 实验性
func (e *EditableProTableW[T]) OnSave(fn func(row T, index int, done func(error))) *EditableProTableW[T]OnSave receives a validated row (index -1 for a new row) before it is written back; call done from any goroutine. A nil error writes the row into *rows, an error keeps the row in edit mode and shows the message.
func (*EditableProTableW[T]) Pagination 实验性
func (e *EditableProTableW[T]) Pagination(n int) *EditableProTableW[T]Pagination pages the rows locally, n per page.
func (*EditableProTableW[T]) RowEditable 实验性
func (e *EditableProTableW[T]) RowEditable(fn func(row T) bool) *EditableProTableW[T]RowEditable limits which rows can be edited.
func (*EditableProTableW[T]) RowKey 实验性
func (e *EditableProTableW[T]) RowKey(f func(T) string) *EditableProTableW[T]RowKey gives rows stable keys (needed when rows are inserted, deleted or reordered while one is edited; default: the row index).
func (*EditableProTableW[T]) Save 实验性
func (e *EditableProTableW[T]) Save(k string)Save validates the edited row k and writes it back (as its save action does; valid after Show).
func (*EditableProTableW[T]) Saved 实验性
func (e *EditableProTableW[T]) Saved() boolSaved reports a row written back in the last Show.
func (*EditableProTableW[T]) ScrollX 实验性
func (e *EditableProTableW[T]) ScrollX(w float32) *EditableProTableW[T]ScrollX sets the table's scroll width.
func (*EditableProTableW[T]) ScrollY 实验性
func (e *EditableProTableW[T]) ScrollY(maxH float32) *EditableProTableW[T]ScrollY bounds the table body to maxH (TableW.ScrollY): the header stays in place and only the visible rows are built, so many thousand rows stay fast. Rows being edited are always built, even scrolled out of view, so their drafts and focus survive; starting to edit a row (Edit, AddRow), focus moving into an edited row (Tab), typing in one and a failed validation scroll it into view. An edited key not found among the rows is not looked up again every frame: a key that reappears in place (a row re-keyed at the same row count) is picked up once the row count changes or a new rows slice is passed. The toolbar and the add button stay outside the scrolling body. Default 0: unbounded, every row is built.
func (*EditableProTableW[T]) Show 实验性
func (e *EditableProTableW[T]) Show() *EditableProTableW[T]Show builds the table.
func (*EditableProTableW[T]) Size 实验性
func (e *EditableProTableW[T]) Size(s ControlSize) *EditableProTableW[T]Size sets the density.
func (*EditableProTableW[T]) Table 实验性
func (e *EditableProTableW[T]) Table() *TableWTable returns the inner table of the last Show.
func (*EditableProTableW[T]) Title 实验性
func (e *EditableProTableW[T]) Title(s string) *EditableProTableW[T]Title sets the toolbar title.
func (*EditableProTableW[T]) ToolBar 实验性
func (e *EditableProTableW[T]) ToolBar(fn func()) *EditableProTableW[T]ToolBar adds actions at the right of the toolbar.
func (*EditableProTableW[T]) Validating 实验性
func (e *EditableProTableW[T]) Validating(k string) boolValidating reports async validations or a save in flight for row k.
func (*EditableProTableW[T]) Virtual 实验性
func (e *EditableProTableW[T]) Virtual() *EditableProTableW[T]Virtual is TableW.Virtual for the inner table: with ScrollY the body is windowed either way, Virtual states the intent (and takes the theme's Table V2 row height where it has one, as TableW.Virtual). Otherwise rows keep the height of the density (Size).
EditableTableLocale 实验性
type EditableTableLocale struct {
Actions string // title of the action column
DeleteConfirm string // Popconfirm of the delete action
// contains filtered or unexported fields
}EditableTableLocale holds the EditableProTable texts.
EmptyW
type EmptyW struct {
// contains filtered or unexported fields
}EmptyW is an empty state: Ant's default/simple pictures or Element's illustration, custom image, size, description and actions.
func Empty
func Empty(c *Context) *EmptyWEmpty adds the "no data" placeholder. Modifiers apply until the end of the build (or Body); the content is built then.
ui.Empty(c)
ui.Empty(c).Simple().Description("暂无订单")
ui.Empty(c).Body(func() { ui.Button(c, "立即创建").Primary() })
func (*EmptyW) Body
func (e *EmptyW) Body(fn func()) *BoxBody adds actions (buttons) below the description and builds the empty state.
func (*EmptyW) Description
func (e *EmptyW) Description(s string) *EmptyWDescription sets the text ("" hides it).
func (*EmptyW) Image
func (e *EmptyW) Image(fn func()) *EmptyWImage replaces the picture with custom content.
func (*EmptyW) ImageSize
func (e *EmptyW) ImageSize(px float32) *EmptyWImageSize sets the picture height (Ant default 100, simple 40, Element 160).
func (*EmptyW) Layout
func (e *EmptyW) Layout(o ...layout.Option) *EmptyWLayout applies layout options to the empty state.
func (*EmptyW) Simple
func (e *EmptyW) Simple() *EmptyWSimple uses the compact picture and spacing (Ant PRESENTED_IMAGE_SIMPLE; used inside selects, tables and lists in both design systems).
func (*EmptyW) Title
func (e *EmptyW) Title(s string) *EmptyWTitle adds a heading between the picture and the description (shadcn EmptyTitle: text-lg font-medium).
FieldVariant 实验性
type FieldVariant stringFieldVariant is the frame look of an input-like selector (Ant variant): AutoComplete, Mentions, Select, MultiSelect, Cascader and TreeSelect take it. The values are the strings Input.Variant and the date pickers accept, so FieldVariant(s) converts a string default.
const (
// FieldOutlined is the default bordered frame.
FieldOutlined FieldVariant = "outlined"
// FieldFilled is a tinted fill whose border shows on focus.
FieldFilled FieldVariant = "filled"
// FieldBorderless draws no frame (the padding stays).
FieldBorderless FieldVariant = "borderless"
// FieldUnderlined draws only the bottom line.
FieldUnderlined FieldVariant = "underlined"
)实验性
FileDrop 实验性
type FileDrop struct {
Position geom.Point
Paths []string
}FileDrop describes a file drop. Position uses the same UI logical coordinates as Context.Pointer and Context.RectOf.
FlexW
type FlexW struct {
// contains filtered or unexported fields
}FlexW is a flex container with design-token gaps (Ant Flex).
func Flex
func Flex(c *Context) *FlexWFlex starts a horizontal flex box; chain options, then Body.
func (*FlexW) Align
func (f *FlexW) Align(a layout.Align) *FlexWAlign positions children on the cross axis.
func (*FlexW) Body
func (f *FlexW) Body(fn func()) *BoxBody adds the children.
func (*FlexW) Gap
func (f *FlexW) Gap(s ControlSize) *FlexWGap sets the gap with a size token (Small 8, Middle 16, Large 24).
func (*FlexW) GapPx
func (f *FlexW) GapPx(px float32) *FlexWGapPx sets the gap in pixels.
func (*FlexW) Justify
func (f *FlexW) Justify(j layout.Justify) *FlexWJustify distributes free space on the main axis.
func (*FlexW) Orientation
func (f *FlexW) Orientation(o string) *FlexWOrientation sets the direction: "horizontal" (default) or "vertical" (Ant v6 orientation). Other values are ignored.
func (*FlexW) Style
func (f *FlexW) Style(opts ...layout.Option) *FlexWStyle applies extra layout options.
func (*FlexW) Vertical
func (f *FlexW) Vertical() *FlexWVertical lays children top to bottom.
func (*FlexW) Wrap
func (f *FlexW) Wrap() *FlexWWrap wraps children onto new lines.
FloatButtonGroupW 实验性
type FloatButtonGroupW struct {
// contains filtered or unexported fields
}FloatButtonGroupW stacks float buttons; with a trigger it collapses them behind a menu button.
func FloatButtonGroup 实验性
func FloatButtonGroup(c *Context) *FloatButtonGroupWFloatButtonGroup starts a group; chain options, then Body with FloatButton calls.
func (*FloatButtonGroupW) Body 实验性
func (g *FloatButtonGroupW) Body(fn func()) *FloatButtonGroupWBody builds the members.
func (*FloatButtonGroupW) Icon 实验性
func (g *FloatButtonGroupW) Icon(ic *icon.Icon) *FloatButtonGroupWIcon sets the menu button icon (default: a plus that turns into a cross).
func (*FloatButtonGroupW) IsOpen 实验性
func (g *FloatButtonGroupW) IsOpen() boolIsOpen reports whether the members are shown.
func (*FloatButtonGroupW) Open 实验性
func (g *FloatButtonGroupW) Open(open *bool) *FloatButtonGroupWOpen binds the open state of a triggered group.
func (*FloatButtonGroupW) Position 实验性
func (g *FloatButtonGroupW) Position(right, bottom float32) *FloatButtonGroupWPosition sets the distance from the right and bottom window edges.
func (*FloatButtonGroupW) Primary 实验性
func (g *FloatButtonGroupW) Primary() *FloatButtonGroupWPrimary colors the menu button.
func (*FloatButtonGroupW) Square 实验性
func (g *FloatButtonGroupW) Square() *FloatButtonGroupWSquare joins the buttons in one rounded card with separators.
func (*FloatButtonGroupW) Trigger 实验性
func (g *FloatButtonGroupW) Trigger(t string) *FloatButtonGroupWTrigger collapses the group behind a menu button opened by "click" or "hover".
FloatButtonW 实验性
type FloatButtonW struct {
// contains filtered or unexported fields
}FloatButtonW is a button floating above the page at a window corner.
func FloatButton 实验性
func FloatButton(c *Context) *FloatButtonWFloatButton adds a floating action button (default bottom-right, 24px from the right and 48px from the bottom). Inside a FloatButtonGroup it becomes a member of the group.
func (*FloatButtonW) A11yLabel 实验性
func (f *FloatButtonW) A11yLabel(s string) *FloatButtonWA11yLabel sets the accessible name of an icon-only button without a tooltip.
func (*FloatButtonW) Badge 实验性
func (f *FloatButtonW) Badge(n int) *FloatButtonWBadge shows a count (dot when n < 0).
func (*FloatButtonW) Bottom 实验性
func (f *FloatButtonW) Bottom(px float32) *FloatButtonWBottom sets the distance from the bottom window edge.
func (*FloatButtonW) Clicked 实验性
func (f *FloatButtonW) Clicked() boolClicked reports activation.
func (*FloatButtonW) Description 实验性
func (f *FloatButtonW) Description(s string) *FloatButtonWDescription shows a short caption below the icon (square shape).
func (*FloatButtonW) ID 实验性
func (f *FloatButtonW) ID() IDID returns the widget ID.
func (*FloatButtonW) Icon 实验性
func (f *FloatButtonW) Icon(ic *icon.Icon) *FloatButtonWIcon sets the icon.
func (*FloatButtonW) Primary 实验性
func (f *FloatButtonW) Primary() *FloatButtonWPrimary uses the brand color.
func (*FloatButtonW) Right 实验性
func (f *FloatButtonW) Right(px float32) *FloatButtonWRight sets the distance from the right window edge (the end edge: the left one in a right-to-left scope).
func (*FloatButtonW) Square 实验性
func (f *FloatButtonW) Square() *FloatButtonWSquare uses a rounded square instead of a circle.
func (*FloatButtonW) Tooltip 实验性
func (f *FloatButtonW) Tooltip(s string) *FloatButtonWTooltip shows a tip on hover, towards the page (left; right in RTL).
FooterLink 实验性
type FooterLink struct {
Key string
Title string
Icon *icon.Icon // shown alone when Title is ""
OnClick func()
// contains filtered or unexported fields
}FooterLink is one link of DefaultFooter.
FooterToolbarW 实验性
type FooterToolbarW struct {
// contains filtered or unexported fields
}FooterToolbarW builds a FooterToolbar.
func FooterToolbar 实验性
func FooterToolbar(c *Context) *FooterToolbarWFooterToolbar starts a bottom action bar; chain options, then Body with the right-hand buttons.
ConfigProvider.Defaults("FooterToolbar", ...) keys: "fixed" (bool, default true), "sticky" (legacy bool).
func (*FooterToolbarW) Body 实验性
func (f *FooterToolbarW) Body(fn func()) *FooterToolbarWBody builds the bar with fn as the right-hand actions.
func (*FooterToolbarW) Extra 实验性
func (f *FooterToolbarW) Extra(fn func()) *FooterToolbarWExtra builds content at the left of the bar.
func (*FooterToolbarW) Fixed 实验性
func (f *FooterToolbarW) Fixed(on bool) *FooterToolbarWFixed controls whether the bar is pinned to the bottom (default true). Fixed(false) places it in normal flow. Sticky remains an alias for enabling it.
func (*FooterToolbarW) ID 实验性
func (f *FooterToolbarW) ID() IDID returns the bar's widget ID (after Body).
func (*FooterToolbarW) Layout 实验性
func (f *FooterToolbarW) Layout(o ...layout.Option) *FooterToolbarWLayout applies layout options to the bar.
func (*FooterToolbarW) Sticky 实验性
func (f *FooterToolbarW) Sticky() *FooterToolbarWSticky pins the bar to the bottom of the viewport while the content above scrolls (Affix with offset bottom 0).
func (*FooterToolbarW) Target 实验性
func (f *FooterToolbarW) Target(id ID) *FooterToolbarWTarget makes Sticky pin to the bottom of a scroll box (ScrollBox.ID()) instead of the window.
FormItemW
type FormItemW struct {
// contains filtered or unexported fields
}FormItemW is one labelled form row.
func RulesOf 实验性
func RulesOf[T any](it *FormItemW, val *T, rules ...RuleOf[T]) *FormItemWRulesOf attaches typed rules to *val (numbers, booleans, slices …) and binds the value for ResetFields; it is Rules for any type. The item's Value (FormW.Value, Dependencies) is the value formatted with fmt.
ui.RulesOf(form.Item("年龄"), &age, ui.RangeValue(18.0, 60.0, "18–60"))
func (*FormItemW) Body
func (it *FormItemW) Body(fn func())Body builds the control(s) of the item.
func (*FormItemW) Dependencies
func (it *FormItemW) Dependencies(names ...string) *FormItemWDependencies names fields this item depends on: when one of their values changes the item re-validates (if it has a value or was validated) and OnDepsChange runs (reset a dependent value, refresh options).
func (*FormItemW) Disabled
func (it *FormItemW) Disabled(on bool) *FormItemWDisabled disables every control of the item.
func (*FormItemW) Error
func (it *FormItemW) Error(msg string) *FormItemWfunc (*FormItemW) Extra
func (it *FormItemW) Extra(s string) *FormItemWExtra shows a description line under the control and its message (Ant Form.Item extra).
func (*FormItemW) ExtraBody
func (it *FormItemW) ExtraBody(fn func()) *FormItemWExtraBody builds custom content under the control (Extra as content).
func (*FormItemW) Help
func (it *FormItemW) Help(msg string) *FormItemWfunc (*FormItemW) Hidden
func (it *FormItemW) Hidden(on bool) *FormItemWHidden skips the item: nothing is built and it is not validated.
func (*FormItemW) Name
func (it *FormItemW) Name(name string) *FormItemWName sets the field name that keys the item's validation state (default: the label). Items with the same label (Form.List rows) need distinct names.
func (*FormItemW) NoLabel
func (it *FormItemW) NoLabel() *FormItemWNoLabel aligns the control with labelled items but shows no label (submit row).
func (*FormItemW) OnDepsChange
func (it *FormItemW) OnDepsChange(fn func()) *FormItemWOnDepsChange runs fn when a dependency's value changed.
func (*FormItemW) OnReset
func (it *FormItemW) OnReset(fn func()) *FormItemWOnReset makes ResetFields call fn for this item: items bound with RulesFunc have no pointer the form could restore, so the application resets its own value (Rules and RulesOf restore automatically).
f.Item("生日").RulesFunc(func() string { return d.Format(ui.DateLayout) }, ...).OnReset(func() { d = time.Time{} })
func (*FormItemW) Required
func (it *FormItemW) Required() *FormItemWfunc (*FormItemW) Rules
func (it *FormItemW) Rules(val *string, rules ...Rule) *FormItemWRules attaches validation rules to a string value. The item validates live once the value changed (see ValidateTrigger), and on FormW.Validate. The value is restored by FormW.ResetFields.
func (*FormItemW) RulesFunc
func (it *FormItemW) RulesFunc(val func() string, rules ...Rule) *FormItemWRulesFunc is Rules for values that are not strings (format them).
func (*FormItemW) Tooltip
func (it *FormItemW) Tooltip(tip string) *FormItemWTooltip shows a question-mark icon after the label with a tooltip (Ant Form.Item tooltip).
func (*FormItemW) ValidateStatus
func (it *FormItemW) ValidateStatus(s string) *FormItemWValidateStatus sets the status by hand: "success" | "warning" | "error" | "validating" (Ant validateStatus). The Help text takes the status color; a failing rule still shows its error.
func (*FormItemW) ValidateTrigger
func (it *FormItemW) ValidateTrigger(t FormTrigger) *FormItemWValidateTrigger sets when this item validates (see FormTrigger).
FormLayout 实验性
type FormLayout uint8FormLayout arranges labels and controls.
Append-only: never reorder or insert; the zero value stays FormHorizontal.
const (
FormHorizontal FormLayout = iota // label left of the control
FormVertical // label above
FormInline // items in a wrapping row
)实验性
FormListRow 实验性
type FormListRow[T any] struct {
Index int
Value *T // the row's element (valid during the callback)
Key string // stable key of the row
// contains filtered or unexported fields
}FormListRow is one row passed to FormListW.Body.
func (*FormListRow[T]) MoveDown 实验性
func (r *FormListRow[T]) MoveDown()MoveDown swaps the row with the one below.
func (*FormListRow[T]) MoveUp 实验性
func (r *FormListRow[T]) MoveUp()MoveUp swaps the row with the one above.
func (*FormListRow[T]) Name 实验性
func (r *FormListRow[T]) Name(field string) stringName returns a field name unique to this row ("label.key.field").
func (*FormListRow[T]) Remove 实验性
func (r *FormListRow[T]) Remove()Remove deletes the row (after the rows are built).
FormListW 实验性
type FormListW[T any] struct {
// contains filtered or unexported fields
}FormListW is a dynamic list of form rows bound to a slice (Ant Design Form.List / ProFormList): rows can be added, removed and moved; every row's items validate on their own (give them row.Name(field)).
ui.FormList(f, "联系人", &contacts).Min(1).Max(5).
Creator(func() Contact { return Contact{} }).
Body(func(row *ui.FormListRow[Contact]) {
f.Item("姓名").Name(row.Name("name")).Rules(&row.Value.Name, ui.Required("请输入姓名")).
Body(func() { ui.Input(c, &row.Value.Name) })
})
func FormList 实验性
func FormList[T any](f *FormW, label string, items *[]T) *FormListW[T]FormList starts a dynamic list inside form f; finish with Body.
func (*FormListW[T]) AddText 实验性
func (l *FormListW[T]) AddText(s string) *FormListW[T]AddText sets the add button's text.
func (*FormListW[T]) Body 实验性
func (l *FormListW[T]) Body(fn func(row *FormListRow[T])) *FormListW[T]Body builds the rows with fn (items inside a row are laid out inline), the row actions and the add button.
func (*FormListW[T]) Changed 实验性
func (l *FormListW[T]) Changed() boolChanged reports a row added, removed or moved in the last Body.
func (*FormListW[T]) Creator 实验性
func (l *FormListW[T]) Creator(fn func() T) *FormListW[T]Creator returns the element added by the add button (default: zero value).
func (*FormListW[T]) Max 实验性
func (l *FormListW[T]) Max(n int) *FormListW[T]Max allows at most n rows (add is disabled at n).
func (*FormListW[T]) Min 实验性
func (l *FormListW[T]) Min(n int) *FormListW[T]Min keeps at least n rows (remove is disabled at n).
func (*FormListW[T]) NoActions 实验性
func (l *FormListW[T]) NoActions() *FormListW[T]NoActions hides the per-row move / remove buttons (use row.Remove etc.).
func (*FormListW[T]) Rule 实验性
func (l *FormListW[T]) Rule(fn func(n int) string) *FormListW[T]Rule validates the list itself (e.g. at least one row): fn gets the row count and returns an error message or "".
FormLocale
type FormLocale struct {
Validating string // help text while an async rule runs
RequiredInputFmt, RequiredSelectFmt string // default required message, arg: field label
Submit, Query, PrevStep, NextStep string
MoveUp, MoveDown, AddRow string // FormList actions
Optional string // label suffix of optional items (Form.RequiredMarkOptional)
// contains filtered or unexported fields
}FormLocale holds the Form / ProForm texts.
FormTrigger
type FormTrigger uint8FormTrigger says when a form item validates its value.
Append-only: never reorder or insert; the zero value stays ValidateInherit.
const (
// ValidateInherit uses the form's trigger (items) or onChange (forms).
ValidateInherit FormTrigger = iota
// ValidateOnChange validates live once the value changed (default).
ValidateOnChange
// ValidateOnBlur validates when focus leaves the item's control.
ValidateOnBlur
// ValidateOnSubmit validates only in Validate / Submit.
ValidateOnSubmit
)FormW
type FormW struct {
// contains filtered or unexported fields
}FormW groups FormItems with shared label settings.
func Form
func Form(c *Context) *FormWForm adds a form container; build items with Item(...).Body.
func (*FormW) Body
func (f *FormW) Body(fn func()) *FormWBody builds the form's items.
func (*FormW) ClearValidate
func (f *FormW) ClearValidate(names ...string)ClearValidate removes the validation result of the named items (all items without names) without touching their values (Ant setFields / Element clearValidate). They validate again live after the next edit, or on Validate.
func (*FormW) Colon
func (f *FormW) Colon(on bool) *FormWfunc (*FormW) Disabled
func (f *FormW) Disabled(on bool) *FormWDisabled disables every control in the form (Ant Form disabled, Element el-form disabled); it passes down like ui.Disabled.
func (*FormW) Errors
func (f *FormW) Errors() map[string]stringErrors returns the current error message per item label.
func (*FormW) Finished
func (f *FormW) Finished() boolFinished reports (once) that a Submit passed validation.
func (*FormW) Inline
func (f *FormW) Inline() *FormWfunc (*FormW) Item
func (f *FormW) Item(label string) *FormItemWItem starts a form item; finish with Body.
func (*FormW) LabelAlign
func (f *FormW) LabelAlign(a TextAlign) *FormWfunc (*FormW) LabelWidth
func (f *FormW) LabelWidth(px float32) *FormWfunc (*FormW) Layout
func (f *FormW) Layout(o ...layout.Option) *FormWfunc (*FormW) RequiredMark
func (f *FormW) RequiredMark(on bool) *FormWRequiredMark shows (default) or hides the asterisk of required items (Ant requiredMark, Element hide-required-asterisk). Required rules still apply.
func (*FormW) RequiredMarkOptional
func (f *FormW) RequiredMarkOptional() *FormWRequiredMarkOptional marks the optional items instead of the required ones (antd requiredMark="optional"): no asterisk, and the labels of items that are not Required end with Locale().Form.Optional in the secondary text color. ConfigProvider Defaults("Form", {"requiredMark": "optional"}) sets it too.
func (*FormW) ResetFields
func (f *FormW) ResetFields(names ...string)ResetFields restores every item bound with Rules(*string) or RulesOf to the value it had when the item was first built, calls the OnReset callback of RulesFunc items, and clears validation (Ant resetFields, Element resetFields). With names only those items are reset.
func (*FormW) ResetValidation
func (f *FormW) ResetValidation()ResetValidation clears errors and touched flags. Values changed from code in the same frame (a submit handler clearing the fields) are not edits: they are not validated on the next build, as antd does not validate setFieldsValue.
func (*FormW) ScrollToFirstError
func (f *FormW) ScrollToFirstError() *FormWScrollToFirstError scrolls the first failing item into view (in its nearest scroll container) when Validate or Submit fails.
func (*FormW) Size
func (f *FormW) Size(s ControlSize) *FormWSize sets the size of every control in the form (Ant Form size, Element el-form size); a control's own Size still wins.
func (*FormW) Submit
func (f *FormW) Submit()Submit validates every item (waiting for asynchronous rules) and makes Finished report true once all pass. It scrolls to the first error when validation fails (ScrollToFirstError).
func (*FormW) Submitting
func (f *FormW) Submitting() boolSubmitting reports a Submit waiting for asynchronous validation.
func (*FormW) Validate
func (f *FormW) Validate() boolValidate checks every item with rules built so far in this frame, shows their errors and reports whether all passed. Items whose asynchronous rules are still running count as not passed (see Validating, Submit).
func (*FormW) ValidateFields
func (f *FormW) ValidateFields(names ...string) boolValidateFields validates only the named items (Name, or the label) and reports whether they all passed (Ant validateFields(names), Element validateField). Without names it is Validate.
func (*FormW) ValidateTrigger
func (f *FormW) ValidateTrigger(t FormTrigger) *FormWValidateTrigger sets when items validate (default ValidateOnChange); FormItemW.ValidateTrigger overrides it per item.
func (*FormW) Validating
func (f *FormW) Validating() boolValidating reports an asynchronous rule still running.
func (*FormW) Value
func (f *FormW) Value(name string) stringValue returns the last value seen of the item named name (Name or label); use it for linkage: f.Item("城市").Hidden(f.Value("国家") == "").
func (*FormW) Vertical
func (f *FormW) Vertical() *FormWGraphLocale 实验性
type GraphLocale struct {
Diagram, ER, GitGraph string // accessible names of the canvases / list
ZoomIn, ZoomOut, FitView, AutoLayout, MiniMap string // toolbar buttons and the minimap
PrimaryKey, ForeignKey string // ER column marks
SummaryFmt string // diagram description, args: node count, edge count ("%[1]d 个节点,%[2]d 条连线")
CommitsFmt string // commit list description, arg: commit count ("%d 个提交")
// contains filtered or unexported fields
}GraphLocale holds the texts of ui/graph widgets (Diagram, ER, GitGraph).
GridColW
type GridColW struct {
// contains filtered or unexported fields
}GridColW is a column of a GridRow.
func Col
func Col(c *Context, span int) *GridColWCol adds a column spanning span/24 of the row; call it inside GridRow.Body.
func (*GridColW) Body
func (col *GridColW) Body(fn func()) *GridColWBody sets the column content (built when the row lays out its lines).
func (*GridColW) Flex
func (col *GridColW) Flex(n float32) *GridColWFlex makes the column take free space (flex: n) instead of a span.
func (*GridColW) LG
func (col *GridColW) LG(span int, offset ...int) *GridColWfunc (*GridColW) MD
func (col *GridColW) MD(span int, offset ...int) *GridColWfunc (*GridColW) Offset
func (col *GridColW) Offset(n int) *GridColWOffset shifts the column towards the end (right; left in RTL) by n columns.
func (*GridColW) Order
func (col *GridColW) Order(n int) *GridColWOrder sets the flex order of the column within the row (lower first; equal orders keep the call order).
func (*GridColW) Pull
func (col *GridColW) Pull(n int) *GridColWPull moves the column towards the start by n columns (Ant pull).
func (*GridColW) Push
func (col *GridColW) Push(n int) *GridColWPush moves the column towards the end by n columns without moving its neighbours (Ant push; for reordering columns visually).
func (*GridColW) SM
func (col *GridColW) SM(span int, offset ...int) *GridColWfunc (*GridColW) Style
func (col *GridColW) Style(opts ...layout.Option) *GridColWStyle applies layout options to the column content box.
func (*GridColW) XL
func (col *GridColW) XL(span int, offset ...int) *GridColWfunc (*GridColW) XS
func (col *GridColW) XS(span int, offset ...int) *GridColWXS..XXL set the span (and optional offset) from that breakpoint up.
func (*GridColW) XXL
func (col *GridColW) XXL(span int, offset ...int) *GridColWGridContentW 实验性
type GridContentW struct {
// contains filtered or unexported fields
}GridContentW builds a GridContent.
func GridContent 实验性
func GridContent(c *Context) *GridContentWGridContent starts a content container; chain options, then Body.
ConfigProvider.Defaults("GridContent", ...) keys: "contentWidth" ("Fluid" | "Fixed"). Without either, the enclosing ProLayout's content width is used.
func (*GridContentW) Body 实验性
func (g *GridContentW) Body(fn func()) *BoxBody builds fn inside the container and returns the inner column.
func (*GridContentW) ContentWidth 实验性
func (g *GridContentW) ContentWidth(w string) *GridContentWContentWidth sets "Fluid" (fill) or "Fixed" (centred, MaxWidth).
func (*GridContentW) Fixed 实验性
func (g *GridContentW) Fixed() boolFixed reports whether the container centres its content.
func (*GridContentW) Layout 实验性
func (g *GridContentW) Layout(o ...layout.Option) *GridContentWLayout applies layout options to the inner column.
func (*GridContentW) MaxWidth 实验性
func (g *GridContentW) MaxWidth(px float32) *GridContentWMaxWidth sets the width of a Fixed container (default 1152).
GridRowW
type GridRowW struct {
// contains filtered or unexported fields
}GridRowW is a 24-column grid row (Ant Row / Element el-row).
func GridRow
func GridRow(c *Context) *GridRowWGridRow starts a grid row; chain options, then Body with Col calls.
func (*GridRowW) Align
func (g *GridRowW) Align(a layout.Align) *GridRowWAlign sets vertical alignment of columns (AlignStart, AlignCenter, AlignEnd).
func (*GridRowW) Body
func (g *GridRowW) Body(fn func()) *BoxBody builds the row.
func (*GridRowW) Gutter
func (g *GridRowW) Gutter(h, v float32) *GridRowWGutter sets the horizontal and vertical spacing between columns.
func (*GridRowW) GutterAt
func (g *GridRowW) GutterAt(bp Breakpoint, px float32) *GridRowWGutterAt sets a responsive horizontal gutter per breakpoint.
func (*GridRowW) Justify
func (g *GridRowW) Justify(j layout.Justify) *GridRowWJustify distributes free columns: JustifyStart, JustifyEnd, JustifyCenter, JustifySpaceBetween, JustifySpaceAround, JustifySpaceEvenly.
func (*GridRowW) NoWrap
func (g *GridRowW) NoWrap() *GridRowWNoWrap keeps all columns on one line.
func (*GridRowW) VGutterAt
func (g *GridRowW) VGutterAt(bp Breakpoint, px float32) *GridRowWVGutterAt sets a responsive vertical gutter (the gap between wrapped lines) per breakpoint (Ant gutter={[h, {xs: 8, md: 16}]}).
Host 实验性
type Host interface {
OpenWindow(opts WindowOptions, r *Runner) (Window, error)
}Host is implemented by a platform backend that can open windows whose content is drawn by the Tango UI. The host owns the event loop and must:
- forward input as input.Event values to Runner.HandleEvent (logical coordinates relative to the content area; positive Scroll.DY reveals content below; Pointer.Clicks if the OS tracks double clicks);
- call Runner.Frame on the UI thread after Window.Invalidate / InvalidateAt, after a resize or scale change, and when the window is first shown;
- map input.Cursor to native cursors in Window.SetCursor;
- route IME through Window.SetTextInput (NSTextInputClient, IMM32/TSF, GTK IM context) and deliver input.Composition + input.TextInput;
- display the image passed to Window.Present (e.g. CGImage into a CALayer, StretchDIBits / D2D bitmap, cairo surface);
- call Runner.Close when the window is destroyed.
HotkeyInputLocale 实验性
type HotkeyInputLocale struct {
Placeholder string // empty, not recording ("点击录制快捷键")
Recording string // waiting for a key ("请按下组合键,Esc 取消")
ClearLabel string // clear button ("清除快捷键")
// contains filtered or unexported fields
}HotkeyInputLocale holds the HotkeyInput texts.
HotkeyInputW 实验性
type HotkeyInputW struct {
// contains filtered or unexported fields
}HotkeyInputW is the shortcut recorder HotkeyInput returns.
func HotkeyInput 实验性
func HotkeyInput(c *Context, accel *string) *HotkeyInputWHotkeyInput adds a shortcut recorder bound to *accel, an accelerator in the syntax of package sys/hotkey and uihost shortcuts ("CmdOrCtrl+Shift+K", "Alt+F4", "F5"):
ui.HotkeyInput(c, &keys.Palette).Conflict(func(a string) string {
if owner := bindings.Owner(a); owner != "" { return "已被“" + owner + "”使用" }
return ""
})
Focusing it (a click, or Tab and then Enter / Space) starts recording: the held modifiers show as key caps until a main key completes the combination, which becomes the value. The platform shortcut modifier is stored as CmdOrCtrl (Literal stores Cmd / Ctrl as pressed). A main key needs a modifier other than Shift, except F1–F12 (AllowBare lifts that). Bare Backspace / Delete clear the value, as the clear button does.
Esc while recording cancels it and keeps the old value; the Esc is not passed on, so an enclosing Modal or Drawer stays open, and a second Esc (not recording) reaches it. (Popovers and dropdowns check Esc before building their content, so inside one Esc closes the panel.) Tab is not recorded: it moves focus as everywhere else.
Hosts implementing ShortcutCaptureWindow (including uihost) yield window shortcuts and menu accelerators while recording, without enabling IME. Capture ends on completion, cancel, blur, disable or removal. System shortcuts and global OS hotkeys cannot be overridden by this widget.
func (*HotkeyInputW) A11yLabel 实验性
func (w *HotkeyInputW) A11yLabel(s string) *HotkeyInputWA11yLabel sets the accessible name (a FormItem label names it too).
func (*HotkeyInputW) AllowBare 实验性
func (w *HotkeyInputW) AllowBare(on bool) *HotkeyInputWAllowBare accepts main keys without a modifier (letters, digits, Enter).
func (*HotkeyInputW) Changed 实验性
func (w *HotkeyInputW) Changed() boolChanged reports that the value was recorded or cleared this frame.
func (*HotkeyInputW) Conflict 实验性
func (w *HotkeyInputW) Conflict(fn func(accel string) string) *HotkeyInputWConflict checks the value: fn returns a message when the shortcut is taken or reserved ("" when it is free). The message shows under the field, which turns to the warning status; the value is kept, the app decides whether to save it.
func (*HotkeyInputW) ConflictText 实验性
func (w *HotkeyInputW) ConflictText() stringConflictText returns the message of the Conflict check ("" for none).
func (*HotkeyInputW) Disabled 实验性
func (w *HotkeyInputW) Disabled(on bool) *HotkeyInputWDisabled stops recording and clearing.
func (*HotkeyInputW) ID 实验性
func (w *HotkeyInputW) ID() IDID returns the field's ID (the focusable frame).
func (*HotkeyInputW) Literal 实验性
func (w *HotkeyInputW) Literal() *HotkeyInputWLiteral stores Cmd (macOS) and Ctrl as pressed instead of CmdOrCtrl.
func (*HotkeyInputW) Placeholder 实验性
func (w *HotkeyInputW) Placeholder(s string) *HotkeyInputWPlaceholder replaces the empty-field text (Locale.HotkeyInput.Placeholder).
func (*HotkeyInputW) Recording 实验性
func (w *HotkeyInputW) Recording() boolRecording reports whether the field is waiting for a key.
func (*HotkeyInputW) Size 实验性
func (w *HotkeyInputW) Size(s ControlSize) *HotkeyInputWSize sets the control size.
func (*HotkeyInputW) Status 实验性
func (w *HotkeyInputW) Status(s string) *HotkeyInputWStatus sets the validation status: "error" or "warning" (a conflict shows as "warning" unless a status is set).
func (*HotkeyInputW) Width 实验性
func (w *HotkeyInputW) Width(px float32) *HotkeyInputWWidth sets the field width (the token's MinWidth by default).
ID
type ID uint64ID identifies a widget across frames. IDs derive from the parent scope, the widget kind, its label and its occurrence count; wrap dynamic lists in Key to make identity independent of position.
IconButtonW
type IconButtonW struct {
// contains filtered or unexported fields
}IconButtonW is a borderless square icon button (close buttons, toolbar toggles, calendar navigation).
func IconButton
func IconButton(c *Context, ic *icon.Icon, label string) *IconButtonWIconButton adds an icon button; label is used for tests and accessibility.
func (*IconButtonW) A11yLabel
func (b *IconButtonW) A11yLabel(s string) *IconButtonWA11yLabel replaces the accessible name (by default the label argument).
func (*IconButtonW) Clicked
func (b *IconButtonW) Clicked() boolClicked reports activation.
func (*IconButtonW) Color
func (b *IconButtonW) Color(col theme.Color) *IconButtonWColor fixes the icon color.
func (*IconButtonW) Hovered
func (b *IconButtonW) Hovered() boolHovered reports hover.
func (*IconButtonW) NoHoverBg
func (b *IconButtonW) NoHoverBg() *IconButtonWNoHoverBg disables the hover background.
func (*IconButtonW) Size
func (b *IconButtonW) Size(box, iconSize float32) *IconButtonWSize sets the square box size and the icon size.
IconViolation 实验性
type IconViolation struct {
Icon string // icon name
Label string // label of the deepest labelled node containing the icon
Under string // label of the nearest labelled ancestor of that node
Rect geom.Rect // where the icon was drawn
}IconViolation is a directional icon (icon.Icon.IsDirectional) drawn without mirroring while its node was painted in a right-to-left scope: the widget used icon.Draw instead of the direction-aware paint helper.
func (IconViolation) String 实验性
func (v IconViolation) String() stringIconW
type IconW struct {
// contains filtered or unexported fields
}IconW is an icon leaf.
func Icon
func Icon(c *Context, ic *icon.Icon) *IconWIcon adds a vector icon (default 14px, current text color).
func (*IconW) A11yLabel
func (w *IconW) A11yLabel(s string) *IconWA11yLabel exposes a meaningful icon (a status, not decoration) as an image with this accessible name. Icons are decorative by default.
func (*IconW) Color
func (w *IconW) Color(col theme.Color) *IconWColor sets the icon color.
func (*IconW) Rotate
func (w *IconW) Rotate(deg float64) *IconWRotate rotates the icon by degrees.
func (*IconW) Size
func (w *IconW) Size(px float32) *IconWSize sets the icon size in px.
func (*IconW) Spin
func (w *IconW) Spin() *IconWSpin rotates the icon continuously (loading).
ImageLocale 实验性
type ImageLocale struct {
Preview, PreviewLabel, ClosePreview, Prev, Next string
ZoomIn, ZoomOut, RotateLeft, RotateRight, FlipHorizontal, FlipVertical string
// contains filtered or unexported fields
}ImageLocale holds the Image placeholder and preview toolbar texts.
ImageW 实验性
type ImageW struct {
// contains filtered or unexported fields
}ImageW displays a bitmap with loading placeholder, error fallback and an optional full-screen preview (Ant Design Image / Element Plus el-image).
func Image 实验性
func Image(c *Context, img image.Image) *ImageWImage adds an image; img may be nil (shows the placeholder). The default size is the image's pixel size (200×200 when unknown); use Width/Height.
func (*ImageW) A11yLabel 实验性
func (w *ImageW) A11yLabel(s string) *ImageWA11yLabel sets the accessible name (like Alt, without changing the Driver.Find label).
func (*ImageW) Alt 实验性
func (w *ImageW) Alt(s string) *ImageWAlt sets the accessible label (also used by Driver.Find).
func (*ImageW) CloseOnEscape 实验性
func (w *ImageW) CloseOnEscape(on bool) *ImageWCloseOnEscape(false) keeps the preview open on Escape (Element close-on-press-escape, default true).
func (*ImageW) Failed 实验性
func (w *ImageW) Failed(on bool) *ImageWFailed shows the error fallback (broken picture / "加载失败").
func (*ImageW) Fallback 实验性
func (w *ImageW) Fallback(img image.Image) *ImageWFallback sets the image shown when loading failed (Ant `fallback`).
func (*ImageW) Fit 实验性
func (w *ImageW) Fit(f string) *ImageWFit sets object-fit: "fill" (default), "contain", "cover", "scale-down".
func (*ImageW) Height 实验性
func (w *ImageW) Height(px float32) *ImageWfunc (*ImageW) ID 实验性
func (w *ImageW) ID() IDID returns the widget ID.
func (*ImageW) Infinite 实验性
func (w *ImageW) Infinite(on bool) *ImageWInfinite sets whether the group preview wraps from the last image to the first (Element infinite, default true; Ant stops at the ends).
func (*ImageW) Layout 实验性
func (w *ImageW) Layout(o ...layout.Option) *ImageWLayout applies layout options.
func (*ImageW) Loading 实验性
func (w *ImageW) Loading(on bool) *ImageWLoading shows the placeholder instead of the image.
func (*ImageW) MaskClosable 实验性
func (w *ImageW) MaskClosable(on bool) *ImageWMaskClosable sets whether a click on the preview backdrop closes it (Ant mask.closable, default true; Element hide-on-click-modal, default false; the theme picks the default).
func (*ImageW) MaxScale 实验性
func (w *ImageW) MaxScale(k float32) *ImageWfunc (*ImageW) MinScale 实验性
func (w *ImageW) MinScale(k float32) *ImageWMinScale and MaxScale bound the preview zoom (Ant minScale 1 / maxScale 50; Element min-scale 0.2 / max-scale 7; the theme picks the default).
func (*ImageW) Movable 实验性
func (w *ImageW) Movable(on bool) *ImageWMovable(false) stops dragging the preview image around (Ant preview.movable, default true).
func (*ImageW) OpenPreview 实验性
func (w *ImageW) OpenPreview() *ImageWOpenPreview opens the preview now (Ant preview.open); call it once per action, like Rotate. PreviewOpen reports the state.
func (*ImageW) Preview 实验性
func (w *ImageW) Preview(on bool) *ImageWPreview enables click-to-preview.
func (*ImageW) PreviewAngle 实验性
func (w *ImageW) PreviewAngle() float64PreviewAngle returns the preview rotation in degrees (clockwise).
func (*ImageW) PreviewGroup 实验性
func (w *ImageW) PreviewGroup(imgs []image.Image, index int) *ImageWPreviewGroup previews imgs (this image is imgs[index]) with prev/next navigation and a counter. An index out of range is clamped.
func (*ImageW) PreviewOpen 实验性
func (w *ImageW) PreviewOpen() boolPreviewOpen reports whether the preview overlay is open.
func (*ImageW) PreviewScale 实验性
func (w *ImageW) PreviewScale() float32PreviewScale returns the preview zoom factor (1 = fitted size).
func (*ImageW) PreviewSrc 实验性
func (w *ImageW) PreviewSrc(img image.Image) *ImageWPreviewSrc shows img in the preview instead of the image itself (Ant preview.src: a larger original behind a thumbnail).
func (*ImageW) Radius 实验性
func (w *ImageW) Radius(px float32) *ImageWRadius rounds the corners.
func (*ImageW) Rotate 实验性
func (w *ImageW) Rotate(deg float64) *ImageWRotate turns the open preview by deg degrees (clockwise, any angle; relative to its current rotation). Call it once per action, e.g. from a button's Clicked branch. The toolbar's rotate buttons step by 90°, and Shift-dragging the preview image rotates it freely.
func (*ImageW) ScaleStep 实验性
func (w *ImageW) ScaleStep(step float32) *ImageWScaleStep sets the zoom step of the preview buttons: each step scales by 1+step (Ant scaleStep 0.5; Element zoom-rate 1.2 = step 0.2).
func (*ImageW) ShowProgress 实验性
func (w *ImageW) ShowProgress(on bool) *ImageWShowProgress shows the "2 / 5" counter of a group preview (Ant always, Element show-progress, default false; the theme picks the default).
func (*ImageW) Size 实验性
func (w *ImageW) Size(wpx, hpx float32) *ImageWSize fixes both sides.
func (*ImageW) Width 实验性
func (w *ImageW) Width(px float32) *ImageWWidth / Height fix the box size in px (the other side follows the image aspect ratio when only one is set).
InfiniteScrollW 实验性
type InfiniteScrollW struct {
// contains filtered or unexported fields
}InfiniteScrollW is a scrolling column that asks for more content when the user nears its bottom.
func InfiniteScroll 实验性
func InfiniteScroll(c *Context, fn func(), opts ...layout.Option) *InfiniteScrollWInfiniteScroll builds fn (the items) inside a vertical scroll area. Give it a bounded height with Height or opts (layout.H / MaxH / Grow), then poll NeedMore:
inf := ui.InfiniteScroll(c, func() { for _, it := range items { ... } }).
Height(400).Loading(loading).Done(len(items) >= total)
if inf.NeedMore() { loading = true; go fetch() }
func (*InfiniteScrollW) Disabled 实验性
func (w *InfiniteScrollW) Disabled(on bool) *InfiniteScrollWDisabled stops NeedMore without showing a footer.
func (*InfiniteScrollW) Distance 实验性
func (w *InfiniteScrollW) Distance(px float32) *InfiniteScrollWDistance is how close (px) to the bottom NeedMore starts firing (Element infinite-scroll-distance; default 0).
func (*InfiniteScrollW) Done 实验性
func (w *InfiniteScrollW) Done(on bool) *InfiniteScrollWDone shows the "no more" footer and stops NeedMore.
func (*InfiniteScrollW) DoneText 实验性
func (w *InfiniteScrollW) DoneText(s string) *InfiniteScrollWfunc (*InfiniteScrollW) Height 实验性
func (w *InfiniteScrollW) Height(px float32) *InfiniteScrollWHeight fixes the viewport height.
func (*InfiniteScrollW) ID 实验性
func (w *InfiniteScrollW) ID() IDID returns the scroll container's ID.
func (*InfiniteScrollW) Layout 实验性
func (w *InfiniteScrollW) Layout(opts ...layout.Option) *InfiniteScrollWLayout applies layout options to the viewport.
func (*InfiniteScrollW) Loading 实验性
func (w *InfiniteScrollW) Loading(on bool) *InfiniteScrollWLoading shows the loading footer and suppresses NeedMore.
func (*InfiniteScrollW) LoadingText 实验性
func (w *InfiniteScrollW) LoadingText(s string) *InfiniteScrollWLoadingText / DoneText replace the footer texts ("" hides the text).
func (*InfiniteScrollW) NeedMore 实验性
func (w *InfiniteScrollW) NeedMore() boolNeedMore reports, once per content height, that the viewport is within Distance of the bottom (or not yet filled) and more items should load.
func (*InfiniteScrollW) Offset 实验性
func (w *InfiniteScrollW) Offset() float64Offset returns the vertical scroll offset.
func (*InfiniteScrollW) ScrollTo 实验性
func (w *InfiniteScrollW) ScrollTo(y float64) *InfiniteScrollWScrollTo sets the vertical scroll offset.
InlineSpan 实验性
type InlineSpan = inlineSpanInlineSpan places things along a rectangle's inline axis by start/end offsets: in RTL scopes offsets run from the right edge.
InputNumberW
type InputNumberW struct {
// contains filtered or unexported fields
}InputNumberW is a numeric input with step controls.
func InputNumber
func InputNumber(c *Context, val *float64) *InputNumberWInputNumber adds a numeric input bound to *val (val may be nil with StringMode).
func (*InputNumberW) A11yLabel
func (w *InputNumberW) A11yLabel(s string) *InputNumberWA11yLabel sets the accessible name of the numeric input.
func (*InputNumberW) Changed
func (w *InputNumberW) Changed() boolfunc (*InputNumberW) Controls
func (w *InputNumberW) Controls(on bool) *InputNumberWControls shows (true, the default) or hides the step buttons (antd controls, Element controls). Without them the arrow keys and the wheel still step the value.
func (*InputNumberW) ControlsPosition
func (w *InputNumberW) ControlsPosition(pos string) *InputNumberWControlsPosition places the step buttons: "right" (stacked at the right, Ant's look and Element's controls-position="right") or "sides" (− before and + after the value). The default follows the design system: "sides" under Element (el-input-number's default), "right" otherwise.
func (*InputNumberW) Disabled
func (w *InputNumberW) Disabled(on bool) *InputNumberWfunc (*InputNumberW) DownDisabled
func (w *InputNumberW) DownDisabled() boolDownDisabled reports whether the − / down button is disabled.
func (*InputNumberW) Empty
func (w *InputNumberW) Empty(empty *bool) *InputNumberWEmpty lets the field hold no value, like a nullable number: *empty reports whether it is empty. An empty field shows the placeholder and ignores *val; typing a number clears *empty, clearing the text sets it. The step buttons start an empty field from 0 (clamped to Min/Max). Without Empty, clearing the text and leaving keeps the previous value.
func (*InputNumberW) Formatter
func (w *InputNumberW) Formatter(fn func(value string) string) *InputNumberWFormatter formats the value for display ("$ 1,000"); the text being edited keeps the formatted form. Pair it with Parser.
func (*InputNumberW) Keyboard
func (w *InputNumberW) Keyboard(on bool) *InputNumberWKeyboard turns the Up / Down arrow keys stepping on (the default) or off (antd keyboard).
func (*InputNumberW) Max
func (w *InputNumberW) Max(v float64) *InputNumberWfunc (*InputNumberW) Min
func (w *InputNumberW) Min(v float64) *InputNumberWfunc (*InputNumberW) Mode
func (w *InputNumberW) Mode(m string) *InputNumberWMode chooses where the step buttons go (antd 6 mode): "input" (stacked at the inline end, the default) or "spinner" (− before and + after the value, which is centred). It is the antd name of ControlsPosition: "spinner" equals ControlsPosition("sides") and "input" equals ControlsPosition("right").
func (*InputNumberW) Parser
func (w *InputNumberW) Parser(fn func(display string) string) *InputNumberWParser turns the displayed text back into a plain number ("1000"). Without one, a formatted field keeps only digits, '.', '-' and 'e'.
func (*InputNumberW) Placeholder
func (w *InputNumberW) Placeholder(s string) *InputNumberWPlaceholder is shown while the field is empty (see Empty).
func (*InputNumberW) Precision
func (w *InputNumberW) Precision(n int) *InputNumberWfunc (*InputNumberW) Prefix
func (w *InputNumberW) Prefix(ic *icon.Icon) *InputNumberWPrefix shows an icon before the value.
func (*InputNumberW) PrefixText
func (w *InputNumberW) PrefixText(s string) *InputNumberWPrefixText shows short static text before the value ("¥").
func (*InputNumberW) ReadOnly
func (w *InputNumberW) ReadOnly() *InputNumberWReadOnly shows the value without letting it change: the text can be selected and copied, the step buttons are hidden and the arrow keys and the wheel do nothing (antd readOnly, Element readonly).
func (*InputNumberW) Size
func (w *InputNumberW) Size(s ControlSize) *InputNumberWfunc (*InputNumberW) Status
func (w *InputNumberW) Status(s string) *InputNumberWStatus overrides the validation status ("error" | "warning"); inside a form item it defaults to the item's status.
func (*InputNumberW) Step
func (w *InputNumberW) Step(v float64) *InputNumberWfunc (*InputNumberW) StepStrictly
func (w *InputNumberW) StepStrictly() *InputNumberWStepStrictly only accepts multiples of Step (Element step-strictly): a typed value is rounded to the nearest multiple when it is committed. It applies to float64 values (not to StringMode).
func (*InputNumberW) StringMode
func (w *InputNumberW) StringMode(s *string) *InputNumberWStringMode binds the value as a decimal string instead of a float64, so it keeps every digit ("0.1" + "0.2" = "0.3", 20-digit amounts; Ant stringMode). "" is an empty field. *val (if any) receives the nearest float64.
func (*InputNumberW) Submitted
func (w *InputNumberW) Submitted() boolSubmitted reports Enter after committing the numeric value. It may be true when the committed value is unchanged.
func (*InputNumberW) UpDisabled
func (w *InputNumberW) UpDisabled() boolUpDisabled reports whether the + / up button is disabled (a value at Max, a disabled or read-only field, or no step buttons).
func (*InputNumberW) Variant
func (w *InputNumberW) Variant(v string) *InputNumberWVariant sets the frame look (see InputW.Variant).
func (*InputNumberW) Wheel
func (w *InputNumberW) Wheel() *InputNumberWWheel lets the mouse wheel step the value while the field has focus (Ant changeOnWheel).
func (*InputNumberW) Width
func (w *InputNumberW) Width(px float32) *InputNumberWInputTagW 实验性
type InputTagW struct {
// contains filtered or unexported fields
}InputTagW is a text field that turns entries into tags (Enter or a separator, by default a comma).
func InputTag 实验性
func InputTag(c *Context, val *[]string) *InputTagWInputTag adds a tag input bound to *val.
func (*InputTagW) A11yLabel 实验性
func (w *InputTagW) A11yLabel(s string) *InputTagWA11yLabel sets the accessible name of the text field (inside a FormItem the item label is used; the placeholder is the last resort).
func (*InputTagW) Added 实验性
func (w *InputTagW) Added() stringAdded returns the tag added this frame ("" if none).
func (*InputTagW) AllowClear 实验性
func (w *InputTagW) AllowClear() *InputTagWfunc (*InputTagW) Changed 实验性
func (w *InputTagW) Changed() boolChanged reports an added or removed tag this frame.
func (*InputTagW) Disabled 实验性
func (w *InputTagW) Disabled(on bool) *InputTagWfunc (*InputTagW) Draggable 实验性
func (w *InputTagW) Draggable() *InputTagWDraggable lets the user reorder the tags by dragging them; a drop reports Changed.
func (*InputTagW) Layout 实验性
func (w *InputTagW) Layout(o ...layout.Option) *InputTagWfunc (*InputTagW) MaxTagCount 实验性
func (w *InputTagW) MaxTagCount(n int) *InputTagWfunc (*InputTagW) MaxTags 实验性
func (w *InputTagW) MaxTags(n int) *InputTagWMaxTags limits how many tags can be entered (0 = unlimited).
func (*InputTagW) Placeholder 实验性
func (w *InputTagW) Placeholder(s string) *InputTagWfunc (*InputTagW) SaveOnBlur 实验性
func (w *InputTagW) SaveOnBlur() *InputTagWSaveOnBlur turns the typed text into a tag when the field loses focus (by default the text stays in the field).
func (*InputTagW) Separators 实验性
func (w *InputTagW) Separators(seps ...string) *InputTagWSeparators sets the strings that end a tag while typing or pasting (Element delimiter), e.g. Separators(";", " "); the default is the ASCII and the full-width comma. Separators() with no argument leaves only Enter. Empty strings are ignored.
func (*InputTagW) Size 实验性
func (w *InputTagW) Size(s ControlSize) *InputTagWfunc (*InputTagW) Status 实验性
func (w *InputTagW) Status(s string) *InputTagWfunc (*InputTagW) Trigger 实验性
func (w *InputTagW) Trigger(key string) *InputTagWTrigger sets the key that turns the typed text into a tag (Element trigger): "Enter" (default) or "Space". With "Space" the space key adds the tag instead of typing a space and Enter does nothing. ConfigProvider.Defaults("InputTag", "trigger") sets it for a subtree.
func (*InputTagW) Width 实验性
func (w *InputTagW) Width(px float32) *InputTagWInputW
type InputW struct {
// contains filtered or unexported fields
}InputW is a single-line text input.
func Input
func Input(c *Context, val *string) *InputWInput adds a text input bound to *val.
func (*InputW) A11yLabel
func (w *InputW) A11yLabel(s string) *InputWA11yLabel sets the accessible name. Inside a FormItem the item label is used; otherwise the placeholder is the last resort.
func (*InputW) AllowClear
func (w *InputW) AllowClear() *InputWAllowClear shows a clear button when the input has a value.
func (*InputW) Bg
func (w *InputW) Bg(col theme.Color) *InputWBg replaces the background color of the frame (a grey search field on a white bar). It keeps hover / focus borders unless NoBorder is set.
func (*InputW) Borderless
func (w *InputW) Borderless() *InputWBorderless drops the frame (background, border and focus halo), for inputs embedded in another surface such as the Command search row.
func (*InputW) Changed
func (w *InputW) Changed() boolChanged reports whether the value was edited this frame.
func (*InputW) Disabled
func (w *InputW) Disabled(on bool) *InputWDisabled disables editing.
func (*InputW) EnterKey
func (w *InputW) EnterKey(k input.EnterKey) *InputWEnterKey labels the soft keyboard's return key (input.EnterSearch, input.EnterNext, …). Pressing it still submits (Submitted).
func (*InputW) Focus
func (w *InputW) Focus() *InputWFocus requests keyboard focus.
func (*InputW) Focused
func (w *InputW) Focused() boolFocused reports keyboard focus.
func (*InputW) ID
func (w *InputW) ID() IDID returns the editor's widget ID.
func (*InputW) Kind
func (w *InputW) Kind(k input.TextKind) *InputWKind tells soft keyboards what the field holds (input.TextEmail, input.TextNumber, …): the keyboard layout and whether it suggests words. It does not filter what can be typed. Password sets input.TextPassword.
func (*InputW) Layout
func (w *InputW) Layout(opts ...layout.Option) *InputWLayout applies layout options to the outer frame.
func (*InputW) MaxLength
func (w *InputW) MaxLength(n int) *InputWMaxLength limits the number of runes.
func (*InputW) NoBorder
func (w *InputW) NoBorder() *InputWNoBorder drops the border and the focus halo but keeps the background (Bg or the variant's), e.g. a filled search bar.
func (*InputW) Password
func (w *InputW) Password() *InputWPassword masks the value and adds a visibility toggle.
func (*InputW) Placeholder
func (w *InputW) Placeholder(s string) *InputWfunc (*InputW) Prefix
func (w *InputW) Prefix(ic *icon.Icon) *InputWfunc (*InputW) PrefixText
func (w *InputW) PrefixText(s string) *InputWPrefixText / SuffixText show short static text (units, currency).
func (*InputW) ReadOnly
func (w *InputW) ReadOnly() *InputWReadOnly prevents edits but allows selection.
func (*InputW) SelectAll
func (w *InputW) SelectAll() *InputWSelectAll selects the full text of the input. It can be used after Focus when presenting a prefilled field and does not move focus itself.
func (*InputW) ShowCount
func (w *InputW) ShowCount() *InputWShowCount shows the character count ("3 / 20" with MaxLength) at the end of the field (Ant showCount, Element show-word-limit).
func (*InputW) Size
func (w *InputW) Size(s ControlSize) *InputWSize sets the control size.
func (*InputW) Status
func (w *InputW) Status(s string) *InputWStatus sets the validation status: "error" or "warning".
func (*InputW) Submitted
func (w *InputW) Submitted() boolSubmitted reports an Enter key press.
func (*InputW) Suffix
func (w *InputW) Suffix(ic *icon.Icon) *InputWfunc (*InputW) SuffixText
func (w *InputW) SuffixText(s string) *InputWfunc (*InputW) Variant
func (w *InputW) Variant(v string) *InputWVariant sets the look of the frame (Ant Input variant): "outlined" (default), "filled" (grey fill, border on focus), "borderless" (no frame) or "underlined" (bottom line only).
func (*InputW) VisibilityToggle
func (w *InputW) VisibilityToggle(on bool) *InputWVisibilityToggle shows (true, the default) or hides the eye button of a Password field (antd Input.Password visibilityToggle; Element type="password" without show-password).
func (*InputW) Width
func (w *InputW) Width(px float32) *InputWWidth fixes the width.
Interaction
type Interaction struct {
ID ID
Hovered bool // pointer over it and not covered by a higher layer
Pressed bool // pointer went down on it and is still held
Clicked bool // activated this frame (pointer or Enter/Space)
Clicks int // click count of the activation (2 = double click)
PressedNow bool // pointer went down on it this frame
Focused bool
FocusVisible bool // focused via keyboard: draw the focus ring
}Interaction is the per-frame pointer/keyboard state of a widget.
ItemGroupW 实验性
type ItemGroupW struct {
// contains filtered or unexported fields
}ItemGroupW stacks Items as a list (shadcn/ui ItemGroup), optionally with rules between them (ItemSeparator) and an outline around them.
func ItemGroup 实验性
func ItemGroup(c *Context) *ItemGroupWItemGroup starts a list of Items; chain options, then Body:
ui.ItemGroup(c).Separated().Bordered().Body(func() {
ui.Item(c, "通知").Description("…")
ui.Item(c, "隐私").Description("…")
})
func (*ItemGroupW) A11yLabel 实验性
func (g *ItemGroupW) A11yLabel(s string) *ItemGroupWA11yLabel names the list.
func (*ItemGroupW) Body 实验性
func (g *ItemGroupW) Body(fn func()) *ItemGroupWBody builds the items.
func (*ItemGroupW) Bordered 实验性
func (g *ItemGroupW) Bordered() *ItemGroupWBordered outlines the group with rounded corners.
func (*ItemGroupW) Gap 实验性
func (g *ItemGroupW) Gap(px float32) *ItemGroupWGap sets the space between items (with Separated, the rule sits in its middle).
func (*ItemGroupW) ID 实验性
func (g *ItemGroupW) ID() IDID returns the group's ID.
func (*ItemGroupW) Separated 实验性
func (g *ItemGroupW) Separated() *ItemGroupWSeparated draws a rule between consecutive items.
ItemSize 实验性
type ItemSize stringItemSize is the density of an Item. Open set.
const (
ItemSizeDefault ItemSize = "default"
ItemSizeSmall ItemSize = "sm"
)实验性
ItemVariant 实验性
type ItemVariant stringItemVariant is the surface of an Item. Open set: new variants are added as new constants.
const (
ItemVariantDefault ItemVariant = "default" // no surface
ItemVariantOutline ItemVariant = "outline" // bordered
ItemVariantMuted ItemVariant = "muted" // muted fill
)实验性
ItemW 实验性
type ItemW struct {
// contains filtered or unexported fields
}ItemW is a general list row (shadcn/ui Item): media (an icon tile, an avatar, an image), a title with a description, and actions at the end.
func Item 实验性
func Item(c *Context, title string) *ItemWItem adds a list row titled title; chain the parts and options:
ui.Item(c, "安全设置").Description("双重验证已开启").Icon(icon.Lock).Outline().
Actions(func() { ui.Button(c, "管理").Small() })
if ui.Item(c, "个人资料").Icon(icon.User).Link().Clicked() { ... }
The row is built at the end of the chain (Clicked, or the end of the build).
func (*ItemW) A11yLabel 实验性
func (w *ItemW) A11yLabel(s string) *ItemWA11yLabel overrides the accessible name (the title by default).
func (*ItemW) Actions 实验性
func (w *ItemW) Actions(fn func()) *ItemWActions builds controls at the end of the row.
func (*ItemW) Clickable 实验性
func (w *ItemW) Clickable() *ItemWClickable makes the whole row a button: focusable, hover highlight, Enter / Space or a click report Clicked.
func (*ItemW) Clicked 实验性
func (w *ItemW) Clicked() boolClicked reports a click (or Enter / Space) on a clickable row.
func (*ItemW) Content 实验性
func (w *ItemW) Content(fn func()) *ItemWContent builds extra content under the description (tags, progress).
func (*ItemW) Description 实验性
func (w *ItemW) Description(s string) *ItemWDescription adds the secondary text under the title (two lines at most).
func (*ItemW) Disabled 实验性
func (w *ItemW) Disabled(on bool) *ItemWDisabled dims the row and stops a clickable one from reacting.
func (*ItemW) ID 实验性
func (w *ItemW) ID() IDID returns the row's ID.
func (*ItemW) Icon 实验性
func (w *ItemW) Icon(ic *icon.Icon) *ItemWIcon shows ic in a tile at the start (ItemMedia variant="icon").
func (*ItemW) Link 实验性
func (w *ItemW) Link() *ItemWLink makes the whole row a link (as Clickable, announced as a link; the app navigates on Clicked).
func (*ItemW) Media 实验性
func (w *ItemW) Media(fn func()) *ItemWMedia builds custom media at the start (an Avatar, an Image) in place of the icon tile.
func (*ItemW) Muted 实验性
func (w *ItemW) Muted() *ItemWMuted is Variant(ItemVariantMuted).
func (*ItemW) Outline 实验性
func (w *ItemW) Outline() *ItemWOutline is Variant(ItemVariantOutline).
func (*ItemW) Size 实验性
func (w *ItemW) Size(s ItemSize) *ItemWSize selects the density (default, sm).
func (*ItemW) Small 实验性
func (w *ItemW) Small() *ItemWSmall is Size(ItemSizeSmall).
func (*ItemW) Variant 实验性
func (w *ItemW) Variant(v ItemVariant) *ItemWVariant selects the surface (default, outline, muted).
JSONViewLocale 实验性
type JSONViewLocale struct {
Name string // accessible name of the tree
CopyValue, CopyPath string
ExpandAll, CollapseAll string
ItemsFmt string // array size, arg: n ("%d 项")
KeysFmt string // object size, arg: n ("%d 个键")
Search string // search box placeholder
PrevMatch, NextMatch string
MatchFmt string // current match and count, args: i, n
NoMatch string
ParseErrorFmt string // arg: the parser's message
// contains filtered or unexported fields
}JSONViewLocale holds the JSONView texts.
func (*JSONViewLocale) Items 实验性
func (l *JSONViewLocale) Items(n int) stringItems formats an array size.
func (*JSONViewLocale) Keys 实验性
func (l *JSONViewLocale) Keys(n int) stringKeys formats an object size.
func (*JSONViewLocale) Match 实验性
func (l *JSONViewLocale) Match(i, n int) stringMatch formats the match position.
func (*JSONViewLocale) ParseError 实验性
func (l *JSONViewLocale) ParseError(msg string) stringParseError formats a parse error.
JSONViewW 实验性
type JSONViewW struct {
// contains filtered or unexported fields
}JSONViewW shows a value tree: a JSON document (JSONView), a Go value (JSONViewValue) or any ValueSource such as a debugger's variables (JSONViewSource). Nodes load when expanded, large arrays and objects open in groups of 100, and only the visible rows are built. Values are colored by type; containers show their size. A row's context menu (or Cmd/Ctrl+C, Cmd/Ctrl+Shift+C on the current row) copies its value or its path ($.a.b[0]); the toolbar searches keys and values and expands or collapses everything.
Keyboard (the tree is one Tab stop): Up/Down/Page Up/Page Down/Home/End move the current row, Right expands or enters, Left collapses or goes to the parent, Enter toggles.
func JSONView 实验性
func JSONView(c *Context, data []byte, opts ...layout.Option) *JSONViewWJSONView adds a viewer of the JSON document data (shown with an error message when it is not valid JSON). The same data slice (by address and length) keeps the tree's state; replace the slice to show new data.
ui.JSONView(c, body).Height(400)
func JSONViewSource 实验性
func JSONViewSource(c *Context, src ValueSource, opts ...layout.Option) *JSONViewWJSONViewSource adds a viewer of a value tree source (a debugger's variables, a remote document …). The same source value keeps the tree's state; bump DataVersion to reload it.
func JSONViewValue 实验性
func JSONViewValue(c *Context, v any, opts ...layout.Option) *JSONViewWJSONViewValue adds a viewer of a Go value (see GoValueSource). Pass a pointer, map or slice to keep the tree's state across frames, and bump DataVersion when its contents change.
func (*JSONViewW) A11yLabel 实验性
func (w *JSONViewW) A11yLabel(s string) *JSONViewWA11yLabel sets the accessible name of the tree.
func (*JSONViewW) Copied 实验性
func (w *JSONViewW) Copied() stringCopied returns the text copied this frame ("" if none).
func (*JSONViewW) Current 实验性
func (w *JSONViewW) Current() stringCurrent returns the path of the current row ("" if none).
func (*JSONViewW) DataVersion 实验性
func (w *JSONViewW) DataVersion(v int) *JSONViewWDataVersion reloads the tree when v changes (keeping what is expanded).
func (*JSONViewW) ExpandDepth 实验性
func (w *JSONViewW) ExpandDepth(n int) *JSONViewWExpandDepth sets how many levels open when data is first shown (default 1: the roots).
func (*JSONViewW) Height 实验性
func (w *JSONViewW) Height(px float32) *JSONViewWHeight fixes the viewer's height (toolbar included); without it the viewer grows in its parent.
func (*JSONViewW) ID 实验性
func (w *JSONViewW) ID() IDID returns the viewer's ID.
func (*JSONViewW) Layout 实验性
func (w *JSONViewW) Layout(opts ...layout.Option) *JSONViewWLayout applies layout options to the viewer.
func (*JSONViewW) Matches 实验性
func (w *JSONViewW) Matches() intMatches returns the number of search matches found so far.
func (*JSONViewW) NoToolbar 实验性
func (w *JSONViewW) NoToolbar() *JSONViewWNoToolbar hides the search / expand toolbar.
func (*JSONViewW) Query 实验性
func (w *JSONViewW) Query(q *string) *JSONViewWQuery binds the search text to *q.
func (*JSONViewW) Rows 实验性
func (w *JSONViewW) Rows() intRows returns the number of visible rows (expanded nodes included).
func (*JSONViewW) ShowTypes 实验性
func (w *JSONViewW) ShowTypes() *JSONViewWShowTypes shows the nodes' Type labels.
KbdW 实验性
type KbdW struct {
*Box
// contains filtered or unexported fields
}KbdW is the key cap Kbd returns; it embeds the widget's Box.
func Kbd 实验性
func Kbd(c *Context, keys string) *KbdWKbd shows a keyboard key or shortcut (shadcn/ui Kbd): small muted rounded box in the text font.
KeyboardInsetWindow 实验性
type KeyboardInsetWindow interface {
KeyboardInset() geom.Insets
}KeyboardInsetWindow is implemented by windows that know the part of their content area covered by the soft keyboard (usually only Bottom; zero while it is hidden). It is polled every frame like SafeAreaWindow, so it must return a cached value.
KeyboardReveal 实验性
type KeyboardReveal struct {
Field ID // the focused widget
Rect geom.Rect // its rectangle
Caret geom.Rect // its caret (Context.WantTextInput)
// Limit is the window y the revealed part must end above: the top of
// the keyboard minus a margin.
Limit float32
}KeyboardReveal is a request to scroll the focused text field above the soft keyboard. Rectangles are window logical pixels from the last painted frame.
func (KeyboardReveal) Target 实验性
func (k KeyboardReveal) Target(top float32) geom.RectTarget returns what to bring into view in a viewport whose visible part starts at window y top: the whole field (with its caret) when it fits between top and Limit, else only the caret line.
Label
type Label struct {
// contains filtered or unexported fields
}Label is a run of text (Typography.Text).
func Paragraph
func Paragraph(c *Context, s string) *LabelParagraph is Text intended for long-form content.
func Text
func Text(c *Context, s string) *LabelText adds a single paragraph of text that wraps to its width.
func Title
func Title(c *Context, s string, level int) *LabelTitle adds a heading; level 1..5 like Typography.Title.
func (*Label) Align
func (t *Label) Align(a TextAlign) *LabelAlign aligns the text in its box.
func (*Label) Code
func (t *Label) Code() *Labelfunc (*Label) Color
func (t *Label) Color(col theme.Color) *LabelColor sets the text color.
func (*Label) Copied
func (t *Label) Copied() boolCopied reports whether the copy icon was clicked within the last 3s.
func (*Label) CopyText
func (t *Label) CopyText(payload string) *LabelCopyText is Copyable with a different clipboard payload.
func (*Label) Copyable
func (t *Label) Copyable() *LabelCopyable adds a copy icon after the text; clicking it writes the text to the clipboard and shows a check mark for three seconds.
func (*Label) Delete
func (t *Label) Delete() *Labelfunc (*Label) Disabled
func (t *Label) Disabled() *LabelDisabled greys the text out.
func (*Label) Editable
func (t *Label) Editable(val *string) *LabelEditable adds an edit icon; clicking it swaps the text for an input. Enter or losing focus commits into *val, Escape cancels.
func (*Label) Editing
func (t *Label) Editing() boolEditing reports whether the label is being edited.
func (*Label) Ellipsis
func (t *Label) Ellipsis() *LabelEllipsis keeps one line and truncates with "…".
func (*Label) Expandable
func (t *Label) Expandable(open *bool) *LabelExpandable adds an "展开" link when the text is cut by Lines(n); open is toggled by the link ("收起" collapses when open).
func (*Label) ID
func (t *Label) ID() IDID returns the node ID.
func (*Label) Italic
func (t *Label) Italic() *LabelItalic slants the text (synthetic oblique).
func (*Label) Layout
func (t *Label) Layout(opts ...layout.Option) *LabelLayout applies layout options to the text node.
func (*Label) LineHeight
func (t *Label) LineHeight(px float32) *LabelLineHeight overrides the line height in px.
func (*Label) Lines
func (t *Label) Lines(n int) *LabelLines limits wrapping to n lines with an ellipsis.
func (*Label) Mark
func (t *Label) Mark() *Labelfunc (*Label) NoWrap
func (t *Label) NoWrap() *LabelNoWrap keeps the text on one line.
func (*Label) Secondary
func (t *Label) Secondary() *LabelSecondary uses the secondary text color.
func (*Label) Size
func (t *Label) Size(px float32) *LabelSize sets the font size (line height follows the theme).
func (*Label) Strong
func (t *Label) Strong() *LabelStrong uses the theme's strong weight.
func (*Label) Tertiary
func (t *Label) Tertiary() *LabelTertiary uses the tertiary text color (descriptions, hints).
func (*Label) TextDir
func (t *Label) TextDir(d text.Direction) *LabelTextDir sets the paragraph base direction explicitly. By default label text follows the scope: RTL in an RTL scope, else taken from the first strong character (text.DirAuto).
func (*Label) Type
func (t *Label) Type(status string) *LabelType colors the text by status: "success", "warning", "danger"/"error".
func (*Label) Underline
func (t *Label) Underline() *LabelUnderline / Delete / Code / Mark decorations.
func (*Label) Weight
func (t *Label) Weight(w text.Weight) *LabelWeight sets the font weight.
LightFilterLocale 实验性
type LightFilterLocale struct {
Name string // accessible name of the toolbar
ClearFmt string // clear button of a field, arg: field label ("清除%s")
PillFmt string // accessible name of a field pill, args: label, value ("%s:%s")
More string // collapsed fields button
MoreFmt string // collapsed fields button with values set, arg: count ("更多筛选(%d)")
// contains filtered or unexported fields
}LightFilterLocale holds the LightFilter texts.
LightFilterW 实验性
type LightFilterW struct {
// contains filtered or unexported fields
}LightFilterW is a compact filter bar (Ant Design Pro LightFilter): each field is a "label: value" pill; clicking it opens a popup with the field's editor and clear / confirm buttons. It takes the same field definitions as QueryFilter and ProForm.
lf := ui.LightFilter(c, fields).Values(&filter).Show()
if lf.Changed() { reload(lf.Params()) }
func LightFilter 实验性
func LightFilter(c *Context, fields []ProField) *LightFilterWLightFilter starts a filter bar over fields; chain options, then Show.
ConfigProvider.Defaults("LightFilter", ...) keys: "size", "bordered", "collapse" (number of pills before "more filters").
func (*LightFilterW) Bordered 实验性
func (f *LightFilterW) Bordered() *LightFilterWBordered draws an outline around every pill.
func (*LightFilterW) Changed 实验性
func (f *LightFilterW) Changed() boolChanged reports a value confirmed or cleared in the last Show.
func (*LightFilterW) Collapse 实验性
func (f *LightFilterW) Collapse(n int) *LightFilterWCollapse shows at most n fields as pills; the others are edited together in a "more filters" popup (n <= 0: every field is a pill).
func (*LightFilterW) ID 实验性
func (f *LightFilterW) ID() IDID returns the widget ID (valid after Show).
func (*LightFilterW) OpenKey 实验性
func (f *LightFilterW) OpenKey() stringOpenKey returns the key of the field whose popup is open ("" if none).
func (*LightFilterW) Params 实验性
func (f *LightFilterW) Params() map[string]stringParams returns the non-empty values as text (dates as 2006-01-02).
func (*LightFilterW) Show 实验性
func (f *LightFilterW) Show() *LightFilterWShow builds the bar.
func (*LightFilterW) Size 实验性
func (f *LightFilterW) Size(s ControlSize) *LightFilterWSize sets the pill size (default: the global size).
func (*LightFilterW) Values 实验性
func (f *LightFilterW) Values(v *ProValues) *LightFilterWValues binds the values (otherwise the filter keeps its own).
LinkW
type LinkW struct {
*Label
// contains filtered or unexported fields
}LinkW is a clickable text link.
func Link
func Link(c *Context, s string) *LinkWLink adds a hyperlink-styled text button.
ConfigProvider.Defaults("Link", ...) keys: "underline" ("always" | "hover" | "never"; Element underline).
func (*LinkW) Clicked
func (lw *LinkW) Clicked() boolClicked reports activation.
func (*LinkW) Color
func (lw *LinkW) Color(col theme.Color) *LinkWColor draws the link in col in every state (disabled still greys out).
func (*LinkW) Hovered
func (lw *LinkW) Hovered() boolHovered reports hover.
func (*LinkW) Icon
func (lw *LinkW) Icon(ic *icon.Icon) *LinkWIcon puts an icon before the text in the link color (Element el-link icon).
func (*LinkW) Secondary
func (lw *LinkW) Secondary() *LinkWSecondary is Type("secondary").
func (*LinkW) Type
func (lw *LinkW) Type(status string) *LinkWType colors the link by status: "success", "warning", "danger" / "error", "info" use that palette (hover and pressed shades follow); "secondary" (or Element's "default") starts in the secondary text color and turns link-colored on hover; "primary" is the primary palette. "" restores the link colors.
func (*LinkW) UnderlineMode
func (lw *LinkW) UnderlineMode(mode string) *LinkWUnderlineMode sets when the link is underlined: "always", "hover" or "never" (Element underline; the default follows the theme: never for Ant, on hover for Element, always for shadcn). Other values restore the theme's.
ListActionsW 实验性
type ListActionsW struct {
*Box
// contains filtered or unexported fields
}ListActionsW is the action row ListActions returns; it embeds the row's Box.
func ListActions 实验性
func ListActions(c *Context, fn func()) *ListActionsWListActions lays out item actions at the end of a list row, separated by short vertical bars (Ant's actions). In a vertical list they sit under the content, wider apart.
ListItemMetaW 实验性
type ListItemMetaW struct {
*Box
// contains filtered or unexported fields
}ListItemMetaW is the block ListItemMeta returns; it embeds the row's Box.
func ListItemMeta 实验性
func ListItemMeta(c *Context, avatar func(), title, desc string) *ListItemMetaWListItemMeta is the avatar + title + description block of a list item. avatar may be nil. It grows to take the row's free space.
In a vertical list (List.ItemLayout("vertical")) the title is large with a 12px gap under it and the block keeps 16px below.
ListToolBarW 实验性
type ListToolBarW struct {
// contains filtered or unexported fields
}ListToolBarW composes the title, subtitle, tooltip, search, actions, settings, filter, tabs and header menu of a list. ProTable uses this same public component for its toolbar, passing its existing settings.
func ListToolBar 实验性
func ListToolBar(c *Context) *ListToolBarWListToolBar starts a list toolbar; chain options, then Show. ConfigProvider.Defaults keys: "title", "subTitle", "tooltip" (strings), "search" (bool, default false), "multipleLine" (bool, default false).
func (*ListToolBarW) Actions 实验性
func (w *ListToolBarW) Actions(fn func()) *ListToolBarWActions builds the right-hand actions.
func (*ListToolBarW) Filter 实验性
func (w *ListToolBarW) Filter(fn func()) *ListToolBarWFilter builds the filter area (for example LightFilter).
func (*ListToolBarW) ID 实验性
func (w *ListToolBarW) ID() IDID returns the toolbar ID after Show.
func (*ListToolBarW) Menu 实验性
func (w *ListToolBarW) Menu(kind string, active *string, items []TabItem) *ListToolBarWMenu sets the header menu, replacing the heading; kind is "inline" (default), "tab" or "dropdown". A nil active pointer is uncontrolled.
func (*ListToolBarW) MultipleLine 实验性
func (w *ListToolBarW) MultipleLine(on bool) *ListToolBarWMultipleLine places filters and tabs on a separate line.
func (*ListToolBarW) OnSearch 实验性
func (w *ListToolBarW) OnSearch(fn func(string)) *ListToolBarWOnSearch receives a submitted keyword (Enter or search button).
func (*ListToolBarW) Search 实验性
func (w *ListToolBarW) Search(s *string) *ListToolBarWSearch binds the search input; nil hides it.
func (*ListToolBarW) Settings 实验性
func (w *ListToolBarW) Settings(fn func()) *ListToolBarWSettings builds the right-hand settings (use named IconButtons).
func (*ListToolBarW) Show 实验性
func (w *ListToolBarW) Show() *ListToolBarWShow builds the toolbar.
func (*ListToolBarW) SubTitle 实验性
func (w *ListToolBarW) SubTitle(s string) *ListToolBarWSubTitle sets the secondary text next to the heading.
func (*ListToolBarW) Tabs 实验性
func (w *ListToolBarW) Tabs(active *string, items []TabItem) *ListToolBarWTabs sets the second-line tabs, shown only with MultipleLine(true). A nil active pointer keeps the active key internally.
func (*ListToolBarW) Title 实验性
func (w *ListToolBarW) Title(s string) *ListToolBarWTitle sets the heading.
func (*ListToolBarW) Tooltip 实验性
func (w *ListToolBarW) Tooltip(s string) *ListToolBarWTooltip sets the heading information tooltip.
ListW
type ListW struct {
// contains filtered or unexported fields
}ListW renders a list of n items (Ant Design List).
func List
func List(c *Context, n int) *ListWList starts a list of n items; render each with Item.
ConfigProvider.Defaults("List", ...) keys: "size", "bordered", "split", "itemLayout" ("horizontal" | "vertical").
func (*ListW) Bordered
func (w *ListW) Bordered() *ListWfunc (*ListW) EmptyText
func (w *ListW) EmptyText(s string) *ListWfunc (*ListW) EstimatedItemHeight
func (w *ListW) EstimatedItemHeight(px float32) *ListWEstimatedItemHeight is the height Virtual assumes for an item not measured yet. Default: one line of text plus the item padding (46 at the middle size, as Listy).
func (*ListW) Footer
func (w *ListW) Footer(fn func()) *ListWfunc (*ListW) Grid
func (w *ListW) Grid(columns int, gap float32) *ListWGrid lays the items out in columns separated by gap px (antd grid gutter); every grid row keeps GridItemMarginBottom below it.
func (*ListW) GridAt
func (w *ListW) GridAt(bp Breakpoint, columns int) *ListWGridAt sets the grid column count from breakpoint bp upwards (Ant grid={{ xs: 1, sm: 2, md: 4 }}); the largest set breakpoint not above the window width wins, Grid's count is the fallback. Without Grid the list becomes a grid with a 16px gap.
func (*ListW) Header
func (w *ListW) Header(fn func()) *ListWfunc (*ListW) Height
func (w *ListW) Height(px float32) *ListWHeight fixes the height of the items' viewport (antd height); longer content scrolls inside it. Header, Footer, LoadMore and the pager stay outside it. Default 0: the list grows with its items.
func (*ListW) Item
func (w *ListW) Item(fn func(i int)) *ListWItem builds the list, calling fn for every visible item index.
func (*ListW) ItemExtra
func (w *ListW) ItemExtra(fn func(i int)) *ListWItemExtra builds extra content of item i (antd List.Item extra): at the inline end of the row, or in its own column beside the content and actions with the vertical layout.
func (*ListW) ItemHeight
func (w *ListW) ItemHeight(px float32) *ListWItemHeight fixes every item's height, padding included (the fast path of Virtual: nothing is measured). Default 0: items size to their content.
func (*ListW) ItemLayout
func (w *ListW) ItemLayout(s string) *ListWItemLayout sets the item layout (antd itemLayout): "horizontal" (the default: content and actions on one line) or "vertical" (actions under the content, ItemExtra in a column at the inline end; ListItemMeta gets the large title and ListActions moves under the content).
func (*ListW) Layout
func (w *ListW) Layout(o ...layout.Option) *ListWLayout applies layout options to the list (call after Item).
func (*ListW) LoadMore
func (w *ListW) LoadMore(label string, busy bool) *ListWLoadMore shows a centered "load more" button under the items; query the click with LoadMoreClicked. busy shows the button in its loading state.
func (*ListW) LoadMoreClicked
func (w *ListW) LoadMoreClicked() boolLoadMoreClicked reports a click on the load-more button in the last Item call.
func (*ListW) Loading
func (w *ListW) Loading(on bool) *ListWfunc (*ListW) PageChanged
func (w *ListW) PageChanged() boolPageChanged reports a page change in the last Item call.
func (*ListW) Pagination
func (w *ListW) Pagination(page *int, pageSize int) *ListWPagination shows a pager under the list and only renders the current page's items; *page is 1-based and owned by the app (out-of-range pages show the nearest page).
func (*ListW) PaginationAlign
func (w *ListW) PaginationAlign(a string) *ListWPaginationAlign aligns the pager (antd pagination.align): "start", "center" or "end" (default).
func (*ListW) PaginationPosition
func (w *ListW) PaginationPosition(pos string) *ListWPaginationPosition places the pager (antd pagination.position): "bottom" (default), "top" or "both".
func (*ListW) Range
func (w *ListW) Range() (first, end int)Range returns the item indexes [first, end) built by the last Item call: the current page, or under Virtual the window (the focused item aside, which is built even outside it).
func (*ListW) RowKey
func (w *ListW) RowKey(fn func(i int) any) *ListWRowKey gives items stable identities for the heights Virtual measures (default: the index; the measured heights are kept for every key seen, as Listy does). It does not change how items are keyed; wrap the item content in Key for state that follows the data.
func (*ListW) ScrollToKey
func (w *ListW) ScrollToKey(key any, align string, offset float64) *ListWScrollToKey scrolls the viewport (Height) to the item with key (RowKey; the index without one) using align (AlignTop, AlignBottom or AlignAuto) plus offset pixels. An item of the current page only; under Virtual an item not measured yet is placed by its estimate first and corrected over the next frames, as Listy.
func (*ListW) Size
func (w *ListW) Size(s ControlSize) *ListWfunc (*ListW) Split
func (w *ListW) Split(on bool) *ListWfunc (*ListW) Virtual
func (w *ListW) Virtual() *ListWVirtual builds only the items in the viewport (and a few past each edge) instead of every item; it needs Height and is ignored without it. With Pagination it windows the current page; with Grid it windows rows of columns items (a row is as high as its tallest item). The item that holds the keyboard focus is built on the frame it leaves the viewport, but once its focused control is clipped out of view the focus is lost, exactly as in the non-virtual Height form. Items scrolled out of view are not built, so state kept inside them (State, an input's text) is dropped after a while and they are missing from the accessibility tree, FindText and the Tab order, as with Listy and VirtualList. Heights are measured as items come into view and cached by RowKey; an item never measured counts EstimatedItemHeight, so the scroll bar can adjust the first time a taller item appears.
ListyW 实验性
type ListyW struct {
// contains filtered or unexported fields
}ListyW is a Listy list. Configure it and call Show.
func Listy 实验性
func Listy(c *Context, n int, item func(i int)) *ListyWListy starts a list of n items; item(i) builds the content of row i (padded 12/16 with a divider and hover background).
ui.Listy(c, len(users), func(i int) { ui.Text(c, users[i].Name) }).
Virtual().Height(400).Group(byLetter, letterHeader).Sticky().Show()
func (*ListyW) Clicked 实验性
func (w *ListyW) Clicked() (int, bool)Clicked returns the item clicked in Show.
func (*ListyW) DataVersion 实验性
func (w *ListyW) DataVersion(v int) *ListyWDataVersion tells the list that the data behind n, RowKey or Group changed without n changing (grouping and offsets are cached by n and this number).
func (*ListyW) EndReached 实验性
func (w *ListyW) EndReached() boolEndReached reports that the viewport is within 100px of the end while more data can be loaded (after Show).
func (*ListyW) EstimatedItemHeight 实验性
func (w *ListyW) EstimatedItemHeight(px float32) *ListyWEstimatedItemHeight is assumed for items not measured yet (default 46).
func (*ListyW) Group 实验性
func (w *ListyW) Group(key func(i int) string, title func(key string, count int)) *ListyWGroup groups items by key(i) (items with equal keys are gathered in order of first appearance) under headers built by title(key, count).
func (*ListyW) Height 实验性
func (w *ListyW) Height(px float32) *ListyWHeight fixes the viewport height; longer content scrolls.
func (*ListyW) ID 实验性
func (w *ListyW) ID() IDID returns the viewport's ID (after Show; 0 without Height).
func (*ListyW) ItemHeight 实验性
func (w *ListyW) ItemHeight(px float32) *ListyWItemHeight fixes every item's height (fast path; default: measured).
func (*ListyW) LoadMore 实验性
func (w *ListyW) LoadMore(hasMore, loading bool) *ListyWLoadMore adds a footer: a spinner while loading, "no more" when hasMore is false. EndReached reports when the user scrolled near it.
func (*ListyW) Offset 实验性
func (w *ListyW) Offset() float64Offset returns the scroll offset (0 without a viewport).
func (*ListyW) Range 实验性
func (w *ListyW) Range() (first, end int)Range returns the rows [first, end) built by Show (headers count as rows).
func (*ListyW) RowHoverable 实验性
func (w *ListyW) RowHoverable(on bool) *ListyWRowHoverable toggles the row hover background (default on).
func (*ListyW) RowKey 实验性
func (w *ListyW) RowKey(fn func(i int) any) *ListyWRowKey gives rows stable identities (default: the index).
func (*ListyW) ScrollTo 实验性
func (w *ListyW) ScrollTo(px float64) *ListyWScrollTo scrolls to a vertical pixel offset.
func (*ListyW) ScrollToGroup 实验性
func (w *ListyW) ScrollToGroup(group string, align string, offset float64) *ListyWScrollToGroup scrolls to a group header.
func (*ListyW) ScrollToKey 实验性
func (w *ListyW) ScrollToKey(key any, align string, offset float64) *ListyWScrollToKey scrolls to the item with key (RowKey) using align (AlignTop, AlignBottom or AlignAuto) plus offset pixels.
func (*ListyW) Show 实验性
func (w *ListyW) Show() *ListyWShow builds the list.
func (*ListyW) Split 实验性
func (w *ListyW) Split(on bool) *ListyWSplit toggles the row dividers (default on).
func (*ListyW) Sticky 实验性
func (w *ListyW) Sticky() *ListyWSticky pins the current group header to the top while scrolling.
func (*ListyW) Virtual 实验性
func (w *ListyW) Virtual() *ListyWVirtual builds only the visible rows (needs Height).
LoadingW 实验性
type LoadingW struct {
// contains filtered or unexported fields
}LoadingW covers a region or the window while loading.
func Loading 实验性
func Loading(c *Context, on bool) *LoadingWLoading starts a loading mask shown while on; chain options, then Body (cover a region) or Fullscreen (cover the window):
ui.Loading(c, busy).Text("加载中").Body(func() { ... })
ui.Loading(c, busy).Fullscreen()
ConfigProvider.Defaults("Spin", ...) "size" and "tip" apply.
func (*LoadingW) Background 实验性
func (m *LoadingW) Background(col theme.Color) *LoadingWBackground overrides the mask color.
func (*LoadingW) Body 实验性
func (m *LoadingW) Body(fn func()) *BoxBody builds the region and covers it while loading.
func (*LoadingW) Fullscreen 实验性
func (m *LoadingW) Fullscreen() *LoadingWFullscreen covers the whole window while loading.
func (*LoadingW) Size 实验性
func (m *LoadingW) Size(s ControlSize) *LoadingWSize sets the spinner size.
func (*LoadingW) Spinner 实验性
func (m *LoadingW) Spinner(ic *icon.Icon) *LoadingWSpinner replaces the indicator with a spinning icon (EP element-loading-spinner, antd indicator).
func (*LoadingW) Text 实验性
func (m *LoadingW) Text(s string) *LoadingWText shows a caption under the spinner (EP element-loading-text, antd Spin description).
func (*LoadingW) Tip 实验性
func (m *LoadingW) Tip(s string) *LoadingWTip shows a caption under the spinner.
Deprecated: use Text.
Locale
type Locale struct {
Code string // BCP 47 tag, e.g. "zh-CN"
Name string // native display name, e.g. "简体中文"
// Dir is the layout direction of the language; the zero value DirAuto
// infers it from Code (ar, he, fa ... and Arab / Hebr script tags are
// RTL). Not copied by FillLocale.
Dir Direction
// Common actions.
OK, Cancel, Close, Confirm, Back, Clear, Reset, Search, Save, Delete, Edit, Copy, Copied, More string
Expand, Collapse, SelectAll, Loading, Retry string
GotIt string // acknowledge-only button of an alert box ("知道了")
// Empty & lists.
NoData, NoMore, LoadMore, LoadFailed string
// Pagination.
TotalFmt, RangeTotalFmt, PageSizeFmt, PrevPage, NextPage, Prev5, Next5, JumpTo, PageSuffix string
// Form controls.
Placeholder, SelectPlaceholder, Required, NotFound string
LabelColon string // appended to form / description labels (":", ":")
SelectedFmt string // selection count, arg: n ("已选择 %d 项")
// Date & time.
Today, Now, SelectDate, SelectTime, SelectDateTime, StartDate, EndDate string
PrevYear, NextYear, PrevMonth, NextMonth string
RangeSeparator string // between the two ends of a range input ("至")
YearFmt string // year label, arg: year ("%d年")
MonthFmt string // month label, args: month number, Months entry ("%d月", "%[2]s")
YearMonthFmt string // panel title, args: year, month number, Months entry ("%d年%d月", "%[3]s %[1]d")
Weekdays [7]string // short names, Sunday first
Months [12]string // short names, January first
WeekStart time.Weekday // first column of month grids (zero value: Sunday)
// Table.
FilterConfirm, FilterReset, SortAsc, SortDesc, CancelSort, SelectionAll, SelectionInvert, ExpandRow, CollapseRow string
// Counts & search.
ItemUnit, ItemsUnit, Searching string
// Currency is the symbol or ISO 4217 code of money values (ProField /
// ProColumn money type) unless the field sets its own ("¥", "$", "NT$",
// "EUR"). See FormatMoney.
Currency string
// Feedback & navigation.
MessageBoxTitle, Info, Success, Warning, Error, BackTop, CollapseMenu, ExpandMenu, Fullscreen, ExitFullscreen string
PromptPlaceholder, PromptInvalid, CloseAll, Steps string
// Component groups.
Calendar CalendarLocale
Carousel CarouselLocale
Image ImageLocale
ColorPicker ColorPickerLocale
Tour TourLocale
QRCode QRCodeLocale
Table TableLocale
ProTable ProTableLocale
Transfer TransferLocale
Upload UploadLocale
Markdown MarkdownLocale
Form FormLocale
MarkdownEditor MarkdownEditorLocale
Command CommandLocale
A11y A11yLocale
Chart ChartLocale
Mobile MobileLocale
Graph GraphLocale
// Groups of the Pro / entry components added later.
DatePicker DatePickerLocale
TimePicker TimePickerLocale
Tabs TabsLocale
Pagination PaginationLocale
Slider SliderLocale
DropZone DropZoneLocale
EditableTable EditableTableLocale
PageContainer PageContainerLocale
ProCard ProCardLocale
StatisticCard StatisticCardLocale
ProField ProFieldLocale
ProDescriptions ProDescriptionsLocale
LightFilter LightFilterLocale
LoginForm LoginFormLocale
SettingDrawer SettingDrawerLocale
Dock DockLocale
// Groups of the data viewers (types in codeblock.go, jsonview.go,
// logview.go).
CodeBlock CodeBlockLocale
JSONView JSONViewLocale
LogView LogViewLocale
// Workbench shell (locale_shell.go).
StatusBar StatusBarLocale
TitleBar TitleBarLocale
NotificationCenter NotificationCenterLocale
HotkeyInput HotkeyInputLocale
Chat ChatLocale // AI chat components (chat_locale.go)
// Extra holds texts of other components by key ("MyWidget.title", ...).
Extra map[string]string
// contains filtered or unexported fields
}Locale holds the built-in texts of every component. Components read it with c.Locale() while building, so wrapping a page in ConfigProvider(c).Locale(ui.EnUS) switches all of them at once.
Component code never writes interface text literally: every label, placeholder, tooltip and accessible name comes from here (see AUTHORING.md section 15). The built-in packs are ZhCN (default), EnUS, ZhTW and Ja (locale_packs.go).
Texts with a number use fmt verbs (TotalFmt "共 %d 条"); call the helper methods (Total, PageSizeLabel, YearMonth ...) instead of formatting by hand. A format may ignore trailing arguments or pick them with explicit indexes ("%[3]s %[1]d"), the helpers tolerate both. Texts of a single component are grouped in a nested struct (l.Image.ZoomIn, l.Tour.Next); texts of third-party components go to Extra and are read with Locale.T(key, fallback).
只有部分成员是稳定的:未标「实验性」的方法和下列以外的字段受兼容性承诺约束。
实验性 实验性成员:Calendar、Carousel、Image、ColorPicker、Tour、QRCode、ProTable、Transfer、Upload、Markdown、MarkdownEditor、Command、Chart、Mobile、Graph、DropZone、EditableTable、PageContainer、ProCard、StatisticCard、ProField、ProDescriptions、LightFilter、LoginForm、SettingDrawer、Dock、CodeBlock、JSONView、LogView、StatusBar、TitleBar、NotificationCenter、HotkeyInput、Chat
func LocaleByCode
func LocaleByCode(code string) (*Locale, bool)LocaleByCode looks up a registered locale ("zh-CN", "en_us", "en", "zh_TW.UTF-8"). Chinese is matched by script: zh-Hant, zh-TW, zh-HK and zh-MO find zh-TW (ZhTW), other zh tags find zh-CN; the two never stand in for each other. Otherwise a tag matches the same language without regard to region ("ja" → ja-JP, "en-GB" → en-US); the language-only entry wins, then the first registered region in code order.
func Locales
func Locales() []*LocaleLocales lists the registered locales sorted by code.
func (*Locale) Date
func (l *Locale) Date(y, m, d int) stringDate formats the full date of a calendar cell ("2026年11月12日" / "Nov 12, 2026").
func (*Locale) Digit
func (l *Locale) Digit(n, total int) stringDigit names cell n of a total-cell one-time code ("第 1 位,共 6 位").
func (*Locale) IsRTL
func (l *Locale) IsRTL() boolIsRTL reports whether the locale lays out right to left: Dir when set, else inferred from Code.
func (*Locale) Items
func (l *Locale) Items(n int) stringItems formats a count with the item unit ("3 项" / "3 items").
func (*Locale) Month
func (l *Locale) Month(m int) stringMonth formats a month label, m in 1-12 ("11月" / "Nov").
func (*Locale) Page
func (l *Locale) Page(n int) stringPage formats the accessible name of a pagination item ("第 3 页").
func (*Locale) PageSizeLabel
func (l *Locale) PageSizeLabel(n int) stringPageSizeLabel formats the page size option ("10 条/页").
func (*Locale) RangeTotal
func (l *Locale) RangeTotal(from, to, total int) stringRangeTotal formats "第 1-10 条/共 85 条".
func (*Locale) Rating
func (l *Locale) Rating(v float64, count int) stringRating formats a rate value ("3.5 星,共 5 星").
func (*Locale) RemoveItem
func (l *Locale) RemoveItem(label string) stringRemoveItem names the remove button of a tag or file ("移除 标签").
func (*Locale) Selected
func (l *Locale) Selected(n int) stringSelected formats the selection count ("已选择 3 项").
func (*Locale) Slide
func (l *Locale) Slide(n, total int) stringSlide formats a carousel slide position ("第 2 张,共 5 张").
func (*Locale) T
func (l *Locale) T(key, fallback string) stringT returns Extra[key] or fallback.
func (*Locale) Total
func (l *Locale) Total(n int) stringTotal formats the pagination total ("共 85 条").
func (*Locale) WeekdayNames
func (l *Locale) WeekdayNames() []stringWeekdayNames returns the short weekday names starting at WeekStart, in the column order of month grids.
func (*Locale) WithColon
func (l *Locale) WithColon(label string) stringWithColon appends LabelColon to a non-empty label.
func (*Locale) Year
func (l *Locale) Year(y int) stringYear formats a year label ("2026年" / "2026").
func (*Locale) YearMonth
func (l *Locale) YearMonth(y, m int) stringYearMonth formats a month title ("2026年11月" / "Nov 2026").
LogBuffer 实验性
type LogBuffer struct {
// contains filtered or unexported fields
}LogBuffer holds log lines for LogView: escape sequences are parsed and levels detected once, when a line is added. It is safe for concurrent use: a goroutine reading a process's output can Write to it while the UI thread shows it (call the OnChange function to wake the UI).
With a line limit the oldest lines are dropped as new ones arrive.
func NewLogBuffer 实验性
func NewLogBuffer(maxLines int) *LogBufferNewLogBuffer returns a buffer keeping at most maxLines lines (<= 0: no limit).
func (*LogBuffer) Append 实验性
func (b *LogBuffer) Append(lines ...string)Append adds lines (each may hold "\n", which splits it further).
func (*LogBuffer) AppendLevel 实验性
func (b *LogBuffer) AppendLevel(level LogLevel, lines ...string)AppendLevel adds lines with a known level (LogNone: detect it).
func (*LogBuffer) Clear 实验性
func (b *LogBuffer) Clear()Clear removes every line.
func (*LogBuffer) Flush 实验性
func (b *LogBuffer) Flush()Flush adds the unterminated tail of the written output as a line.
func (*LogBuffer) Len 实验性
func (b *LogBuffer) Len() intLen returns the number of lines.
func (*LogBuffer) Level 实验性
func (b *LogBuffer) Level(i int) LogLevelLevel returns the level of line i (inherited from the line above when the line has none of its own).
func (*LogBuffer) Line 实验性
func (b *LogBuffer) Line(i int) stringLine returns the plain text of line i (0 is the oldest kept line).
func (*LogBuffer) OnChange 实验性
func (b *LogBuffer) OnChange(fn func())OnChange sets a function called (outside the buffer's lock, from the goroutine that added lines) after lines are added or the buffer is cleared; pass a Context.Invalidator to repaint the view.
func (*LogBuffer) SetDetector 实验性
func (b *LogBuffer) SetDetector(fn func(line string) LogLevel)SetDetector replaces the level detector (default DetectLogLevel). It applies to lines added afterwards.
func (*LogBuffer) Write 实验性
func (b *LogBuffer) Write(p []byte) (int, error)Write appends p as output: complete lines are added, an unterminated tail waits for the next Write (or Flush). It implements io.Writer.
LogLevel 实验性
type LogLevel uint8LogLevel is the severity of a log line. LogView filters by a minimum level; lines whose level is unknown (LogNone) always pass.
const (
LogNone LogLevel = iota
LogTrace
LogDebug
LogInfo
LogWarn
LogError
)The levels, lowest first.
实验性
func DetectLogLevel 实验性
func DetectLogLevel(line string) LogLevelDetectLogLevel finds a level word near the start of a line, within the first 120 bytes and not part of a longer word: TRACE, DEBUG, INFO, WARN, WARNING, ERROR, FATAL, PANIC, CRITICAL, SEVERE in any case, and the upper-case abbreviations TRC, DBG, INF, WRN, ERR, CRIT.
LogViewLocale 实验性
type LogViewLocale struct {
Name string // accessible name of the log area
Search string // search box placeholder
PrevMatch, NextMatch string
MatchFmt string // current match and count, args: i, n ("%d/%d")
NoMatch string
Wrap string
Follow string // keep showing the newest lines
Level string // level filter
AllLevels string
Levels [5]string // Trace, Debug, Info, Warn, Error
LinesFmt string // line count, arg: n ("%d 行")
// contains filtered or unexported fields
}LogViewLocale holds the LogView toolbar texts.
func (*LogViewLocale) Lines 实验性
func (l *LogViewLocale) Lines(n int) stringLines formats a line count.
func (*LogViewLocale) Match 实验性
func (l *LogViewLocale) Match(i, n int) stringMatch formats the match position ("3/120").
LogViewW 实验性
type LogViewW struct {
// contains filtered or unexported fields
}LogViewW shows a LogBuffer: millions of lines scroll smoothly (only the visible rows are shaped), ANSI colors and attributes are drawn, new lines keep the view at the bottom until the user scrolls up (scrolling back to the bottom follows again), and the toolbar searches (Enter / Shift+Enter or the arrows move between matches), filters by minimum level, toggles soft wrapping and following, and clears the buffer. Text is selectable and copies with Cmd/Ctrl+C.
func LogView 实验性
func LogView(c *Context, buf *LogBuffer, opts ...layout.Option) *LogViewWLogView adds a log viewer over buf.
logs := ui.NewLogBuffer(1_000_000) // keep the newest million lines
go cmd.Stdout.CopyTo(logs) // Write is goroutine-safe
ui.LogView(c, logs).Height(400)
func (*LogViewW) A11yLabel 实验性
func (w *LogViewW) A11yLabel(s string) *LogViewWA11yLabel sets the accessible name of the log area.
func (*LogViewW) Follow 实验性
func (w *LogViewW) Follow(on *bool) *LogViewWFollow binds following the newest lines to *on.
func (*LogViewW) Height 实验性
func (w *LogViewW) Height(px float32) *LogViewWHeight fixes the viewer's height (toolbar included). Without it the viewer grows in its parent (give the parent a height).
func (*LogViewW) ID 实验性
func (w *LogViewW) ID() IDID returns the viewer's ID.
func (*LogViewW) Layout 实验性
func (w *LogViewW) Layout(opts ...layout.Option) *LogViewWLayout applies layout options to the viewer.
func (*LogViewW) LineNumbers 实验性
func (w *LogViewW) LineNumbers(on bool) *LogViewWLineNumbers shows line numbers (counting dropped lines, so a line keeps its number).
func (*LogViewW) Matches 实验性
func (w *LogViewW) Matches() intMatches returns the number of search matches found so far.
func (*LogViewW) MinLevel 实验性
func (w *LogViewW) MinLevel(lv *LogLevel) *LogViewWMinLevel binds the level filter to *lv: lines below it are hidden (LogNone shows everything; lines without a level always show).
func (*LogViewW) NoLevelColors 实验性
func (w *LogViewW) NoLevelColors() *LogViewWNoLevelColors draws warn / error / debug lines in the plain text color.
func (*LogViewW) NoToolbar 实验性
func (w *LogViewW) NoToolbar() *LogViewWNoToolbar hides the toolbar (bind Query / MinLevel / Wrap / Follow to drive the view from elsewhere).
func (*LogViewW) Query 实验性
func (w *LogViewW) Query(q *string) *LogViewWQuery binds the search text to *q (case-insensitive).
func (*LogViewW) Selection 实验性
func (w *LogViewW) Selection() stringSelection returns the selected text ("" if none).
func (*LogViewW) Wrap 实验性
func (w *LogViewW) Wrap(on *bool) *LogViewWWrap binds soft wrapping to *on.
LoginFormLocale 实验性
type LoginFormLocale struct {
AccountTab, MobileTab string
Username, UsernameRequired string
Password, PasswordRequired string
Mobile, MobileRequired string
MobileInvalid string
Captcha, CaptchaRequired string
GetCode string
ResendFmt string // code button while counting down, arg: seconds ("%d 秒后重新获取")
CodeSentFmt string // announcement after sending, arg: seconds
CodeReady string // announcement when the countdown ends
Remember, Forgot string
Submit string
Others string // title of the other-methods row
// contains filtered or unexported fields
}LoginFormLocale holds the LoginForm / LoginFormPage texts.
LoginFormW 实验性
type LoginFormW struct {
// contains filtered or unexported fields
}LoginFormW is a login form (Ant Design Pro LoginForm): logo, title and subtitle, account / mobile tabs, a verification code button with a countdown, "remember me", a forgot-password link, a slot for other login methods and a submit button with a loading state.
OnFinish receives ProValues with the keys loginType ("account" or "mobile"), username, password, mobile, captcha and autoLogin (bool).
ui.LoginForm(c).Title("Tango").SubTitle("...").
OnSendCode(func(mobile string, done func(error)) { go sms(mobile, done) }).
OnFinish(func(v ui.ProValues, done func(error)) { go login(v, done) }).
Show()
func LoginForm 实验性
func LoginForm(c *Context) *LoginFormWLoginForm starts a login form; chain options, then Show.
func LoginFormPage 实验性
func LoginFormPage(c *Context) *LoginFormWLoginFormPage is LoginForm on a full page with a background color or image and an optional side area (Ant Design Pro LoginFormPage).
func (*LoginFormW) AccountOnly 实验性
func (w *LoginFormW) AccountOnly() *LoginFormWAccountOnly hides the tabs and the mobile login.
func (*LoginFormW) Actions 实验性
func (w *LoginFormW) Actions(fn func()) *LoginFormWActions builds the other login methods (icons) under the form, in a group named "Other login methods". Icon-only buttons have no visible text: give each one an accessible name, e.g. ui.Button(c, "").Icon(icon.Wechat).Circle().A11yLabel("WeChat").
func (*LoginFormW) Background 实验性
func (w *LoginFormW) Background(col theme.Color) *LoginFormWBackground sets the page background color (LoginFormPage).
func (*LoginFormW) BackgroundImage 实验性
func (w *LoginFormW) BackgroundImage(img image.Image) *LoginFormWBackgroundImage sets the page background image, scaled to cover (LoginFormPage).
func (*LoginFormW) CodeInterval 实验性
func (w *LoginFormW) CodeInterval(sec int) *LoginFormWCodeInterval sets the countdown in seconds (default 60).
func (*LoginFormW) CodeSent 实验性
func (w *LoginFormW) CodeSent() boolCodeSent reports that a verification code was sent in the last Show.
func (*LoginFormW) Countdown 实验性
func (w *LoginFormW) Countdown() intCountdown returns the seconds left before a new code can be sent.
func (*LoginFormW) Err 实验性
func (w *LoginFormW) Err() errorErr returns the last OnFinish or OnSendCode error.
func (*LoginFormW) Finished 实验性
func (w *LoginFormW) Finished() boolFinished reports a completed login (OnFinish called done(nil)), once.
func (*LoginFormW) ForgotClicked 实验性
func (w *LoginFormW) ForgotClicked() boolForgotClicked reports a click on the forgot-password link.
func (*LoginFormW) ID 实验性
func (w *LoginFormW) ID() IDID returns the widget ID (valid after Show).
func (*LoginFormW) LoginType 实验性
func (w *LoginFormW) LoginType() stringLoginType returns the active tab (LoginAccount or LoginMobile).
func (*LoginFormW) Logo 实验性
func (w *LoginFormW) Logo(fn func()) *LoginFormWLogo builds the logo left of the title.
func (*LoginFormW) MobileOnly 实验性
func (w *LoginFormW) MobileOnly() *LoginFormWMobileOnly hides the tabs and the account login.
func (*LoginFormW) MobilePattern 实验性
func (w *LoginFormW) MobilePattern(re string) *LoginFormWMobilePattern replaces the mobile number pattern (default: 11 digits starting with 1).
func (*LoginFormW) OnFinish 实验性
func (w *LoginFormW) OnFinish(fn func(v ProValues, done func(error))) *LoginFormWOnFinish receives the values after validation; call done from any goroutine. The submit button spins meanwhile and an error is shown above the form.
func (*LoginFormW) OnForgot 实验性
func (w *LoginFormW) OnForgot(fn func()) *LoginFormWOnForgot shows the forgot-password link and calls fn on click.
func (*LoginFormW) OnSendCode 实验性
func (w *LoginFormW) OnSendCode(fn func(mobile string, done func(error))) *LoginFormWOnSendCode is called by the "get code" button with a valid mobile number; call done from any goroutine. A nil error starts the countdown.
func (*LoginFormW) Placement 实验性
func (w *LoginFormW) Placement(s string) *LoginFormWPlacement puts the form card "left", "center" or "right" (default) of the page (LoginFormPage).
func (*LoginFormW) Show 实验性
func (w *LoginFormW) Show() *LoginFormWShow builds the form (or the page).
func (*LoginFormW) Side 实验性
func (w *LoginFormW) Side(fn func()) *LoginFormWSide builds content beside the form card (LoginFormPage), such as an activity banner.
func (*LoginFormW) SubTitle 实验性
func (w *LoginFormW) SubTitle(s string) *LoginFormWSubTitle sets the line under the title.
func (*LoginFormW) Submit 实验性
func (w *LoginFormW) Submit()Submit validates and submits the form.
func (*LoginFormW) SubmitText 实验性
func (w *LoginFormW) SubmitText(s string) *LoginFormWSubmitText sets the submit button's text.
func (*LoginFormW) Submitting 实验性
func (w *LoginFormW) Submitting() boolSubmitting reports validation or OnFinish in progress.
func (*LoginFormW) Title 实验性
func (w *LoginFormW) Title(s string) *LoginFormWTitle sets the title.
func (*LoginFormW) Values 实验性
func (w *LoginFormW) Values() ProValuesValues returns the form values (see OnFinish).
func (*LoginFormW) Width 实验性
func (w *LoginFormW) Width(px float32) *LoginFormWWidth sets the form width (default 328).
MarkdownEditorLocale 实验性
type MarkdownEditorLocale struct {
Placeholder string
Heading, Bold, Italic, Strike, Code, Link, Quote string
BulletList, OrderedList, Task, CodeBlock, Table, Divider string
BoldSample, ItalicSample, StrikeSample, LinkSample, TableColumnFmt string // TableColumnFmt arg: column number
Edit, Split, Preview string
// contains filtered or unexported fields
}MarkdownEditorLocale holds the MarkdownEditor toolbar, samples inserted by the toolbar and the view mode switch.
MarkdownEditorW 实验性
type MarkdownEditorW struct {
// contains filtered or unexported fields
}MarkdownEditorW is a Markdown editor bound to *src.
func MarkdownEditor 实验性
func MarkdownEditor(c *Context, src *string) *MarkdownEditorWMarkdownEditor adds an editor for *src (default 400px high, split view).
ui.MarkdownEditor(c, &doc).Height(480)
func (*MarkdownEditorW) Changed 实验性
func (w *MarkdownEditorW) Changed() boolChanged reports an edit this frame (typing, toolbar, task toggles).
func (*MarkdownEditorW) ClickedLink 实验性
func (w *MarkdownEditorW) ClickedLink() stringClickedLink returns a link clicked in the preview this frame.
func (*MarkdownEditorW) CurrentMode 实验性
func (w *MarkdownEditorW) CurrentMode() stringCurrentMode returns the active view.
func (*MarkdownEditorW) Height 实验性
func (w *MarkdownEditorW) Height(px float32) *MarkdownEditorWHeight sets the total height (toolbar included).
func (*MarkdownEditorW) Layout 实验性
func (w *MarkdownEditorW) Layout(opts ...layout.Option) *MarkdownEditorWLayout applies layout options to the outer frame.
func (*MarkdownEditorW) Mode 实验性
func (w *MarkdownEditorW) Mode(m string) *MarkdownEditorWMode sets the initial view: "edit", "split" or "preview". The toolbar switches it afterwards.
func (*MarkdownEditorW) Placeholder 实验性
func (w *MarkdownEditorW) Placeholder(s string) *MarkdownEditorWPlaceholder sets the empty-editor hint.
MarkdownImage 实验性
type MarkdownImage struct {
Src, Alt string
Width, Height float32
}MarkdownImage describes a Markdown or HTML image. Width and Height are positive HTML pixel dimensions, or zero when unspecified.
MarkdownListStyle 实验性
type MarkdownListStyle struct {
Indent float32 // logical pixels before item text, including the marker
ItemGap float32 // logical pixels between items at the same depth
Bullet string // optional marker text, reused at each depth
}MarkdownListStyle controls Markdown list spacing and unordered markers.
MarkdownLocale 实验性
type MarkdownLocale struct {
ImagePrefix string // shown before the alt text of an image ("[图片] ")
CopyCode string
Copied string
// contains filtered or unexported fields
}MarkdownLocale holds the Markdown viewer texts.
MarkdownW 实验性
type MarkdownW struct {
// contains filtered or unexported fields
}MarkdownW renders a Markdown document.
func Markdown 实验性
func Markdown(c *Context, src string, opts ...layout.Option) *MarkdownWMarkdown adds a rendered Markdown document; it grows to its content (put it in a Scroll for long documents).
md := ui.Markdown(c, src)
if u := md.ClickedLink(); u != "" { openURL(u) }
func (*MarkdownW) BodyLineHeight 实验性
func (m *MarkdownW) BodyLineHeight(px float32) *MarkdownWBodyLineHeight sets the line height in logical pixels for prose, list items and table cells. Zero uses the theme line height.
func (*MarkdownW) ClickedLink 实验性
func (m *MarkdownW) ClickedLink() stringClickedLink returns the URL of a link clicked this frame ("" if none).
func (*MarkdownW) CodeBackground 实验性
func (m *MarkdownW) CodeBackground(color theme.Color) *MarkdownWCodeBackground overrides the theme's code block background. A transparent color makes the block background transparent.
func (*MarkdownW) CodeBorder 实验性
func (m *MarkdownW) CodeBorder(color theme.Color) *MarkdownWCodeBorder overrides the code block's border color. A transparent color hides the border.
func (*MarkdownW) CodeHeader 实验性
func (m *MarkdownW) CodeHeader(style CodeHeaderStyle) *MarkdownWCodeHeader styles the header of fenced code blocks. CodeLanguage and CopyCode still control whether the language and copy button are shown.
func (*MarkdownW) CodeLanguage 实验性
func (m *MarkdownW) CodeLanguage(on bool) *MarkdownWCodeLanguage controls whether fenced code blocks display their language label (default true). Syntax highlighting and copy controls are independent.
func (*MarkdownW) CodeLineHeight 实验性
func (m *MarkdownW) CodeLineHeight(px float32) *MarkdownWCodeLineHeight sets the line height of fenced code in logical pixels. Zero uses the theme line height for the code font size.
func (*MarkdownW) CodeSize 实验性
func (m *MarkdownW) CodeSize(px float32) *MarkdownWCodeSize sets the code block font size in logical pixels. Use 0 for the default (body size minus one).
func (*MarkdownW) Color 实验性
func (m *MarkdownW) Color(col theme.Color) *MarkdownWColor sets the color of body text and headings (default theme Text and TextHeading), for documents on a colored background such as a chat bubble.
func (*MarkdownW) ContentWidth 实验性
func (m *MarkdownW) ContentWidth(px float32) *MarkdownWContentWidth caps the width of the document box, including its layout padding, in logical pixels. Use a positive maximum.
func (*MarkdownW) CopyCode 实验性
func (m *MarkdownW) CopyCode(on bool) *MarkdownWCopyCode controls whether fenced code blocks show a copy button (default true).
func (*MarkdownW) HeadingBlock 实验性
func (m *MarkdownW) HeadingBlock(id string) (int, bool)HeadingBlock returns the zero-based top-level block containing a heading. It accepts a heading ID or a URL fragment with a leading #. IDs are based on the heading's inline text: lowercase letters, marks, numbers, hyphens and underscores are kept, spaces become hyphens and other characters are removed. Duplicate IDs receive numeric suffixes in document order.
func (*MarkdownW) HeadingRules 实验性
func (m *MarkdownW) HeadingRules(levels ...int) *MarkdownWHeadingRules draws a bottom rule under the specified heading levels (1–6). With no levels, it removes the theme's heading rules.
func (*MarkdownW) HeadingSize 实验性
func (m *MarkdownW) HeadingSize(level int, px float32) *MarkdownWHeadingSize sets a heading level's font size in logical pixels. Use 0 for the theme default.
func (*MarkdownW) Highlighter 实验性
func (m *MarkdownW) Highlighter(h CodeHighlighter) *MarkdownWHighlighter sets the code highlighter of fenced code blocks with a language (default DefaultCodeHighlighter; nil: plain text).
func (*MarkdownW) ImageMaxSize 实验性
func (m *MarkdownW) ImageMaxSize(width, height float32) *MarkdownWImageMaxSize caps both standalone and inline images, keeping their aspect ratio. A non-positive dimension leaves that axis unconstrained.
func (*MarkdownW) Images 实验性
func (m *MarkdownW) Images(load func(src string) image.Image) *MarkdownWImages supplies decoded images by source. Return nil to show the image fallback. Use ResolveImage to receive the alt text and size as well.
func (*MarkdownW) ListStyle 实验性
func (m *MarkdownW) ListStyle(style MarkdownListStyle) *MarkdownWListStyle overrides the default list spacing and unordered markers.
func (*MarkdownW) NoCopy 实验性
func (m *MarkdownW) NoCopy() *MarkdownWNoCopy hides the copy button of code blocks.
func (*MarkdownW) NoSelect 实验性
func (m *MarkdownW) NoSelect() *MarkdownWNoSelect makes the text non-selectable (selection and Cmd/Ctrl+C copy are on by default).
func (*MarkdownW) QuoteBorder 实验性
func (m *MarkdownW) QuoteBorder(color theme.Color) *MarkdownWQuoteBorder overrides the quote's leading border color. A transparent color hides the border while preserving the quote's inset.
func (*MarkdownW) ReadOnlyTasks 实验性
func (m *MarkdownW) ReadOnlyTasks(on bool) *MarkdownWReadOnlyTasks disables task toggling while retaining the checkboxes and their checked state in the accessibility tree.
func (*MarkdownW) ResolveImage 实验性
func (m *MarkdownW) ResolveImage(load func(MarkdownImage) image.Image) *MarkdownWResolveImage supplies decoded images for inline and reference-style Markdown images and HTML img tags. It takes precedence over Images. Return nil to show the image fallback.
func (*MarkdownW) ScrollToBlock 实验性
func (m *MarkdownW) ScrollToBlock(block int) boolScrollToBlock queues a jump to the zero-based top-level block in a Virtual Markdown viewport. It aligns the block near the top, within the scroll bounds. It returns false for a non-virtual document or an invalid index.
func (*MarkdownW) ScrollToHeading 实验性
func (m *MarkdownW) ScrollToHeading(id string) boolScrollToHeading queues a jump to the heading's containing block in a Virtual Markdown viewport and reports whether the fragment was found. It returns false for a non-virtual document or an unknown heading.
func (*MarkdownW) Size 实验性
func (m *MarkdownW) Size(px float32) *MarkdownWSize sets the body font size (default theme FontSize).
func (*MarkdownW) TaskToggled 实验性
func (m *MarkdownW) TaskToggled() (int, bool)TaskToggled reports a click on a task-list checkbox: its index in document order. Apply it with src = ui.ToggleMarkdownTask(src, i).
func (*MarkdownW) Virtual 实验性
func (m *MarkdownW) Virtual() *MarkdownWVirtual makes Markdown a scroll viewport and builds only visible top-level blocks, with overscan. Give it a bounded height through the layout options and use it in place of an enclosing vertical Scroll.
MasonryW 实验性
type MasonryW struct {
// contains filtered or unexported fields
}MasonryW is a masonry (waterfall) layout. Configure it and call Show.
func Masonry 实验性
func Masonry(c *Context, n int, render func(i int)) *MasonryWMasonry lays out n items built by render(i) in columns, each item going to the shortest column so far.
ui.Masonry(c, len(cards), func(i int) { card(i) }).Columns(4).Gutter(16).Show()
func (*MasonryW) Assignment 实验性
func (w *MasonryW) Assignment() []intAssignment returns the column of every item (after Show).
func (*MasonryW) Built 实验性
func (w *MasonryW) Built() intBuilt returns how many items were built by Show (virtual mode builds only the visible ones).
func (*MasonryW) Columns 实验性
func (w *MasonryW) Columns(n int) *MasonryWColumns sets the column count (default 3).
func (*MasonryW) ColumnsAt 实验性
func (w *MasonryW) ColumnsAt(bp Breakpoint, n int) *MasonryWColumnsAt sets the column count from breakpoint bp upwards (Ant columns={{ xs: 1, sm: 2, md: 3 }}); the largest set breakpoint not above the window width wins, Columns is the fallback.
func (*MasonryW) EstimatedHeight 实验性
func (w *MasonryW) EstimatedHeight(px float32) *MasonryWEstimatedHeight is the height assumed for items not measured yet.
func (*MasonryW) Gutter 实验性
func (w *MasonryW) Gutter(px float32) *MasonryWGutter sets the horizontal and vertical spacing.
func (*MasonryW) Gutters 实验性
func (w *MasonryW) Gutters(h, v float32) *MasonryWGutters sets horizontal and vertical spacing separately.
func (*MasonryW) ID 实验性
func (w *MasonryW) ID() IDID returns the viewport's ID in virtual mode (after Show).
func (*MasonryW) ItemColumn 实验性
func (w *MasonryW) ItemColumn(fn func(i int) int) *MasonryWItemColumn pins items to a column (0-based; return -1 for automatic), so existing items keep their column when more are added.
func (*MasonryW) ItemHeight 实验性
func (w *MasonryW) ItemHeight(fn func(i int) float32) *MasonryWItemHeight gives known item heights (Ant item.height); items then get that fixed height. Without it heights are measured after the first paint (EstimatedHeight is used until then).
func (*MasonryW) ItemKey 实验性
func (w *MasonryW) ItemKey(fn func(i int) any) *MasonryWItemKey gives items stable identities (default: the index).
func (*MasonryW) LayoutChanged 实验性
func (w *MasonryW) LayoutChanged() boolLayoutChanged reports that Show placed some item in another column than the previous Show, or the item count changed (Ant onLayoutChange; read the columns with Assignment).
func (*MasonryW) Show 实验性
func (w *MasonryW) Show() *MasonryWShow builds the layout.
func (*MasonryW) Virtual 实验性
func (w *MasonryW) Virtual(height float32) *MasonryWVirtual scrolls the layout inside a viewport of the given height and builds only the items near it.
MentionsW 实验性
type MentionsW struct {
// contains filtered or unexported fields
}MentionsW is a multi-line input that suggests options after a trigger character such as '@'.
func Mentions 实验性
func Mentions(c *Context, val *string, opts []Option) *MentionsWMentions adds a mention input bound to *val with candidate opts.
func (*MentionsW) A11yLabel 实验性
func (w *MentionsW) A11yLabel(s string) *MentionsWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*MentionsW) AllowClear 实验性
func (w *MentionsW) AllowClear() *MentionsWAllowClear shows a clear button at the inline end of the first line while the input has text (Ant allowClear).
func (*MentionsW) Changed 实验性
func (w *MentionsW) Changed() boolChanged reports an edit this frame.
func (*MentionsW) Cleared 实验性
func (w *MentionsW) Cleared() boolCleared reports that the clear button emptied the input this frame.
func (*MentionsW) DataVersion 实验性
func (w *MentionsW) DataVersion(v int) *MentionsWDataVersion tells the mentions input that the options slice was modified in place (a virtual list caches its matches and label widths by slice identity, length and this number): after editing options of the same slice without changing its length, change v (or pass a new slice) so the matches and the list's width are recomputed on the next frame.
func (*MentionsW) Debounce 实验性
func (w *MentionsW) Debounce(d time.Duration) *MentionsWDebounce sets the delay before a Remote call.
func (*MentionsW) Disabled 实验性
func (w *MentionsW) Disabled(on bool) *MentionsWfunc (*MentionsW) IsOpen 实验性
func (w *MentionsW) IsOpen() boolIsOpen reports whether suggestions are shown.
func (*MentionsW) Layout 实验性
func (w *MentionsW) Layout(o ...layout.Option) *MentionsWfunc (*MentionsW) Loading 实验性
func (w *MentionsW) Loading(on bool) *MentionsWLoading shows a spinner and the loading text in the suggestions (in place of the options with Remote, or when there are none).
func (*MentionsW) Open 实验性
func (w *MentionsW) Open() *MentionsWOpen forces the suggestions open when a trigger is at the caret (tests, screenshots).
func (*MentionsW) Placeholder 实验性
func (w *MentionsW) Placeholder(s string) *MentionsWfunc (*MentionsW) Placement 实验性
func (w *MentionsW) Placement(p Placement) *MentionsWPlacement opens the suggestions below (BottomStart, default) or above (TopStart) the input (Ant placement "bottom" / "top", Element placement); ConfigProvider.Defaults("Mentions", "placement") takes "top" / "bottom".
func (*MentionsW) Prefix 实验性
func (w *MentionsW) Prefix(p ...string) *MentionsWPrefix sets the trigger characters (default "@").
func (*MentionsW) Query 实验性
func (w *MentionsW) Query() (prefix, query string, ok bool)Query returns the mention being typed at the caret: its trigger prefix and the text after it; ok is false when the caret is not in a mention. Read it after the build (or from a Remote callback) to drive suggestions yourself.
func (*MentionsW) Remote 实验性
func (w *MentionsW) Remote(fn func(prefix, query string)) *MentionsWRemote turns on server-side suggestions: after an edit at an active mention, fn receives its trigger prefix and the text typed after it once Debounce (300ms by default) has passed, on the UI thread. Start the request in the background, pass Loading(true) while it runs, then replace the options given to Mentions (shown as-is, not filtered by the query) and wake the window with Invalidate.
ui.Mentions(c, &msg, users).Remote(func(p, q string) { go lookup(p, q) }).Loading(busy)
func (*MentionsW) Rows 实验性
func (w *MentionsW) Rows(n int) *MentionsWfunc (*MentionsW) Selected 实验性
func (w *MentionsW) Selected() stringSelected returns the option value inserted this frame ("" if none).
func (*MentionsW) Size 实验性
func (w *MentionsW) Size(s ControlSize) *MentionsWfunc (*MentionsW) Split 实验性
func (w *MentionsW) Split(s string) *MentionsWSplit sets the text inserted after a picked mention (Ant split, default " "; Element split). "" inserts nothing.
func (*MentionsW) Status 实验性
func (w *MentionsW) Status(s string) *MentionsWfunc (*MentionsW) Variant 实验性
func (w *MentionsW) Variant(v FieldVariant) *MentionsWVariant sets the frame look (FieldOutlined by default).
func (*MentionsW) Virtual 实验性
func (w *MentionsW) Virtual(on bool) *MentionsWVirtual forces the virtual suggestion list on or off; by default lists longer than 100 suggestions are virtual (only the visible rows and the keyboard row are built; the list keeps the width, height and scroll range of the full list, but suggestions out of view are not in the accessibility tree). Labels, values and Disabled are always read live. A virtual list keeps which options match while the options slice (identity and length), the query and the DataVersion stay the same, and measures label widths once per slice, DataVersion and theme: an option renamed in place (same slice, same length) does not join or leave the matches, nor change the list's width, until the query, the slice or the DataVersion (or the theme pointer) changes. Virtual(false) builds every row.
func (*MentionsW) Whole 实验性
func (w *MentionsW) Whole() *MentionsWWhole makes Backspace delete a mention as one unit (Element whole): with the caret right after a mention ("@name", or "@name " as inserted by a pick), one Backspace removes the whole mention. A mention is a trigger prefix at the start of a word followed by non-space text; see WholeCheck to restrict which ones count.
func (*MentionsW) WholeCheck 实验性
func (w *MentionsW) WholeCheck(fn func(prefix, value string) bool) *MentionsWWholeCheck decides which mentions Whole deletes as a unit (Element check-is-whole): fn receives the trigger prefix and the text after it. Implies Whole.
ui.Mentions(c, &msg, users).WholeCheck(func(p, v string) bool { return known[v] })
func (*MentionsW) Width 实验性
func (w *MentionsW) Width(px float32) *MentionsWMenuItem
type MenuItem struct {
Key string
Label string
Icon *icon.Icon
Children []MenuItem
Disabled bool
Danger bool
Divider bool // render a separator instead of an item
// Group makes the entry a titled group of Children (Ant type="group",
// Element el-menu-item-group): Label is a non-clickable title and the
// children follow at the same level. Dropdowns and pop-out submenus
// show it as a titled section (shadcn: a DropdownMenuLabel set apart
// by separators); keyboard navigation skips the title.
Group bool
// Shortcut is the item's keyboard shortcut text ("Ctrl+C", "⌘K"),
// shown in a dimmer column at the item's inline end of Dropdown panels,
// Menu pop-out submenus and ContextMenuAt. It is display only (the app
// handles the key itself); the label stays the accessible name and the
// shortcut is exposed as the node's keyboard shortcut.
Shortcut string
// Radio marks a point context-menu leaf as a single-choice item. The
// caller owns the checked value and updates it when the item is chosen.
Radio *bool
}MenuItem is an entry of Menu / Dropdown.
func MenuPath 实验性
func MenuPath(items []MenuItem, key string) []MenuItemMenuPath returns the items from the root to the item with key (parent submenus first), or nil when key is not in items.
MenuMode
type MenuMode uint8MenuMode selects how Menu shows submenus.
Append-only: never reorder or insert; the zero value stays MenuInline.
const (
MenuInline MenuMode = iota // submenus expand in place (sider)
MenuVertical // submenus pop out to the right
MenuHorizontal // top bar, submenus drop down
)MenuW
type MenuW struct {
// contains filtered or unexported fields
}MenuW is a navigation menu: inline, vertical and horizontal modes, collapsed icon mode with pop-out submenus and tooltips, dark theme, accordion behavior and keyboard navigation.
Keyboard (the menu items are in the Tab order): Up/Down move between visible items; in inline mode Right opens a submenu (again: enters it) and Left closes it or returns to the parent; in vertical / collapsed mode Right or Enter opens the pop-out submenu and moves into it; in horizontal mode Left/Right move along the bar and Down or Enter opens the dropdown. Enter/Space choose a leaf and Escape closes a pop-out submenu.
func Menu
func Menu(c *Context, items []MenuItem, selected *string) *MenuWMenu starts a menu bound to the selected key; chain options, then Show.
ConfigProvider.Defaults("Menu", ...) keys: "mode" (MenuMode), "theme" ("dark" | "light"), "accordion", "inlineCollapsed", "selectable", "tooltip", "ellipsis" (bool), "inlineIndent" (float32 px), "subMenuOpenDelay" / "subMenuCloseDelay" (time.Duration; default the Menu token: Ant 100 / 100 ms, Element 300 / 300 ms, shadcn 200 / 150 ms), "triggerSubMenuAction" ("hover" | "click").
func (*MenuW) Accordion
func (m *MenuW) Accordion() *MenuWAccordion keeps only one branch of inline submenus open (Element unique-opened).
func (*MenuW) Clicked
func (m *MenuW) Clicked() stringClicked returns the leaf key clicked this frame.
func (*MenuW) Collapsed
func (m *MenuW) Collapsed(on bool) *MenuWCollapsed shows icons only; submenus pop out on hover.
func (*MenuW) Dark
func (m *MenuW) Dark() *MenuWDark uses the dark sider colors (Ant theme="dark", Element's dark el-menu). Under shadcn/ui it is ignored by design: shadcn has a single Sidebar look built from the --sidebar-* variables, which already follow the light / dark theme (theme.Shadcn(theme.Dark()) gives the dark sidebar); a dark sidebar on a light shadcn page is not offered.
func (*MenuW) DefaultOpen
func (m *MenuW) DefaultOpen(keys ...string) *MenuWDefaultOpen opens inline submenus initially.
func (*MenuW) Ellipsis
func (m *MenuW) Ellipsis(on bool) *MenuWEllipsis(false) keeps every root item of a horizontal bar instead of folding the overflow into "…" (Element ellipsis).
func (*MenuW) ExpandIcon
func (m *MenuW) ExpandIcon(ic *icon.Icon) *MenuWExpandIcon replaces the submenu chevron (antd expandIcon).
func (*MenuW) InlineIndent
func (m *MenuW) InlineIndent(px float32) *MenuWInlineIndent sets the indent per inline level (antd inlineIndent 24, Element --el-menu-level-padding 20; default the Menu token).
func (*MenuW) ItemPanel
func (m *MenuW) ItemPanel(key string, fn func()) *MenuWItemPanel shows fn in the drop-down panel of the root item keyed key of a horizontal menu instead of its children (shadcn NavigationMenuContent): hovering or focusing the item opens the panel, Escape or leaving it closes it. The item gets a chevron like a submenu.
func (*MenuW) Mode
func (m *MenuW) Mode(md MenuMode) *MenuWMode selects inline (default), vertical or horizontal.
func (*MenuW) OpenChanged
func (m *MenuW) OpenChanged() boolOpenChanged reports that the user opened or closed an inline submenu this frame.
func (*MenuW) OpenKeys
func (m *MenuW) OpenKeys(keys *[]string) *MenuWOpenKeys binds the keys of the open inline submenus (antd openKeys / onOpenChange, Element default-openeds): the menu reads and writes *keys; OpenChanged reports a change. Keys that are not submenus of the menu are ignored.
func (*MenuW) OverflowedIndicator
func (m *MenuW) OverflowedIndicator(ic *icon.Icon) *MenuWOverflowedIndicator replaces the icon of the "…" item that collects the items a horizontal bar cannot fit (antd overflowedIndicator, Element ellipsis-icon).
func (*MenuW) Selectable
func (m *MenuW) Selectable(on bool) *MenuWSelectable(false) leaves the selected key alone when a leaf is clicked (antd selectable; Clicked still reports it).
func (*MenuW) Show
func (m *MenuW) Show() *MenuWShow builds the menu.
func (*MenuW) SubMenuCloseDelay
func (m *MenuW) SubMenuCloseDelay(d time.Duration) *MenuWSubMenuCloseDelay waits d before a pop-out submenu closes once the pointer left it (antd subMenuCloseDelay, Element hide-timeout).
func (*MenuW) SubMenuOpenDelay
func (m *MenuW) SubMenuOpenDelay(d time.Duration) *MenuWSubMenuOpenDelay waits d before a hovered pop-out submenu opens (antd subMenuOpenDelay, Element show-timeout).
func (*MenuW) Tooltip
func (m *MenuW) Tooltip(on bool) *MenuWTooltip(false) turns off the tooltip of a collapsed menu's root items (antd tooltip={false}).
func (*MenuW) TriggerSubMenuAction
func (m *MenuW) TriggerSubMenuAction(t Trigger) *MenuWTriggerSubMenuAction selects how pop-out submenus open: TriggerHover (default) or TriggerClick (antd triggerSubMenuAction, Element menu-trigger); a click popup stays until a choice, Escape or a press outside.
func (*MenuW) Width
func (m *MenuW) Width(px float32) *MenuWWidth sets the expanded width (default: fill).
MenubarItem 实验性
type MenubarItem struct {
Key string
Label string
Icon *icon.Icon
Shortcut string // display only, like MenuItem.Shortcut
Disabled bool
Danger bool
Divider bool // a separator instead of an item
// Group makes the entry a titled group of Children shown inline (a
// radio group under a label, for example), like MenuItem.Group.
Group bool
Kind MenubarItemKind
// Checked is the value a checkbox item shows and toggles.
Checked *bool
// Radio is the value of the radio group the item belongs to: the item
// is checked when *Radio equals Value (Key when Value is empty) and
// choosing it stores that value.
Radio *string
Value string
// Children open as a submenu (or, with Group, form the group).
Children []MenubarItem
}MenubarItem is an entry of a Menubar menu. Key identifies the item (Label is used when Key is empty) and must be unique within its menu.
MenubarItemKind 实验性
type MenubarItemKind stringMenubarItemKind is the behaviour of a Menubar item. Open set: new kinds are added as new constants.
const (
MenubarItemNormal MenubarItemKind = "" // runs a command
MenubarItemCheckbox MenubarItemKind = "checkbox" // toggles *Checked
MenubarItemRadio MenubarItemKind = "radio" // sets *Radio to its value
)实验性
MenubarMenu 实验性
type MenubarMenu struct {
Key string // identifies the menu (Label when empty)
Label string
Disabled bool
Items []MenubarItem
}MenubarMenu is a top-level menu of a Menubar ("File", "Edit" …).
MenubarW 实验性
type MenubarW struct {
// contains filtered or unexported fields
}MenubarW is an application menu bar inside the window (shadcn/ui Menubar; the menu bar of desktop applications): a row of top-level menus that open drop-down panels (the Dropdown panels) on click, or with Alt / F10 and the arrow keys.
func Menubar 实验性
func Menubar(c *Context, menus []MenubarMenu) *MenubarWMenubar adds a menu bar with the given top-level menus:
mb := ui.Menubar(c, []ui.MenubarMenu{
{Label: "文件", Items: []ui.MenubarItem{{Key: "new", Label: "新建", Shortcut: "Ctrl+N"}}},
{Label: "视图", Items: []ui.MenubarItem{{Label: "状态栏", Kind: ui.MenubarItemCheckbox, Checked: &status}}},
})
switch mb.Clicked() { case "new": ... }
A click on a trigger opens its menu; while a menu is open, moving the pointer onto another trigger switches to it. Alt (pressed and released alone) or F10 moves focus to the bar and back. Keyboard: Left/Right move between the menus (mirrored in RTL), Down/Enter/Space open one, Up/Down move in it, Right/Left open and close submenus, or at the edge switch to the neighbouring menu, Enter chooses, Escape closes, a letter jumps to the next item starting with it.
func (*MenubarW) A11yLabel 实验性
func (m *MenubarW) A11yLabel(s string) *MenubarWA11yLabel names the bar for assistive technology.
func (*MenubarW) Changed 实验性
func (m *MenubarW) Changed() boolChanged reports that a checkbox or radio item changed its value this frame.
func (*MenubarW) Clicked 实验性
func (m *MenubarW) Clicked() stringClicked returns the key of the item chosen this frame ("" if none). Checkbox and radio items have already updated their bound value.
func (*MenubarW) ID 实验性
func (m *MenubarW) ID() IDID returns the bar's ID.
func (*MenubarW) OpenMenu 实验性
func (m *MenubarW) OpenMenu() stringOpenMenu returns the key of the open menu ("" when all are closed).
MessagePlacement
type MessagePlacement stringMessagePlacement is where Message toasts appear. The start / end placements are logical: in RTL the end is the left side. The zero value is the design system's default (top center; shadcn/ui: the bottom end corner, as Sonner).
const (
MessageTop MessagePlacement = "top"
MessageTopStart MessagePlacement = "top-start"
MessageTopEnd MessagePlacement = "top-end"
MessageBottom MessagePlacement = "bottom"
MessageBottomStart MessagePlacement = "bottom-start"
MessageBottomEnd MessagePlacement = "bottom-end"
)MessageRef
type MessageRef struct {
// contains filtered or unexported fields
}MessageRef configures a message opened by Message. Use it in the same call chain; it does not need to be kept.
func Message
func Message(c *Context, status, content string) *MessageRefMessage shows a global toast at the top of the window and returns a reference for further options. status: success, info, warning, error, loading.
ui.Message(c, "loading", "保存中…").Key("save").Duration(0)
ui.Message(c, "success", "已保存").Key("save") // replaces the loading one
func (*MessageRef) Duration
func (r *MessageRef) Duration(d time.Duration) *MessageRefDuration sets how long the message stays; d <= 0 keeps it until MessageDestroy or an update with a positive duration.
func (*MessageRef) Grouping
func (r *MessageRef) Grouping() *MessageRefGrouping merges this message into a visible one with the same content and placement: that one restarts its timer, takes the new options and shows a repeat counter (EP grouping / repeatNum). The merge happens when the message is first shown, so the options chained after Grouping apply.
func (*MessageRef) Icon
func (r *MessageRef) Icon(ic *icon.Icon) *MessageRefIcon replaces the status icon (antd icon).
func (*MessageRef) Key
func (r *MessageRef) Key(key string) *MessageRefKey names the message; a message with the same key already on screen is updated in place (content, status and a restarted timer) instead of stacking a new one.
func (*MessageRef) Offset
func (r *MessageRef) Offset(px float32) *MessageRefOffset sets the distance in px from the window's top (or bottom) edge to the stack (default MessageToken.Top). The newest message of a placement decides it. shadcn/ui's Sonner stack keeps its own inset.
func (*MessageRef) OnClick
func (r *MessageRef) OnClick(fn func()) *MessageRefOnClick runs fn when the message is clicked (antd onClick).
func (*MessageRef) OnClose
func (r *MessageRef) OnClose(fn func()) *MessageRefOnClose runs fn once when the message has closed (timed out, closed or destroyed), as antd onClose / EP onClose.
func (*MessageRef) PauseOnHover
func (r *MessageRef) PauseOnHover(on bool) *MessageRefPauseOnHover pauses the countdown while the pointer is over the message (antd pauseOnHover, default true; Defaults key "pauseOnHover").
func (*MessageRef) Placement
func (r *MessageRef) Placement(p MessagePlacement) *MessageRefPlacement selects where the message appears (MessageTop by default; shadcn/ui: the bottom end corner). Messages of each placement stack separately; bottom placements stack upwards.
func (*MessageRef) Plain
func (r *MessageRef) Plain() *MessageRefPlain draws the message on the neutral popup background with only the icon in the status color (Element plain); Ant's message already looks this way.
func (*MessageRef) ShowClose
func (r *MessageRef) ShowClose() *MessageRefShowClose adds a close button that dismisses the message.
MirrorReport 实验性
type MirrorReport struct {
Width float32 // frame width both passes ran at
Checked int // nodes compared
Skipped int // nodes present in both frames but exempt (NoMirror, LTR parent)
Violations []MirrorViolation
// Icons lists directional icons drawn unmirrored in the RTL frame
// (icon check); IconsSkipped counts those exempt inside a NoMirror
// node or subtree.
Icons []IconViolation
IconsSkipped int
}MirrorReport is the result of Driver.MirrorCheck.
func (MirrorReport) OK 实验性
func (r MirrorReport) OK() boolOK reports whether no violation (layout or icon) was found.
func (MirrorReport) String 实验性
func (r MirrorReport) String() stringString summarizes the report, one violation per line.
MirrorViolation 实验性
type MirrorViolation struct {
ID ID
Label string // the node's internal label (to locate it)
Under string // label of the nearest labelled ancestor ("" if none)
LTR geom.Rect // absolute rectangle in the LTR frame
RTL geom.Rect // absolute rectangle in the RTL frame
Want geom.Rect // where the RTL rectangle was expected
}MirrorViolation is a node whose RTL position is not the mirror of its LTR position inside its parent.
func (MirrorViolation) String 实验性
func (v MirrorViolation) String() stringMobileLocale 实验性
type MobileLocale struct {
PullToRefresh, ReleaseToRefresh, Refreshed string // pull-to-refresh states (the loading state uses Loading)
TapToRetry string // appended to LoadFailed in infinite lists (",点击重试")
DayFmt, HourFmt, MinuteFmt string // date-time picker columns, arg: number ("%d日", "%02d时", "%02d分")
// contains filtered or unexported fields
}MobileLocale holds the texts of ui/mobile components.
ModalFormW 实验性
type ModalFormW struct {
// contains filtered or unexported fields
}ModalFormW is a ProForm inside a Modal (Ant Design Pro ModalForm): the dialog's OK button submits (spinning while OnFinish runs) and the dialog closes once the values are saved.
func DrawerForm 实验性
func DrawerForm(c *Context, open *bool, title string, fields []ProField) *ModalFormWDrawerForm is ModalForm in a right-side drawer (Ant Design Pro DrawerForm).
func ModalForm 实验性
func ModalForm(c *Context, open *bool, title string, fields []ProField) *ModalFormWModalForm starts a dialog form bound to open; chain options, then Show.
ConfigProvider.Defaults("ModalForm" / "DrawerForm", ...) keys: "width", "columns" (number).
func (*ModalFormW) Columns 实验性
func (m *ModalFormW) Columns(n int) *ModalFormWColumns lays the fields out in n grid columns.
func (*ModalFormW) DestroyOnHidden 实验性
func (m *ModalFormW) DestroyOnHidden(on bool) *ModalFormWDestroyOnHidden resets the field values when the form is opened again (Pro modalProps/drawerProps.destroyOnHidden). By default values survive.
func (*ModalFormW) Finished 实验性
func (m *ModalFormW) Finished() boolFinished reports a completed submit (the dialog just closed), once.
func (*ModalFormW) KeepValues 实验性
func (m *ModalFormW) KeepValues() *ModalFormWKeepValues keeps the values after closing (the default, as in Pro v3).
func (*ModalFormW) OnFinish 实验性
func (m *ModalFormW) OnFinish(fn func(vals ProValues, done func(error))) *ModalFormWOnFinish receives the validated values; call done (from any goroutine) when saved. A nil error closes the dialog.
func (*ModalFormW) Readonly 实验性
func (m *ModalFormW) Readonly(on bool) *ModalFormWReadonly shows the values read-only (a details dialog): the drawer drops its OK button and the modal's OK just closes it.
func (*ModalFormW) Show 实验性
func (m *ModalFormW) Show() *ModalFormWShow builds the dialog (nothing while closed).
func (*ModalFormW) Values 实验性
func (m *ModalFormW) Values(v *ProValues) *ModalFormWValues binds the values.
func (*ModalFormW) Width 实验性
func (m *ModalFormW) Width(px float32) *ModalFormWWidth sets the dialog width (drawer: its size).
ModalW
type ModalW struct {
// contains filtered or unexported fields
}ModalW is a dialog over a mask: centered or top placement, draggable, fullscreen, custom footer and close options.
func Modal
func Modal(c *Context, open *bool, title string) *ModalWModal starts a dialog shown while *open; chain options, then Body.
The default width, top and centering come from theme.ModalToken (Ant 520 / 100, Element 50% / 15%, shadcn 512 centered). Besides the keys read in shad2c_defaults.go, ConfigProvider.Defaults("Modal", ...) reads "keyboard" (bool).
func (*ModalW) AfterOpenChanged
func (m *ModalW) AfterOpenChanged() boolAfterOpenChanged reports, after Body, that the open or close transition finished this frame (antd afterOpenChange; read *open for the new state, false is antd afterClose).
func (*ModalW) Body
func (m *ModalW) Body(fn func()) *ModalWBody builds the dialog content.
func (*ModalW) CancelText
func (m *ModalW) CancelText(s string) *ModalWfunc (*ModalW) Cancelled
func (m *ModalW) Cancelled() boolCancelled reports cancel / close / mask click / Escape this frame.
func (*ModalW) Centered
func (m *ModalW) Centered() *ModalWCentered centers the dialog vertically.
func (*ModalW) Closable
func (m *ModalW) Closable(on bool) *ModalWfunc (*ModalW) ConfirmLoading
func (m *ModalW) ConfirmLoading(on bool) *ModalWfunc (*ModalW) Danger
func (m *ModalW) Danger() *ModalWfunc (*ModalW) Draggable
func (m *ModalW) Draggable() *ModalWDraggable lets the user move the dialog by its header.
func (*ModalW) Footer
func (m *ModalW) Footer(fn func()) *ModalWfunc (*ModalW) Fullscreen
func (m *ModalW) Fullscreen(on *bool) *ModalWFullscreen binds the fullscreen state.
func (*ModalW) FullscreenToggle
func (m *ModalW) FullscreenToggle() *ModalWFullscreenToggle shows a maximize button in the header.
func (*ModalW) Header
func (m *ModalW) Header(fn func()) *ModalWHeader replaces the visible title with custom content. The title passed to Modal remains the accessible dialog name. The built-in fullscreen and close buttons, drag handle and focus management remain available.
func (*ModalW) Keyboard
func (m *ModalW) Keyboard(on bool) *ModalWKeyboard sets whether Escape closes the dialog (default true; antd keyboard, Element close-on-press-escape).
func (*ModalW) Loading
func (m *ModalW) Loading(on bool) *ModalWLoading shows an active Skeleton instead of the content and hides the footer (antd loading).
func (*ModalW) Mask
func (m *ModalW) Mask(on bool) *ModalWMask(false) hides the dimming mask (the page stays visible but blocked).
func (*ModalW) MaskBlur
func (m *ModalW) MaskBlur(radius float32) *ModalWMaskBlur sets the Gaussian blur radius of the canvas behind the mask, in logical pixels. A zero radius draws the mask without blur.
func (*ModalW) MaskClosable
func (m *ModalW) MaskClosable(on bool) *ModalWfunc (*ModalW) NoFooter
func (m *ModalW) NoFooter() *ModalWfunc (*ModalW) Ok
func (m *ModalW) Ok() boolOk reports the OK button this frame.
func (*ModalW) OkText
func (m *ModalW) OkText(s string) *ModalWfunc (*ModalW) Top
func (m *ModalW) Top(px float32) *ModalWTop sets the distance from the window top (Ant 100, Element 15%).
func (*ModalW) Width
func (m *ModalW) Width(px float32) *ModalWMultiDatePickerW 实验性
type MultiDatePickerW struct {
// contains filtered or unexported fields
}MultiDatePickerW is a date input with several values shown as tags.
func MultiDatePicker 实验性
func MultiDatePicker(c *Context, vals *[]time.Time) *MultiDatePickerWMultiDatePicker adds a multiple date input bound to *vals (Ant DatePicker multiple; with Picker(PickerMonth / PickerYear) Element's type="months" / "years"). Each click in the panel toggles a date (with Picker: a period start, UTC midnight); the panel stays open, the values are kept sorted and shown as closable tags. Backspace removes the last tag; arrow keys move the panel cursor and Enter / Space toggle it.
func (*MultiDatePickerW) A11yLabel 实验性
func (w *MultiDatePickerW) A11yLabel(s string) *MultiDatePickerWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*MultiDatePickerW) AllowClear 实验性
func (w *MultiDatePickerW) AllowClear(on bool) *MultiDatePickerWAllowClear toggles the clear-all button shown on hover (on by default).
func (*MultiDatePickerW) Changed 实验性
func (w *MultiDatePickerW) Changed() boolChanged reports a committed change of the dates this frame.
func (*MultiDatePickerW) Disabled 实验性
func (w *MultiDatePickerW) Disabled(on bool) *MultiDatePickerWDisabled disables the picker.
func (*MultiDatePickerW) DisabledDate 实验性
func (w *MultiDatePickerW) DisabledDate(fn func(time.Time) bool) *MultiDatePickerWDisabledDate marks dates (period starts) that cannot be picked.
func (*MultiDatePickerW) Format 实验性
func (w *MultiDatePickerW) Format(f string) *MultiDatePickerWFormat sets the Go layout of the tags (see DatePickerW.Format).
func (*MultiDatePickerW) IsOpen 实验性
func (w *MultiDatePickerW) IsOpen() boolIsOpen reports whether the panel is shown.
func (*MultiDatePickerW) MaxDate 实验性
func (w *MultiDatePickerW) MaxDate(t time.Time) *MultiDatePickerWMaxDate limits the pickable dates (Ant maxDate), like MinDate.
func (*MultiDatePickerW) MaxTagCount 实验性
func (w *MultiDatePickerW) MaxTagCount(n int) *MultiDatePickerWMaxTagCount folds the tags after the first n into "+ N ..." (0 = all).
func (*MultiDatePickerW) MinDate 实验性
func (w *MultiDatePickerW) MinDate(t time.Time) *MultiDatePickerWMinDate limits the pickable dates (Ant minDate): periods wholly before t cannot be toggled and the panel arrows stop at t's page.
func (*MultiDatePickerW) NeedConfirm 实验性
func (w *MultiDatePickerW) NeedConfirm(on bool) *MultiDatePickerWNeedConfirm keeps the toggled dates as a draft until the footer's OK button commits them; closing the panel otherwise drops the changes.
func (*MultiDatePickerW) Open 实验性
func (w *MultiDatePickerW) Open() *MultiDatePickerWOpen forces the panel open (screenshots, tests).
func (*MultiDatePickerW) Picker 实验性
func (w *MultiDatePickerW) Picker(p PickerType) *MultiDatePickerWPicker sets the granularity: PickerDate (default), PickerWeek, PickerMonth, PickerQuarter or PickerYear.
func (*MultiDatePickerW) Placeholder 实验性
func (w *MultiDatePickerW) Placeholder(s string) *MultiDatePickerWfunc (*MultiDatePickerW) Placement 实验性
func (w *MultiDatePickerW) Placement(p Placement) *MultiDatePickerWPlacement sets where the panel opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement); it flips when there is no room.
func (*MultiDatePickerW) Size 实验性
func (w *MultiDatePickerW) Size(s ControlSize) *MultiDatePickerWfunc (*MultiDatePickerW) Status 实验性
func (w *MultiDatePickerW) Status(s string) *MultiDatePickerWStatus sets the validation look: "error" or "warning".
func (*MultiDatePickerW) Width 实验性
func (w *MultiDatePickerW) Width(px float32) *MultiDatePickerWWidth sets the input width in pixels (default 260; tags wrap).
MultiSelectW 实验性
type MultiSelectW struct {
// contains filtered or unexported fields
}MultiSelectW is a select with multiple values shown as closable tags.
func MultiSelect 实验性
func MultiSelect(c *Context, val *[]string, opts []Option) *MultiSelectWMultiSelect adds a multiple-choice select bound to *val (selected values).
func (*MultiSelectW) A11yLabel 实验性
func (w *MultiSelectW) A11yLabel(s string) *MultiSelectWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*MultiSelectW) AllowClear 实验性
func (w *MultiSelectW) AllowClear() *MultiSelectWAllowClear shows a clear-all button on hover.
func (*MultiSelectW) AllowCreate 实验性
func (w *MultiSelectW) AllowCreate() *MultiSelectWAllowCreate offers the typed text as a new option (Ant mode="tags", Element allow-create); read it with Created. Implies Searchable.
func (*MultiSelectW) Changed 实验性
func (w *MultiSelectW) Changed() boolChanged reports a selection change this frame.
func (*MultiSelectW) Created 实验性
func (w *MultiSelectW) Created() (string, bool)Created returns the value of an entry created with AllowCreate this frame.
func (*MultiSelectW) DataVersion 实验性
func (w *MultiSelectW) DataVersion(v int) *MultiSelectWDataVersion tells the select that the option slice was modified in place.
func (*MultiSelectW) Debounce 实验性
func (w *MultiSelectW) Debounce(d time.Duration) *MultiSelectWDebounce sets the delay before a Remote call.
func (*MultiSelectW) Disabled 实验性
func (w *MultiSelectW) Disabled(on bool) *MultiSelectWfunc (*MultiSelectW) FilterMethod 实验性
func (w *MultiSelectW) FilterMethod(fn func(query string, o Option) bool) *MultiSelectWFilterMethod replaces the label match of the search text with fn (see SelectW.FilterMethod). Implies Searchable.
func (*MultiSelectW) Groups 实验性
func (w *MultiSelectW) Groups(groups []OptionGroup) *MultiSelectWGroups shows the options under titled groups; the opts passed to MultiSelect are ignored. Options can also be grouped with Option.Group.
func (*MultiSelectW) IsOpen 实验性
func (w *MultiSelectW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*MultiSelectW) Layout 实验性
func (w *MultiSelectW) Layout(o ...layout.Option) *MultiSelectWfunc (*MultiSelectW) ListHeight 实验性
func (w *MultiSelectW) ListHeight(px float32) *MultiSelectWListHeight sets the maximum dropdown height.
func (*MultiSelectW) Loading 实验性
func (w *MultiSelectW) Loading(on bool) *MultiSelectWLoading shows a spinner and the loading text in the dropdown.
func (*MultiSelectW) MaxCount 实验性
func (w *MultiSelectW) MaxCount(n int) *MultiSelectWMaxCount limits how many values may be selected (Ant maxCount, Element multiple-limit); the other options turn disabled at the limit.
func (*MultiSelectW) MaxTagCount 实验性
func (w *MultiSelectW) MaxTagCount(n int) *MultiSelectWMaxTagCount collapses tags after n into a "+ N ..." tag.
func (*MultiSelectW) MaxTagPlaceholder 实验性
func (w *MultiSelectW) MaxTagPlaceholder(fn func(omitted []string) string) *MultiSelectWMaxTagPlaceholder builds the text of the collapsed tag from the labels MaxTagCount hides (Ant maxTagPlaceholder; default "+ N ...").
func (*MultiSelectW) MaxTagTextLength 实验性
func (w *MultiSelectW) MaxTagTextLength(n int) *MultiSelectWMaxTagTextLength cuts tag labels longer than n runes to n runes plus "..." (Ant maxTagTextLength); the accessible names keep the full label.
func (*MultiSelectW) NotFoundContent 实验性
func (w *MultiSelectW) NotFoundContent(s string) *MultiSelectWNotFoundContent sets the text of an empty dropdown (Ant notFoundContent, Element no-data-text).
func (*MultiSelectW) Open 实验性
func (w *MultiSelectW) Open() *MultiSelectWOpen forces the dropdown open (screenshots, tests).
func (*MultiSelectW) OpenChanged 实验性
func (w *MultiSelectW) OpenChanged() boolOpenChanged reports that the dropdown opened or closed this frame (Ant onOpenChange, Element visible-change).
func (*MultiSelectW) OptionRender 实验性
func (w *MultiSelectW) OptionRender(fn func(o Option, s OptionState)) *MultiSelectWOptionRender builds each option row's content with fn.
func (*MultiSelectW) Placeholder 实验性
func (w *MultiSelectW) Placeholder(s string) *MultiSelectWfunc (*MultiSelectW) Placement 实验性
func (w *MultiSelectW) Placement(p Placement) *MultiSelectWPlacement sets where the dropdown opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement, Element placement); it flips when there is no room.
func (*MultiSelectW) Prefix 实验性
func (w *MultiSelectW) Prefix(ic *icon.Icon) *MultiSelectWPrefix shows ic before the tags (Ant prefix).
func (*MultiSelectW) PrefixText 实验性
func (w *MultiSelectW) PrefixText(s string) *MultiSelectWPrefixText shows s before the tags (Ant prefix, Element prefix slot).
func (*MultiSelectW) Remote 实验性
func (w *MultiSelectW) Remote(fn func(query string)) *MultiSelectWRemote turns on server-side search (see SelectW.Remote). Implies Searchable.
func (*MultiSelectW) Searchable 实验性
func (w *MultiSelectW) Searchable() *MultiSelectWSearchable filters options by typing into the selector.
func (*MultiSelectW) Size 实验性
func (w *MultiSelectW) Size(s ControlSize) *MultiSelectWfunc (*MultiSelectW) Status 实验性
func (w *MultiSelectW) Status(s string) *MultiSelectWfunc (*MultiSelectW) SuffixIcon 实验性
func (w *MultiSelectW) SuffixIcon(ic *icon.Icon) *MultiSelectWSuffixIcon replaces the dropdown arrow with ic (Ant suffixIcon); the clear button still takes its place on hover with AllowClear.
func (*MultiSelectW) Variant 实验性
func (w *MultiSelectW) Variant(v FieldVariant) *MultiSelectWVariant sets the frame look (FieldOutlined by default).
func (*MultiSelectW) Virtual 实验性
func (w *MultiSelectW) Virtual(on bool) *MultiSelectWVirtual forces the virtual dropdown on or off (default: lists longer than 100 options). With false, the dropdown builds every row.
func (*MultiSelectW) Width 实验性
func (w *MultiSelectW) Width(px float32) *MultiSelectWNativeRegion 实验性
type NativeRegion struct {
ID ID
// Rect is the whole box.
Rect geom.Rect
// Visible is the part of Rect that ancestors (scroll containers,
// clipping boxes, the window) leave visible; empty when the box is
// scrolled or clipped out of view, or culled.
Visible geom.Rect
// Covered reports that a layer above the box (an Overlay: dropdown,
// tooltip, popover, dialog, message), including a margin for its
// shadow, overlaps Visible.
Covered bool
// Focused reports the UI's keyboard focus on the box.
Focused bool
}NativeRegion is where a native view sits in the frame just painted. Rectangles are host window logical pixels, after UI scaling.
NativeViewW 实验性
type NativeViewW struct {
*Box
// contains filtered or unexported fields
}NativeViewW is the builder of NativeView. Box modifiers (Bg, Border, Radius, Paint, ...) style what the canvas draws under the native view, which shows wherever the native view is hidden (before it exists, while it is frozen as a snapshot, when the platform has none).
func NativeView 实验性
func NativeView(c *Context, key string, opts ...layout.Option) *NativeViewWNativeView reserves a box for a platform view. key identifies the view among its siblings (it is part of the ID: views with the same key in the same scope share an ID). The box is a Tab stop like a focusable control (Focusable(false) removes it from the Tab order); Enter and Space are left to the native view.
func (*NativeViewW) A11yLabel 实验性
func (w *NativeViewW) A11yLabel(s string) *NativeViewWA11yLabel names the region for assistive technologies.
func (*NativeViewW) Clicked 实验性
func (w *NativeViewW) Clicked() boolClicked reports a click on the box itself (the canvas only sees clicks where the native view is hidden).
func (*NativeViewW) Focusable 实验性
func (w *NativeViewW) Focusable(on bool) *NativeViewWFocusable puts the box in the Tab order (the default) or takes it out.
func (*NativeViewW) Focused 实验性
func (w *NativeViewW) Focused() boolFocused reports whether the box has the UI's keyboard focus.
NotificationAction 实验性
type NotificationAction struct {
Key string
Label string
Primary bool
}NotificationAction is a button under a NotificationItem.
NotificationCenterLocale 实验性
type NotificationCenterLocale struct {
MarkAllRead, ClearAll, Dismiss string
Empty string // empty panel ("暂无通知")
UnreadFmt string // unread count, arg: n ("%d 条未读")
JustNow string // under a minute ago
MinutesAgoFmt, HoursAgoFmt, DaysAgoFmt string // arg: n ("%d 分钟前")
// contains filtered or unexported fields
}NotificationCenterLocale holds the NotificationCenter texts. The trigger and panel are named by Locale.A11y.Notifications.
func (*NotificationCenterLocale) Unread 实验性
func (l *NotificationCenterLocale) Unread(n int) stringUnread formats the unread count of a NotificationCenter ("3 条未读").
NotificationCenterW 实验性
type NotificationCenterW struct {
// contains filtered or unexported fields
}NotificationCenterW is the bell button with its notification panel.
func NotificationCenter 实验性
func NotificationCenter(c *Context, items *[]NotificationItem) *NotificationCenterWNotificationCenter adds a bell button whose badge counts the unread entries of *items; it opens a panel listing them, grouped, newest first as the app orders them:
nc := ui.NotificationCenter(c, ¬es)
if key, ok := nc.Clicked(); ok { open(key) }
if key, act, ok := nc.Action(); ok { run(key, act) }
Activating an entry or one of its actions marks it read and closes the panel. The header marks everything read or clears the list; each entry can be dismissed on its own. Changed reports any such edit of *items. The panel is a Popover: Esc or a click outside closes it.
func (*NotificationCenterW) Action 实验性
func (w *NotificationCenterW) Action() (key, action string, ok bool)Action reports the entry and action keys of an action button activated this frame.
func (*NotificationCenterW) Changed 实验性
func (w *NotificationCenterW) Changed() boolChanged reports that the center edited *items this frame (marked read, dismissed, cleared).
func (*NotificationCenterW) Clicked 实验性
func (w *NotificationCenterW) Clicked() (string, bool)Clicked reports the key of the entry activated this frame.
func (*NotificationCenterW) IsOpen 实验性
func (w *NotificationCenterW) IsOpen() boolIsOpen reports whether the panel is shown.
func (*NotificationCenterW) Open 实验性
func (w *NotificationCenterW) Open(v *bool) *NotificationCenterWOpen binds the panel's open state (controlled mode).
func (*NotificationCenterW) Placement 实验性
func (w *NotificationCenterW) Placement(s string) *NotificationCenterWPlacement places the panel like Popover.Placement ("bottomRight" by default; "topRight" for a trigger in a status bar).
func (*NotificationCenterW) Title 实验性
func (w *NotificationCenterW) Title(s string) *NotificationCenterWTitle replaces the panel heading (Locale.A11y.Notifications).
func (*NotificationCenterW) Unread 实验性
func (w *NotificationCenterW) Unread() intUnread returns the number of unread entries.
func (*NotificationCenterW) Width 实验性
func (w *NotificationCenterW) Width(px float32) *NotificationCenterWWidth sets the panel width.
NotificationItem 实验性
type NotificationItem struct {
Key string // stable identity (required for the list to keep state)
Title string
Body string
// Level picks the leading status icon: "info", "success", "warning",
// "error" ("" for none).
Level string
// Group is the section the entry is listed under. Sections appear in
// the order their first entry has in the slice ("" = no heading).
Group string
Time time.Time // shown relative to now ("3 分钟前"); zero hides it
Read bool
Actions []NotificationAction
}NotificationItem is one entry of a NotificationCenter. The app owns the slice; the center marks entries read and removes them.
NotificationRef
type NotificationRef struct {
// contains filtered or unexported fields
}NotificationRef configures a notification opened by Notification. Use it in the same call chain; it does not need to be kept.
func Notification
func Notification(c *Context, status, title string) *NotificationRefNotification opens a notification card in a window corner (top end by default: top right, top left in RTL) and returns a reference for further options:
ui.Notification(c, "success", "已发布").Description("版本 1.2 已上线").Placement(ui.NotifyBottomRight)
status is success, info, warning, error or "" (no icon). Cards close after 4.5s (paused while hovered), collapse into a stack when more than NotifyStackThreshold share a corner, and can be updated in place by key.
func (*NotificationRef) Actions
func (r *NotificationRef) Actions(fn func()) *NotificationRefActions adds buttons under the description.
func (*NotificationRef) Closable
func (r *NotificationRef) Closable(on bool) *NotificationRefClosable shows (default) or hides the close button (antd closable, EP showClose).
func (*NotificationRef) CloseIcon
func (r *NotificationRef) CloseIcon(ic *icon.Icon) *NotificationRefCloseIcon replaces the close icon (antd closeIcon, EP closeIcon).
func (*NotificationRef) Description
func (r *NotificationRef) Description(s string) *NotificationRefDescription sets the text under the title.
func (*NotificationRef) Duration
func (r *NotificationRef) Duration(d time.Duration) *NotificationRefDuration sets how long the card stays; d <= 0 keeps it until closed.
func (*NotificationRef) Icon
func (r *NotificationRef) Icon(ic *icon.Icon) *NotificationRefIcon replaces the status icon (antd icon, EP icon).
func (*NotificationRef) Key
func (r *NotificationRef) Key(key string) *NotificationRefKey names the card; opening another card with the same key replaces the existing one in place (its timer restarts).
func (*NotificationRef) NoPause
func (r *NotificationRef) NoPause() *NotificationRefNoPause keeps counting down while the card is hovered.
func (*NotificationRef) OnClick
func (r *NotificationRef) OnClick(fn func()) *NotificationRefOnClick runs fn when the card is clicked.
func (*NotificationRef) OnClose
func (r *NotificationRef) OnClose(fn func()) *NotificationRefOnClose runs fn once when the card has closed (timed out, closed or destroyed), as antd onClose / EP onClose.
func (*NotificationRef) Placement
func (r *NotificationRef) Placement(p NotifyPlacement) *NotificationRefPlacement selects the corner (NotifyTopEnd default).
func (*NotificationRef) Role
func (r *NotificationRef) Role(role string) *NotificationRefRole sets the live-region role: "alert" (assertive) or "status" (polite). By default errors and warnings are alerts (antd role).
func (*NotificationRef) ShowProgress
func (r *NotificationRef) ShowProgress() *NotificationRefShowProgress draws a countdown bar at the bottom.
NotifyPlacement
type NotifyPlacement uint8NotifyPlacement is the corner a notification appears in. NotifyTopEnd (the zero value and default), NotifyTopStart, NotifyBottomEnd and NotifyBottomStart are logical: in RTL the end is the left side. The Right / Left placements are always that physical side.
Append-only: never reorder or insert; the zero value stays NotifyTopEnd.
const (
NotifyTopEnd NotifyPlacement = iota
NotifyTopStart
NotifyBottomEnd
NotifyBottomStart
NotifyTop
NotifyBottom
NotifyTopRight
NotifyTopLeft
NotifyBottomRight
NotifyBottomLeft
)OTPW 实验性
type OTPW struct {
// contains filtered or unexported fields
}OTPW is a one-time-password input: one box per character.
func OTP 实验性
func OTP(c *Context, val *string, n int) *OTPWOTP adds an n-character code input bound to *val.
func (*OTPW) A11yLabel 实验性
func (w *OTPW) A11yLabel(s string) *OTPWA11yLabel names the group of boxes (inside a FormItem use the item label); each box is announced as "character n of total".
func (*OTPW) CellID 实验性
func (w *OTPW) CellID(i int) IDCellID returns the ID of box i.
func (*OTPW) Changed 实验性
func (w *OTPW) Changed() boolChanged reports an edit this frame.
func (*OTPW) Completed 实验性
func (w *OTPW) Completed() boolCompleted reports an edit that filled every box.
func (*OTPW) Disabled 实验性
func (w *OTPW) Disabled(on bool) *OTPWfunc (*OTPW) Focus 实验性
func (w *OTPW) Focus() *OTPWFocus focuses the first empty box.
func (*OTPW) Gap 实验性
func (w *OTPW) Gap(px float32) *OTPWfunc (*OTPW) Mask 实验性
func (w *OTPW) Mask(s string) *OTPWMask shows s instead of each character (e.g. "•").
func (*OTPW) Numeric 实验性
func (w *OTPW) Numeric() *OTPWNumeric accepts digits only.
func (*OTPW) ReadOnly 实验性
func (w *OTPW) ReadOnly() *OTPWReadOnly shows the code without letting it change; the boxes can still be focused and walked with the arrow keys (Element readonly).
func (*OTPW) Separator 实验性
func (w *OTPW) Separator(s string) *OTPWSeparator shows s between every two boxes (antd / Element separator, shadcn InputOTPSeparator); "" shows none.
func (*OTPW) SeparatorFunc 实验性
func (w *OTPW) SeparatorFunc(fn func(i int) string) *OTPWSeparatorFunc shows fn(i) between box i and box i+1 (antd separator as a function of the index); "" leaves that gap empty, e.g. a "-" only after the third box of six.
func (*OTPW) Size 实验性
func (w *OTPW) Size(s ControlSize) *OTPWfunc (*OTPW) Status 实验性
func (w *OTPW) Status(s string) *OTPWfunc (*OTPW) Variant 实验性
func (w *OTPW) Variant(v string) *OTPWVariant sets the look of the boxes like InputW.Variant: "outlined" (default), "filled", "borderless" or "underlined" (antd variant, Element type).
Option
type Option struct {
Label, Value string
Disabled bool
Group string
// contains filtered or unexported fields
}Option is an item of a Select / RadioGroup / CheckboxGroup. Group puts the option under a titled group in Select / MultiSelect / VirtualSelect dropdowns (Ant OptGroup, Element el-option-group); options of one group are listed together in order of the group's first appearance.
func Opts
func Opts(labels ...string) []OptionOpts builds options whose value equals the label.
OptionGroup 实验性
type OptionGroup = VirtualOptionGroupOptionGroup is a titled group of options for Select / MultiSelect Groups (the same type as VirtualOptionGroup).
OptionState 实验性
type OptionState = VirtualOptionStateOptionState tells an OptionRender function how the row is shown.
OverlayOptions 实验性
type OverlayOptions struct {
Anchor ID // widget to attach to (anchored placements)
// AnchorRect supplies a non-empty anchor in UI logical coordinates
// for placement, such as an editor caret. Anchor still owns focus.
AnchorRect geom.Rect
Place Placement
Offset float32 // gap between anchor and overlay
MatchWidth bool // at least as wide as the anchor
Margin float32 // distance from window edges for Screen* placements
Flip bool // flip to the opposite side when it does not fit (currently always on for anchored placements)
ShiftX float32 // translation applied after placement (enter/leave motion)
ShiftY float32
// contains filtered or unexported fields
}OverlayOptions configure an overlay layer.
PageContainerLocale 实验性
type PageContainerLocale struct {
FooterToolbar string // accessible name of the FooterToolbar ("页面操作")
// contains filtered or unexported fields
}PageContainerLocale holds the PageContainer / FooterToolbar texts.
PageContainerW 实验性
type PageContainerW struct {
// contains filtered or unexported fields
}PageContainerW builds a PageContainer.
func PageContainer 实验性
func PageContainer(c *Context, title string) *PageContainerWPageContainer starts a page container titled title; chain options, then Body with the page content.
ConfigProvider.Defaults("PageContainer", ...) keys: "ghost", "fill", "tabsCard" (bool).
func (*PageContainerW) Back 实验性
func (p *PageContainerW) Back() *PageContainerWBack shows the back button (query BackClicked).
func (*PageContainerW) BackClicked 实验性
func (p *PageContainerW) BackClicked() boolBackClicked reports a click on the back button.
func (*PageContainerW) Body 实验性
func (p *PageContainerW) Body(fn func()) *PageContainerWBody builds the container with fn as the page content.
func (*PageContainerW) Breadcrumb 实验性
func (p *PageContainerW) Breadcrumb(items ...string) *PageContainerWBreadcrumb shows a breadcrumb above the title.
func (*PageContainerW) Content 实验性
func (p *PageContainerW) Content(fn func()) *PageContainerWContent builds the description area under the title.
func (*PageContainerW) CrumbClicked 实验性
func (p *PageContainerW) CrumbClicked() intCrumbClicked returns the index of a clicked breadcrumb item or -1.
func (*PageContainerW) Extra 实验性
func (p *PageContainerW) Extra(fn func()) *PageContainerWExtra builds the actions at the right of the title.
func (*PageContainerW) ExtraContent 实验性
func (p *PageContainerW) ExtraContent(fn func()) *PageContainerWExtraContent builds a block at the right of Content.
func (*PageContainerW) Fill 实验性
func (p *PageContainerW) Fill() *PageContainerWFill makes the container take its parent's free height: header and body scroll inside it and the footer toolbar stays at the bottom.
func (*PageContainerW) Footer 实验性
func (p *PageContainerW) Footer(fn func()) *PageContainerWFooter builds the right-hand buttons of a FooterToolbar.
func (*PageContainerW) FooterExtra 实验性
func (p *PageContainerW) FooterExtra(fn func()) *PageContainerWFooterExtra builds the left side of the FooterToolbar.
func (*PageContainerW) Ghost 实验性
func (p *PageContainerW) Ghost() *PageContainerWGhost drops the header background and the content padding (for use inside a padded content area). Inside ProLayout a non-ghost PageContainer switches the content area to NoPadding, so the header spans it.
func (*PageContainerW) Layout 实验性
func (p *PageContainerW) Layout(o ...layout.Option) *PageContainerWLayout applies layout options to the container.
func (*PageContainerW) Loading 实验性
func (p *PageContainerW) Loading(on bool) *PageContainerWLoading shows a centred spinner instead of the body.
func (*PageContainerW) NoHeader 实验性
func (p *PageContainerW) NoHeader() *PageContainerWNoHeader hides the page header (body and footer only).
func (*PageContainerW) ScrollID 实验性
func (p *PageContainerW) ScrollID() IDScrollID returns the scroll box of a Fill container (0 otherwise).
func (*PageContainerW) SubTitle 实验性
func (p *PageContainerW) SubTitle(s string) *PageContainerWSubTitle sets the secondary title.
func (*PageContainerW) TabChanged 实验性
func (p *PageContainerW) TabChanged() boolTabChanged reports a tab switch this frame.
func (*PageContainerW) TabExtra 实验性
func (p *PageContainerW) TabExtra(fn func()) *PageContainerWTabExtra builds content at the right of the tab list.
func (*PageContainerW) Tabs 实验性
func (p *PageContainerW) Tabs(active *string, items []TabItem) *PageContainerWTabs shows a tab list at the bottom of the header bound to active.
func (*PageContainerW) TabsCard 实验性
func (p *PageContainerW) TabsCard() *PageContainerWTabsCard uses card-style tabs.
func (*PageContainerW) Tags 实验性
func (p *PageContainerW) Tags(fn func()) *PageContainerWTags builds tags after the title.
PageHeaderW 实验性
type PageHeaderW struct {
// contains filtered or unexported fields
}PageHeaderW is the page title bar: back action, breadcrumb, title, subtitle, tags, extra actions, content and footer (tabs).
func PageHeader 实验性
func PageHeader(c *Context, title string) *PageHeaderWPageHeader starts a page header; chain options, then Show. Sizes and colors come from theme.PageHeaderToken (Pro Components v3 PageHeader, Element el-page-header); a Bordered header is the container color, as Pro's non-ghost header.
func (*PageHeaderW) Avatar 实验性
func (p *PageHeaderW) Avatar(fn func()) *PageHeaderWAvatar builds an avatar before the title (Pro avatar), e.g. func() { ui.Avatar(c, "U") }.
func (*PageHeaderW) Back 实验性
func (p *PageHeaderW) Back() *PageHeaderWBack shows the back button.
func (*PageHeaderW) BackClicked 实验性
func (p *PageHeaderW) BackClicked() boolBackClicked reports a click on the back button.
func (*PageHeaderW) BackIcon 实验性
func (p *PageHeaderW) BackIcon(ic *icon.Icon) *PageHeaderWBackIcon replaces the back arrow and shows the back button (Pro backIcon, Element icon).
func (*PageHeaderW) BackText 实验性
func (p *PageHeaderW) BackText(s string) *PageHeaderWBackText overrides the Element back label (default Locale().Back).
func (*PageHeaderW) Bordered 实验性
func (p *PageHeaderW) Bordered() *PageHeaderWBordered draws the container background (Pro ghost=false; a bottom line only when PageHeaderToken.BorderColor is set).
func (*PageHeaderW) Breadcrumb 实验性
func (p *PageHeaderW) Breadcrumb(items ...string) *PageHeaderWBreadcrumb shows a breadcrumb above the title.
func (*PageHeaderW) BreadcrumbItems 实验性
func (p *PageHeaderW) BreadcrumbItems(items []BreadcrumbItem) *PageHeaderWBreadcrumbItems shows a structured breadcrumb above the title (Pro breadcrumb {items}); CrumbClicked reports clicks on it.
func (*PageHeaderW) Content 实验性
func (p *PageHeaderW) Content(fn func()) *PageHeaderWContent adds the description area below the title.
func (*PageHeaderW) CrumbClicked 实验性
func (p *PageHeaderW) CrumbClicked() intCrumbClicked returns the clicked breadcrumb index or -1.
func (*PageHeaderW) Extra 实验性
func (p *PageHeaderW) Extra(fn func()) *PageHeaderWExtra adds actions at the right.
func (*PageHeaderW) Footer 实验性
func (p *PageHeaderW) Footer(fn func()) *PageHeaderWFooter adds a footer (usually Tabs).
func (*PageHeaderW) Ghost 实验性
func (p *PageHeaderW) Ghost(on bool) *PageHeaderWGhost toggles the transparent background (Pro ghost, default true).
func (*PageHeaderW) Padding 实验性
func (p *PageHeaderW) Padding(in geom.Insets) *PageHeaderWPadding overrides the header padding (Ant 16px 24px, Element none), e.g. to align it with a surrounding container.
func (*PageHeaderW) Show 实验性
func (p *PageHeaderW) Show() *PageHeaderWShow builds the header.
func (*PageHeaderW) SubTitle 实验性
func (p *PageHeaderW) SubTitle(s string) *PageHeaderWSubTitle sets the secondary title.
func (*PageHeaderW) Tags 实验性
func (p *PageHeaderW) Tags(fn func()) *PageHeaderWTags adds tags after the title.
PageLoadingW 实验性
type PageLoadingW struct {
// contains filtered or unexported fields
}PageLoadingW is ProLayout's centred, large Spin wrapper.
func PageLoading 实验性
func PageLoading(c *Context) *PageLoadingWPageLoading starts a page loading indicator; chain options, then Show. Like Pro v3 PageLoading, it adds 100px top padding and centres a large Spin. The legacy react-loadable isLoading/pastDelay/error props do not control visibility; Spinning is the Spin visibility input. ConfigProvider.Defaults("PageLoading", ...): "spinning", "size", "delay" (time.Duration), "description".
func (*PageLoadingW) Delay 实验性
func (p *PageLoadingW) Delay(d time.Duration) *PageLoadingWDelay delays showing the indicator; stopping always hides immediately.
func (*PageLoadingW) Description 实验性
func (p *PageLoadingW) Description(s string) *PageLoadingWDescription sets the loading indicator's text and accessible name.
func (*PageLoadingW) Show 实验性
func (p *PageLoadingW) Show() *PageLoadingWShow builds the page loading wrapper using the shared Spin implementation.
func (*PageLoadingW) Size 实验性
func (p *PageLoadingW) Size(size ControlSize) *PageLoadingWSize selects the Spin size (default large).
func (*PageLoadingW) Spinning 实验性
func (p *PageLoadingW) Spinning(on bool) *PageLoadingWSpinning controls the loading indicator, not the surrounding page.
PaginationLocale
type PaginationLocale struct {
Jump, Current string
// Confirm is the quick jumper's go button (antd jump_to_confirm);
// Prev3 / Next3 name the ••• jumps of ShowLessItems.
Confirm, Prev3, Next3 string
// contains filtered or unexported fields
}PaginationLocale holds the accessible names of the Pagination inputs (quick jumper, simple mode current page).
PaginationPart
type PaginationPart stringPaginationPart is one part of a Pagination arranged by PaginationW.Layout (Element's layout).
const (
PaginationPrev PaginationPart = "prev" // previous-page button
PaginationPager PaginationPart = "pager" // page buttons (the editable page in Simple)
PaginationNext PaginationPart = "next" // next-page button
PaginationJumper PaginationPart = "jumper" // "go to [ ] page"
PaginationSizes PaginationPart = "sizes" // page-size select (needs SizeChanger)
PaginationTotal PaginationPart = "total" // "total N items"
PaginationSpacer PaginationPart = "->" // pushes the following parts to the end
)PaginationW
type PaginationW struct {
// contains filtered or unexported fields
}PaginationW is a page navigator: page buttons with ellipsis jumps, total text, size changer, quick jumper, simple mode, hide on a single page, disabled state and Element's background (filled) style.
func Pagination
func Pagination(c *Context, page *int, total, pageSize int) *PaginationWPagination adds a pager bound to *page (1-based).
ConfigProvider.Defaults("Pagination", ...) keys: "showQuickJumper", "showTotal", "simple", "hideOnSinglePage", "background", "disabled", "showLessItems" (bool), "size" (ControlSize or "small" | "default" | "large"), "align" ("start" | "center" | "end"), "pageSizeOptions" ([]int), "pagerCount" (int).
The page buttons follow @rc-component/pagination: every page up to 7 pages (5 with ShowLessItems), else the first, the last, the pages around the current one and ••• jumps of 5 (3) pages. The Element theme uses PagerCount(7) by default (el-pagination pager-count), Background on, and page sizes 10/20/30/40/50/100 (PaginationToken). With total 0 a single disabled page 1 shows, like antd.
Under shadcn/ui page links are ghost buttons, the current page an outline button and Previous / Next carry their label next to the chevron (icon only in the small and simple pagers).
func (*PaginationW) Align
func (p *PaginationW) Align(a string) *PaginationWAlign places the pager in its row: "start", "center" or "end" (antd align); "" leaves it at its natural width.
func (*PaginationW) Background
func (p *PaginationW) Background(on bool) *PaginationWBackground toggles the filled page buttons (Element background; the default of the Element theme, off by default in Ant). A Simple pager is plain unless Background(true) is given, so it sits lightly at the bottom of a list or transfer panel.
func (*PaginationW) Changed
func (p *PaginationW) Changed() boolfunc (*PaginationW) Disabled
func (p *PaginationW) Disabled(on bool) *PaginationWDisabled disables every part of the pager.
func (*PaginationW) GoButton
func (p *PaginationW) GoButton(label string) *PaginationWGoButton adds a confirm button after the quick jumper input (antd showQuickJumper.goButton) and turns the jumper on; label "" uses Locale().Pagination.Confirm.
func (*PaginationW) HideOnSinglePage
func (p *PaginationW) HideOnSinglePage() *PaginationWHideOnSinglePage hides the pager when there is at most one page.
func (*PaginationW) Layout
func (p *PaginationW) Layout(parts ...PaginationPart) *PaginationWLayout arranges the pager from parts in the given order (Element's layout "total, prev, pager, next, sizes, jumper"); only the listed parts show, whatever ShowTotal / ShowQuickJumper say. PaginationSizes needs SizeChanger. PaginationSpacer pushes the parts after it to the end of the row.
func (*PaginationW) NextIcon
func (p *PaginationW) NextIcon(ic *icon.Icon) *PaginationWfunc (*PaginationW) NextText
func (p *PaginationW) NextText(s string) *PaginationWfunc (*PaginationW) PageSizeOptions
func (p *PaginationW) PageSizeOptions(sizes ...int) *PaginationWPageSizeOptions sets the choices of the size changer (antd pageSizeOptions, default 10/20/50/100; Element page-sizes, default 10/20/30/40/50/100).
func (*PaginationW) PagerCount
func (p *PaginationW) PagerCount(n int) *PaginationWPagerCount sets how many page-number buttons the pager shows at most (Element pager-count: an odd number from 5 to 21, others are rounded up to the next odd number in range). The first and last pages always show; the rest are a window around the current page with ••• jumps. Without it the pager follows Ant: every page up to 9 pages, else the first, the last and five around the current page.
func (*PaginationW) PrevIcon
func (p *PaginationW) PrevIcon(ic *icon.Icon) *PaginationWPrevIcon / NextIcon replace the chevrons (Element prev-icon / next-icon, antd itemRender for prev / next).
func (*PaginationW) PrevText
func (p *PaginationW) PrevText(s string) *PaginationWPrevText / NextText show a text instead of the chevron in the previous / next buttons (Element prev-text / next-text).
func (*PaginationW) ReadOnly
func (p *PaginationW) ReadOnly() *PaginationWReadOnly shows the current page of a Simple pager as text instead of an input ("< 2 / 5 >", Ant simple.readOnly): the narrowest pager, for embedding at the bottom of a list.
func (*PaginationW) Show
func (p *PaginationW) Show() *PaginationWShow builds the pager.
func (*PaginationW) ShowLessItems
func (p *PaginationW) ShowLessItems() *PaginationWShowLessItems shows fewer page buttons: one page on each side of the current one and ••• jumps of 3 pages (antd showLessItems).
func (*PaginationW) ShowQuickJumper
func (p *PaginationW) ShowQuickJumper() *PaginationWShowQuickJumper adds the "go to [ ] page" input (Enter or leaving the input jumps).
func (*PaginationW) ShowTotal
func (p *PaginationW) ShowTotal() *PaginationWfunc (*PaginationW) ShowTotalFunc
func (p *PaginationW) ShowTotalFunc(fn func(total, from, to int) string) *PaginationWShowTotalFunc shows the text fn returns before the pager (antd showTotal(total, range)): from and to are the 1-based items of the current page (0, 0 when total is 0).
func (*PaginationW) Simple
func (p *PaginationW) Simple() *PaginationWSimple shows only prev, an editable current page, "/ pages" and next.
func (*PaginationW) Size
func (p *PaginationW) Size(s ControlSize) *PaginationWSize picks the small pager (Small), the default one or the large one (Large: 40px buttons, antd 6 size="large", Element size="large"); Small with Simple is the narrow pager for list and transfer footers.
func (*PaginationW) SizeChanger
func (p *PaginationW) SizeChanger(size *int) *PaginationWSizeChanger shows a page-size select bound to *size.
func (*PaginationW) Small
func (p *PaginationW) Small() *PaginationWPaintFunc
type PaintFunc func(l *paint.List, r geom.Rect)PaintFunc draws a node; r is the node's absolute rectangle.
PanAxis 实验性
type PanAxis uint8PanAxis is a set of drag directions.
Append-only: never reorder or insert; existing values never change.
const (
PanX PanAxis = 1 << iota // horizontal drags
PanY // vertical drags
PanXY = PanX | PanY
)实验性
PickerType
type PickerType uint8PickerType is the granularity of a DatePickerPanel (Ant picker, Element type).
Append-only: never reorder or insert; the zero value stays PickerDate.
const (
PickerDate PickerType = iota
PickerWeek
PickerMonth
PickerQuarter
PickerYear
)Placement
type Placement uint8Placement positions an overlay relative to an anchor or the window.
BottomStart/BottomEnd/TopStart/TopEnd and the Inline* and Screen{Start, End,TopStart,TopEnd} values are logical: Start is the inline start edge (left in LTR, right in RTL). Left/Right/RightStart/LeftStart/RightEnd/ LeftEnd and ScreenLeft/ScreenRight/ScreenTopRight/ScreenTopLeft are physical and never mirror. The overlay's direction is that of the scope that built it; see Resolve.
Append-only: never reorder or insert; the zero value stays BottomStart.
const (
BottomStart Placement = iota // below anchor, aligned to its inline start edge
BottomEnd // below anchor, aligned to its inline end edge
Bottom // below, centered
TopStart // above anchor, aligned to its inline start edge
TopEnd // above anchor, aligned to its inline end edge
Top
RightStart // right of anchor, top edges aligned
LeftStart // left of anchor, top edges aligned
ScreenCenter // centered in the window
ScreenTop // horizontally centered, near the top (messages)
ScreenTopRight // notifications
ScreenRight // drawers: full height on the right
ScreenLeft // full height on the left
ScreenFill // covers the window (masks)
ScreenTopCenter // modal: centered horizontally, 100px from top
Right // right of anchor, vertically centered
Left // left of anchor, vertically centered
RightEnd // right of anchor, bottom edges aligned
LeftEnd // left of anchor, bottom edges aligned
InlineEnd // after the anchor on the inline axis, vertically centered
InlineEndTop // after the anchor, top edges aligned (submenus)
InlineEndBottom // after the anchor, bottom edges aligned
InlineStart // before the anchor on the inline axis, vertically centered
InlineStartTop // before the anchor, top edges aligned
InlineStartBottom // before the anchor, bottom edges aligned
ScreenEnd // full height on the inline end side (drawers)
ScreenStart // full height on the inline start side
ScreenTopEnd // top corner on the inline end side (notifications)
ScreenTopStart // top corner on the inline start side
ScreenTopLeft // physical top-left corner
InsideTopRight // inside the anchor, at its physical top-right corner
)实验性 ScreenCenter、ScreenTop、ScreenTopRight、ScreenRight、ScreenLeft、ScreenFill、ScreenTopCenter、ScreenEnd、ScreenStart、ScreenTopEnd、ScreenTopStart、ScreenTopLeft、InsideTopRight
func (Placement) Resolve
func (p Placement) Resolve(rtl bool) PlacementResolve maps a logical placement to the physical one used for the given direction. Physical placements are returned unchanged, so in LTR every placement resolves to its LTR meaning.
PopconfirmW
type PopconfirmW struct {
// contains filtered or unexported fields
}PopconfirmW asks for confirmation before an action. Options apply when the build finishes (or at Confirmed / Cancelled).
ConfigProvider.Defaults("Popconfirm", ...) keys: "okText", "cancelText", "placement", "okType", "cancelType" (string), "showCancel", "arrow", "disabled" (bool), "width" (float32).
func Popconfirm
func Popconfirm(c *Context, title, desc string, trigger func()) *PopconfirmWPopconfirm wraps trigger content; clicking it opens a confirm bubble. The default placement, width, arrow and cancel button type come from theme.PopoverToken (Ant top; Element bottom, 150 wide, text cancel button; shadcn no arrow).
func (*PopconfirmW) Arrow
func (p *PopconfirmW) Arrow(on bool) *PopconfirmWArrow shows or hides the bubble arrow (default from the theme; antd arrow).
func (*PopconfirmW) CancelText
func (p *PopconfirmW) CancelText(s string) *PopconfirmWCancelText sets the cancel button text (default Locale().Cancel).
func (*PopconfirmW) CancelType
func (p *PopconfirmW) CancelType(t string) *PopconfirmWCancelType sets the cancel button type, as OkType (default "default"; Element "text", its cancel-button-type).
func (*PopconfirmW) Cancelled
func (p *PopconfirmW) Cancelled() boolCancelled reports the cancel button.
func (*PopconfirmW) Confirmed
func (p *PopconfirmW) Confirmed() boolConfirmed reports the OK button.
func (*PopconfirmW) Description
func (p *PopconfirmW) Description(s string) *PopconfirmWDescription sets the text under the title.
func (*PopconfirmW) Disabled
func (p *PopconfirmW) Disabled(on bool) *PopconfirmWDisabled keeps the bubble from opening.
func (*PopconfirmW) Icon
func (p *PopconfirmW) Icon(ic *icon.Icon) *PopconfirmWIcon replaces the warning icon (nil hides it).
func (*PopconfirmW) IconColor
func (p *PopconfirmW) IconColor(col theme.Color) *PopconfirmWIconColor colors a custom Icon (default the warning color).
func (*PopconfirmW) IsOpen
func (p *PopconfirmW) IsOpen() boolIsOpen reports whether the bubble is shown.
func (*PopconfirmW) OkDanger
func (p *PopconfirmW) OkDanger() *PopconfirmWOkDanger styles the confirm button as dangerous (okType="danger").
func (*PopconfirmW) OkText
func (p *PopconfirmW) OkText(s string) *PopconfirmWOkText sets the confirm button text (default Locale().OK).
func (*PopconfirmW) OkType
func (p *PopconfirmW) OkType(t string) *PopconfirmWOkType sets the confirm button type: "primary" (default), "default", "dashed", "text", "link" or "danger" (antd okType, Element confirm-button-type).
func (*PopconfirmW) Placement
func (p *PopconfirmW) Placement(s string) *PopconfirmWPlacement as Popover.Placement (default "top").
func (*PopconfirmW) ShowCancel
func (p *PopconfirmW) ShowCancel(on bool) *PopconfirmWShowCancel shows or hides the cancel button (default shown).
func (*PopconfirmW) Width
func (p *PopconfirmW) Width(px float32) *PopconfirmWWidth fixes the bubble width (Element width, default 150 there; zero fits the content).
PopoverW
type PopoverW struct {
// contains filtered or unexported fields
}PopoverW is a floating card attached to a trigger: title, content and an arrow, in twelve placements, opened by hover, click or focus.
func Popover
func Popover(c *Context) *PopoverWPopover starts a popover; set options then call Body with the trigger.
ConfigProvider.Defaults("Popover", ...) keys: "placement", "trigger", "arrow" (bool; default PopoverToken.Arrow: true, false for shadcn whose popover has none), "mouseEnterDelay", "mouseLeaveDelay" (time.Duration; default the theme's PopoverToken delays: antd 0.1 s / 0.1 s, Element 0 / 0.2 s).
func (*PopoverW) Arrow
func (p *PopoverW) Arrow(on bool) *PopoverWArrow shows or hides the arrow (antd arrow; NoArrow is Arrow(false)).
func (*PopoverW) Body
func (p *PopoverW) Body(fn func()) *BoxBody builds the trigger content and, when open, the panel.
func (*PopoverW) Content
func (p *PopoverW) Content(fn func()) *PopoverWContent builds the body.
func (*PopoverW) IsOpen
func (p *PopoverW) IsOpen() boolIsOpen reports whether the panel is shown.
func (*PopoverW) MouseEnterDelay
func (p *PopoverW) MouseEnterDelay(d time.Duration) *PopoverWMouseEnterDelay waits d before a hover popover opens (antd mouseEnterDelay, Element show-after).
func (*PopoverW) MouseLeaveDelay
func (p *PopoverW) MouseLeaveDelay(d time.Duration) *PopoverWMouseLeaveDelay keeps a hover popover open for d after the pointer left the trigger and the panel (antd mouseLeaveDelay, Element hide-after).
func (*PopoverW) NoArrow
func (p *PopoverW) NoArrow() *PopoverWNoArrow hides the arrow.
func (*PopoverW) NoPadding
func (p *PopoverW) NoPadding() *PopoverWNoPadding removes the panel padding (menus, custom cards).
func (*PopoverW) Open
func (p *PopoverW) Open(v *bool) *PopoverWOpen binds the open state (controlled mode).
func (*PopoverW) OpenChanged
func (p *PopoverW) OpenChanged() boolOpenChanged reports a state change caused by the user this frame.
func (*PopoverW) Placement
func (p *PopoverW) Placement(s string) *PopoverWPlacement: top, topLeft, topRight, bottom, bottomLeft, bottomRight, left, leftTop, leftBottom, right, rightTop, rightBottom. Left and right are logical (start / end): in RTL "left" opens on the right.
func (*PopoverW) Text
func (p *PopoverW) Text(s string) *PopoverWText sets a plain text body.
func (*PopoverW) Title
func (p *PopoverW) Title(s string) *PopoverWTitle sets the bold heading.
func (*PopoverW) Trigger
func (p *PopoverW) Trigger(s string) *PopoverWTrigger: "hover" (default), "click", "focus" or "manual" (Open only).
func (*PopoverW) Width
func (p *PopoverW) Width(px float32) *PopoverWWidth fixes the panel width.
ProBreadcrumbW 实验性
type ProBreadcrumbW struct {
*BreadcrumbW
// contains filtered or unexported fields
}ProBreadcrumbW is the route-aware Breadcrumb exported by ProLayout. It delegates rendering, keyboard handling and semantics to BreadcrumbW.
func ProBreadcrumb 实验性
func ProBreadcrumb(c *Context) *ProBreadcrumbWProBreadcrumb starts a breadcrumb from the innermost ProLayout's route. Items overrides the route items, including with an empty slice. ConfigProvider.Defaults("ProBreadcrumb", ...): "separator" (string).
func (*ProBreadcrumbW) Items 实验性
func (b *ProBreadcrumbW) Items(items []BreadcrumbItem) *ProBreadcrumbWItems replaces the breadcrumb items (rather than appending).
func (*ProBreadcrumbW) Len 实验性
func (b *ProBreadcrumbW) Len() intLen reports the number of breadcrumb items.
func (*ProBreadcrumbW) Separator 实验性
func (b *ProBreadcrumbW) Separator(s string) *ProBreadcrumbWSeparator replaces the separator between items.
func (*ProBreadcrumbW) Show 实验性
func (b *ProBreadcrumbW) Show() *ProBreadcrumbWShow builds the breadcrumb. Empty route breadcrumbs produce no landmark.
ProCardLocale 实验性
type ProCardLocale struct {
MoreInfo string // accessible name of the title tooltip icon
// contains filtered or unexported fields
}ProCardLocale holds the ProCard / StatisticCard texts.
ProCardTab 实验性
type ProCardTab struct {
Key, Label string
Icon *icon.Icon
Disabled bool
Body func()
}ProCardTab is one tab of a tabbed ProCard.
ProCardW 实验性
type ProCardW struct {
// contains filtered or unexported fields
}ProCardW builds a ProCard.
func ProCard 实验性
func ProCard(c *Context, title string) *ProCardWProCard starts a ProCard ("" title = no header unless Extra, Tooltip or Collapsible need one); chain options, then call Body.
ConfigProvider.Defaults("ProCard", ...) keys: "size" ("small" | "default" or a ControlSize), "bordered", "headerBordered", "ghost", "hoverable", "collapsible", "boxShadow" (bool), "gutter" (number).
Like Pro Components v3 (variant defaults to "outlined") a card is bordered unless Borderless is set; ghost cards and split children have no border.
func StatisticCardGroup 实验性
func StatisticCardGroup(c *Context) *ProCardWStatisticCardGroup builds StatisticCard.Group: a ProCard with zero body padding. Use Divider for explicit separators, or Split for automatic ones.
func (*ProCardW) Actions 实验性
func (w *ProCardW) Actions(fns ...func()) *ProCardWActions adds the bottom action bar (Ant ProCard actions): each fn builds one equal-width slot, separated by dividers (CardAction makes an icon action). The bar is hidden while the card is folded.
func (*ProCardW) Body 实验性
func (w *ProCardW) Body(fn func()) *ProCardWBody builds the card with fn as its content.
func (*ProCardW) BodyPadding 实验性
func (w *ProCardW) BodyPadding(in geom.Insets) *ProCardWBodyPadding overrides the body padding.
func (*ProCardW) Bordered 实验性
func (w *ProCardW) Bordered() *ProCardWBordered draws a border around the card (the default; it overrides a "bordered": false ConfigProvider default).
func (*ProCardW) Borderless 实验性
func (w *ProCardW) Borderless() *ProCardWBorderless removes the border (Pro v3 variant "borderless").
func (*ProCardW) Box 实验性
func (w *ProCardW) Box() *BoxBox returns the card container (valid after Body).
func (*ProCardW) BoxShadow 实验性
func (w *ProCardW) BoxShadow(on bool) *ProCardWBoxShadow gives the card the tertiary shadow and hides its border (Pro v3 boxShadow).
func (*ProCardW) Centered 实验性
func (w *ProCardW) Centered() *ProCardWCentered centres the body content on both axes.
func (*ProCardW) Clicked 实验性
func (w *ProCardW) Clicked() boolClicked reports a click on a hoverable card.
func (*ProCardW) ColSpan 实验性
func (w *ProCardW) ColSpan(span int) *ProCardWColSpan sizes the card inside a parent ProCard row: span of 24 columns.
func (*ProCardW) ColWidth 实验性
func (w *ProCardW) ColWidth(px float32) *ProCardWColWidth gives the card a fixed width inside a parent ProCard row.
func (*ProCardW) Collapsed 实验性
func (w *ProCardW) Collapsed(v *bool) *ProCardWCollapsed binds the folded state (implies Collapsible).
func (*ProCardW) Collapsible 实验性
func (w *ProCardW) Collapsible() *ProCardWCollapsible lets a click on the header fold the body.
func (*ProCardW) DefaultCollapsed 实验性
func (w *ProCardW) DefaultCollapsed() *ProCardWDefaultCollapsed starts an uncontrolled collapsible card folded.
func (*ProCardW) Direction 实验性
func (w *ProCardW) Direction(d string) *ProCardWDirection sets how child ProCards are arranged: "row" (default) or "column".
func (*ProCardW) Extra 实验性
func (w *ProCardW) Extra(fn func()) *ProCardWExtra builds the actions at the right of the header.
func (*ProCardW) Ghost 实验性
func (w *ProCardW) Ghost() *ProCardWGhost removes the background and the body padding.
func (*ProCardW) Gutter 实验性
func (w *ProCardW) Gutter(px float32) *ProCardWGutter sets the space between child ProCards.
func (*ProCardW) HeaderBordered 实验性
func (w *ProCardW) HeaderBordered() *ProCardWHeaderBordered draws a divider under the header.
func (*ProCardW) Hoverable 实验性
func (w *ProCardW) Hoverable() *ProCardWHoverable lifts the card with a shadow on hover.
func (*ProCardW) ID 实验性
func (w *ProCardW) ID() IDID returns the card's widget ID (valid after Body).
func (*ProCardW) IsCollapsed 实验性
func (w *ProCardW) IsCollapsed() boolIsCollapsed reports whether the body is folded.
func (*ProCardW) Layout 实验性
func (w *ProCardW) Layout(o ...layout.Option) *ProCardWLayout applies layout options to the card.
func (*ProCardW) Loading 实验性
func (w *ProCardW) Loading(on bool) *ProCardWLoading shows the animated loading placeholder instead of the body.
func (*ProCardW) Small 实验性
func (w *ProCardW) Small() *ProCardWSmall uses the compact paddings.
func (*ProCardW) Split 实验性
func (w *ProCardW) Split(dir string) *ProCardWSplit lays the child ProCards out on one surface separated by dividers (SplitVertical or SplitHorizontal).
func (*ProCardW) SubTitle 实验性
func (w *ProCardW) SubTitle(s string) *ProCardWSubTitle sets the secondary title shown after the title.
func (*ProCardW) TabChanged 实验性
func (w *ProCardW) TabChanged() boolTabChanged reports a tab switch this frame.
func (*ProCardW) TabExtra 实验性
func (w *ProCardW) TabExtra(fn func()) *ProCardWTabExtra builds content at the right of the tab bar.
func (*ProCardW) Tabs 实验性
func (w *ProCardW) Tabs(active *string, tabs []ProCardTab) *ProCardWTabs turns the card into a tab card bound to active; the active tab's Body is shown as the card body.
func (*ProCardW) TabsCard 实验性
func (w *ProCardW) TabsCard() *ProCardWTabsCard uses card-style tabs.
func (*ProCardW) Toggled 实验性
func (w *ProCardW) Toggled() boolToggled reports a collapse / expand by the user this frame.
func (*ProCardW) Tooltip 实验性
func (w *ProCardW) Tooltip(tip string) *ProCardWTooltip adds a question icon after the title showing tip on hover.
func (*ProCardW) Wrap 实验性
func (w *ProCardW) Wrap() *ProCardWWrap lets child ProCards wrap onto new lines.
ProColumn 实验性
type ProColumn[T any] struct {
Key, Title string
Width float32
MinWidth float32
Fixed string
Align TextAlign
Ellipsis bool
Hidden bool // hidden until enabled in the column settings
// ValueType formats Value (see the Value* constants).
ValueType string
ValueEnum []ProEnum
Value func(row T) any
// Render overrides the cell (i is the row index in the current page).
Render func(row T, i int)
// OnClick makes link cells clickable.
OnClick func(row T)
// Currency is the ISO 4217 code ("USD", "JPY") or symbol of money cells
// (default: the Locale's, "¥" for zh-CN / ja, "$" for en-US, "NT$" for
// zh-TW). A code also sets the decimals (JPY: none); see FormatMoney.
Currency string
// Editor makes the column editable in EditableProTable: the field
// (Required, Rules, Validate, AsyncValidate, Options, Min / Max ...)
// picks the control by its ValueType; Key, Label, ValueType and
// ValueEnum default to the column's. Set writes an edited value back
// into a copy of the row; without Set the column stays read-only.
Editor *ProField
Set func(row *T, v any)
Sortable bool // server-side sort (reported in ProRequest.Sort)
Filterable bool // filter dropdown from ValueEnum (ProRequest.Filters)
HideInSearch bool
HideInTable bool
}ProColumn is a ProTable column over rows of type T.
ProDescItem 实验性
type ProDescItem struct {
Key, Label string
ValueType string
ValueEnum []ProEnum
Span int // columns taken (default 1)
// ReadOnly keeps the item out of inline editing.
ReadOnly bool
// Render replaces the value display (all holds every value).
Render func(c *Context, v any, all ProValues)
// Field configures the inline editor (Required, Rules, Min / Max,
// Placeholder, Options ...). Key, Label, ValueType and ValueEnum
// default to the item's.
Field *ProField
}ProDescItem is one entry of ProDescriptions. ValueType and ValueEnum use the ProTable / ProForm value types (text, money, digit, percent, date, dateTime, select, status, tag, progress, textarea ...): they format the value and pick the inline editor.
ProDescriptionsLocale 实验性
type ProDescriptionsLocale struct {
EditFmt string // inline edit button, arg: item label ("编辑%s")
// contains filtered or unexported fields
}ProDescriptionsLocale holds the ProDescriptions texts.
ProDescriptionsW 实验性
type ProDescriptionsW struct {
// contains filtered or unexported fields
}ProDescriptionsW is a description list driven by item definitions (Ant Design Pro ProDescriptions): values formatted by value type, data loaded by a request function with a loading state, and inline editing of single items with save / cancel.
ui.ProDescriptions(c, items).Title("Rule").Column(2).Bordered().
Request(func() (map[string]any, error) { return api.Rule(id) }).
Editable(func(key string, v any, all ui.ProValues, done func(error)) { go save(key, v, done) }).
Show()
func ProDescriptions 实验性
func ProDescriptions(c *Context, items []ProDescItem) *ProDescriptionsWProDescriptions starts a description list over items; chain options, then Show.
func (*ProDescriptionsW) Bordered 实验性
func (p *ProDescriptionsW) Bordered() *ProDescriptionsWBordered draws the table-like bordered style.
func (*ProDescriptionsW) Column 实验性
func (p *ProDescriptionsW) Column(n int) *ProDescriptionsWColumn sets the number of columns (default: Descriptions' DEFAULT_COLUMN_MAP, 1 on xs, 2 on sm, 3 from md up).
func (*ProDescriptionsW) ColumnAt 实验性
func (p *ProDescriptionsW) ColumnAt(bp Breakpoint, n int) *ProDescriptionsWColumnAt sets the number of columns from breakpoint bp upwards.
func (*ProDescriptionsW) Columns 实验性
func (p *ProDescriptionsW) Columns(m map[Breakpoint]int) *ProDescriptionsWColumns sets the number of columns for several breakpoints.
func (*ProDescriptionsW) DataSource 实验性
func (p *ProDescriptionsW) DataSource(v *ProValues) *ProDescriptionsWDataSource binds the values (inline edits are written into it).
func (*ProDescriptionsW) Editable 实验性
func (p *ProDescriptionsW) Editable(onSave func(key string, v any, all ProValues, done func(error))) *ProDescriptionsWEditable turns on inline editing: every item without ReadOnly gets an edit icon. onSave (may be nil) receives the new value; call done from any goroutine. A nil error commits the value, an error stays shown under the editor.
func (*ProDescriptionsW) Editing 实验性
func (p *ProDescriptionsW) Editing(key string) boolEditing reports whether the item key is being edited.
func (*ProDescriptionsW) Err 实验性
func (p *ProDescriptionsW) Err() errorErr returns the last request error.
func (*ProDescriptionsW) Extra 实验性
func (p *ProDescriptionsW) Extra(fn func()) *ProDescriptionsWExtra builds actions right of the heading.
func (*ProDescriptionsW) ID 实验性
func (p *ProDescriptionsW) ID() IDID returns the widget ID (valid after Show).
func (*ProDescriptionsW) Loading 实验性
func (p *ProDescriptionsW) Loading() boolLoading reports a pending request.
func (*ProDescriptionsW) Reload 实验性
func (p *ProDescriptionsW) Reload()Reload runs the request again (valid after Show).
func (*ProDescriptionsW) Request 实验性
func (p *ProDescriptionsW) Request(fn func() (map[string]any, error)) *ProDescriptionsWRequest loads the values on a background goroutine; the list shows a loading mask meanwhile and an error banner when it fails.
func (*ProDescriptionsW) Saved 实验性
func (p *ProDescriptionsW) Saved() stringSaved returns the key of the item committed this frame ("" if none).
func (*ProDescriptionsW) Show 实验性
func (p *ProDescriptionsW) Show() *ProDescriptionsWShow builds the list.
func (*ProDescriptionsW) Size 实验性
func (p *ProDescriptionsW) Size(s ControlSize) *ProDescriptionsWSize sets the density (Large default, Middle, Small).
func (*ProDescriptionsW) Title 实验性
func (p *ProDescriptionsW) Title(s string) *ProDescriptionsWTitle sets the heading.
func (*ProDescriptionsW) Values 实验性
func (p *ProDescriptionsW) Values() ProValuesValues returns the current values.
func (*ProDescriptionsW) Vertical 实验性
func (p *ProDescriptionsW) Vertical() *ProDescriptionsWVertical puts labels above values.
ProEnum 实验性
type ProEnum struct {
Value, Label string
Status, Color string
// Children nests options for the cascader and treeSelect value types.
Children []ProEnum
// Disabled marks an option that can't be picked (Pro valueEnum
// disabled, es/field/components/Select/index.js
// proFieldParsingValueEnumToArray).
Disabled bool
}ProEnum is one value of an enumerated ProTable column (status, tag, select). Status is a badge status ("success", "error", "processing", "warning", "default"); Color a tag color.
ProField 实验性
type ProField struct {
Key, Label string
ValueType string // see the Value* constants (default text)
ValueEnum []ProEnum // options of select / radio / checkbox / status / tag
Placeholder string
Help string // hint under the control
Span int // grid columns out of 24 (default: 24 / form columns)
// Group puts the field in a titled ProFormGroup with the consecutive
// fields of the same Group (ProForm, ModalForm, StepsForm).
Group string
Width float32 // fixed control width (default: fill the column)
Initial any // value when the form starts or resets
// Validation: Required adds a required rule with the locale message;
// Rules check the value's text form; Validate checks the typed value
// against all values (cross-field); AsyncValidate runs after them.
Required bool
Rules []Rule
Validate func(v any, all ProValues) string
AsyncValidate func(v any, done func(msg string))
// Linkage: Dependencies lists keys whose change re-validates this
// field, refreshes Options and drops a value Options no longer offers.
Dependencies []string
Hide func(all ProValues) bool
Disable func(all ProValues) bool
Options func(all ProValues) []ProEnum
// Number fields.
Min, Max float64
Precision int
// Pick handles the upload field's trigger (open a file dialog); call
// done from any goroutine with the files to add.
Pick func(done func(files []UploadFile))
// Dragger shows the upload field as a drag area (Upload.Dragger):
// it highlights while files are dragged over it and takes dropped
// files (DropZone inside Upload).
Dragger bool
// Render replaces the built-in control (bind it to vals[Key]).
Render func(c *Context, vals ProValues)
// Readonly shows the value as read-only text (ProFormW.Readonly does
// it for every field); a read-only field is not validated.
Readonly bool
// OnCaptcha sends the code of a captcha field (call done from any
// goroutine; nil starts the countdown); the button then counts down
// CaptchaSeconds (default 60).
OnCaptcha func(vals ProValues, done func(error))
CaptchaSeconds int
// Captcha configures the phone key, button text and timing callback.
Captcha *ProFieldCaptcha
// Segmented configures the ValueSegmented editor (custom item content,
// direction, size, icons, etc.) before it is built.
Segmented func(w *SegmentedW)
// List gives the row fields of a formList field.
List *ProFieldList
// contains filtered or unexported fields
}ProField describes a form field; ProForm, QueryFilter, StepsForm, ModalForm and DrawerForm render fields from it.
func ProFormFieldSet 实验性
func ProFormFieldSet(c *Context, fs ProFieldSet) ProFieldProFormFieldSet turns a field set into a ProField for ProForm, QueryFilter, ModalForm, StepsForm …:
fields = append(fields, ui.ProFormFieldSet(c, ui.ProFieldSet{
Key: "budget", Label: "Budget", Separator: "~", Required: true,
Parts: []ui.ProField{{ValueType: ui.ValueDigit}, {ValueType: ui.ValueDigit}},
}))
ProFieldCaptcha 实验性
type ProFieldCaptcha struct {
// PhoneKey is the key of the phone field: inside a form that field is
// validated first and nothing is sent while it is invalid (Pro
// phoneName). OnCaptcha receives all values, the phone included.
PhoneKey string
// Text returns the button text while counting down (timing true, count
// = seconds left) or idle (count = the full countdown); nil uses the
// locale's "get code" / "resend in %d s" (Pro captchaTextRender).
Text func(timing bool, count int) string
// OnTiming receives the count whenever it changes: the full countdown
// when idle, then every second left while counting down (Pro onTiming).
OnTiming func(count int)
// contains filtered or unexported fields
}ProFieldCaptcha configures a captcha field beyond ProField.OnCaptcha and ProField.CaptchaSeconds (Pro ProFormCaptcha phoneName, captchaTextRender, onTiming).
ProFieldList 实验性
type ProFieldList struct {
Fields []ProField
Min, Max int // Max 0: no limit
AddText string // default: the locale's "add row"
// contains filtered or unexported fields
}ProFieldList configures a ValueFormList field: the fields of one row, the row count limits and the add button's text.
ProFieldLocale 实验性
type ProFieldLocale struct {
On, Off string // switch value text
StartFmt, EndFmt string // time range ends, arg: field label ("%s开始")
Min, Max string // digit range placeholders
RangeEndFmt string // accessible name of a digit range end, args: field label, Min / Max ("%s:%s")
// fromNow and second value types: JustNow for under a minute, AgoFmt /
// LaterFmt wrap an amount ("%s前"), the unit formats take a count
// ("%d 分钟"); second joins the day … second amounts.
JustNow, AgoFmt, LaterFmt string
SecondFmt, MinuteFmt, HourFmt, DayFmt, MonthFmt, YearFmt string
InvalidJSON string // jsonCode validation message
// contains filtered or unexported fields
}ProFieldLocale holds texts of ProField / ProColumn value types (editors and read-only views).
ProFieldMode 实验性
type ProFieldMode stringProFieldMode selects how ProFieldOf shows its value.
const (
ProFieldRead ProFieldMode = "read" // formatted read-only value (default)
ProFieldEdit ProFieldMode = "edit" // the value type's editor
)Modes of ProFieldOf.
实验性
ProFieldSet 实验性
type ProFieldSet struct {
Key, Label string
Parts []ProField // ValueType, ValueEnum, Placeholder, Width, Min / Max of each part
Separator string // text between the parts (e.g. "~"); empty: a gap
Required bool // every part must be filled
// Validate checks the combined value (e.g. min <= max).
Validate func(parts []any, all ProValues) string
Help string
Span int
Initial []any
}ProFieldSet combines several controls into one form value (Ant Design Pro ProFormFieldSet), such as a numeric range or a phone area code plus number. The value of Key is a []any with one entry per part (nil for an empty part); read it with ProValues.Parts.
ProFieldW 实验性
type ProFieldW struct {
// contains filtered or unexported fields
}ProFieldW renders a single value outside a form (Ant Design ProField): the same value types as ProForm, ProTable and ProDescriptions, read-only or as the editor, switched with Mode.
var price any = 12800.0
mode := ui.ProFieldRead
ui.ProFieldOf(c, ui.ProField{Label: "价格", ValueType: ui.ValueMoney}, &price).Mode(mode).Show()
func ProFieldOf 实验性
func ProFieldOf(c *Context, fd ProField, val *any) *ProFieldWProFieldOf starts a standalone field over *val described by fd (its Label names the editor for assistive technologies; Key may be empty); chain options, then Show. The Go type of *val follows the value type, as in ProValues.
ConfigProvider.Defaults("ProField", ...) keys: "mode" ("read" | "edit").
func (*ProFieldW) Changed 实验性
func (w *ProFieldW) Changed() boolChanged reports an edit of the value in the last Show.
func (*ProFieldW) ID 实验性
func (w *ProFieldW) ID() IDID returns the widget ID (valid after Show).
func (*ProFieldW) Mode 实验性
func (w *ProFieldW) Mode(m ProFieldMode) *ProFieldWMode switches between the read-only view and the editor.
func (*ProFieldW) Show 实验性
func (w *ProFieldW) Show() *ProFieldWShow builds the field.
ProFormGroupW 实验性
type ProFormGroupW struct {
// contains filtered or unexported fields
}ProFormGroupW builds a ProFormGroup.
func ProFormGroup 实验性
func ProFormGroup(c *Context, title string) *ProFormGroupWProFormGroup starts a group titled title ("" = no title row); chain options, then Body.
ConfigProvider.Defaults("ProFormGroup", ...) keys: "collapsible" (bool), "columns", "gutter", "size" (gap between rows, number).
func (*ProFormGroupW) Body 实验性
func (g *ProFormGroupW) Body(fn func()) *ProFormGroupWBody builds the group with fn as its items.
func (*ProFormGroupW) Collapsed 实验性
func (g *ProFormGroupW) Collapsed(v *bool) *ProFormGroupWCollapsed binds the folded state (implies Collapsible).
func (*ProFormGroupW) Collapsible 实验性
func (g *ProFormGroupW) Collapsible() *ProFormGroupWCollapsible lets a click on the title fold the items.
func (*ProFormGroupW) Columns 实验性
func (g *ProFormGroupW) Columns(n int) *ProFormGroupWColumns lays the items out n per line (0: stacked).
func (*ProFormGroupW) DefaultCollapsed 实验性
func (g *ProFormGroupW) DefaultCollapsed() *ProFormGroupWDefaultCollapsed starts an uncontrolled collapsible group folded.
func (*ProFormGroupW) Description 实验性
func (g *ProFormGroupW) Description(s string) *ProFormGroupWDescription adds a muted line under the title.
func (*ProFormGroupW) Extra 实验性
func (g *ProFormGroupW) Extra(fn func()) *ProFormGroupWExtra builds content at the right of the title row.
func (*ProFormGroupW) Gutter 实验性
func (g *ProFormGroupW) Gutter(px float32) *ProFormGroupWGutter sets the horizontal space between columns (default 24).
func (*ProFormGroupW) ID 实验性
func (g *ProFormGroupW) ID() IDID returns the group's widget ID (after Body).
func (*ProFormGroupW) Size 实验性
func (g *ProFormGroupW) Size(px float32) *ProFormGroupWSize sets the vertical space between item rows (default 0: the items' own margins).
func (*ProFormGroupW) Toggled 实验性
func (g *ProFormGroupW) Toggled() boolToggled reports a fold / unfold by the user this frame.
ProFormW 实验性
type ProFormW struct {
// contains filtered or unexported fields
}ProFormW renders a form from field definitions (Ant Design ProForm): a grid of fields whose controls follow their value types (shared with ProTable columns), linkage, validation (sync, cross-field, async), submit / reset buttons with a loading state and asynchronous initial values.
ui.ProForm(c, fields).Columns(2).
Request(func(done func(ui.ProValues, error)) { go load(done) }).
OnFinish(func(v ui.ProValues, done func(error)) { go save(v, done) }).
Show()
func ProForm 实验性
func ProForm(c *Context, fields []ProField) *ProFormWProForm starts a form over fields; chain options, then Show.
func (*ProFormW) Children 实验性
func (p *ProFormW) Children(fn func(f *FormW)) *ProFormWChildren builds extra items after the fields (FormList, custom items).
func (*ProFormW) Columns 实验性
func (p *ProFormW) Columns(n int) *ProFormWColumns lays fields out in a grid of n equal columns (ProField.Span overrides a field's width out of 24).
func (*ProFormW) Err 实验性
func (p *ProFormW) Err() errorErr returns the last OnFinish error.
func (*ProFormW) Finished 实验性
func (p *ProFormW) Finished() boolFinished reports a completed submit (OnFinish called done(nil)), once.
func (*ProFormW) Form 实验性
func (p *ProFormW) Form() *FormWForm returns the inner form of the last Show.
func (*ProFormW) Gutter 实验性
func (p *ProFormW) Gutter(px float32) *ProFormWGutter sets the horizontal gap between grid columns (default 24).
func (*ProFormW) Horizontal 实验性
func (p *ProFormW) Horizontal() *ProFormWHorizontal puts labels left of the controls (default: above).
func (*ProFormW) ID 实验性
func (p *ProFormW) ID() IDID returns the widget ID (valid after Show).
func (*ProFormW) LabelWidth 实验性
func (p *ProFormW) LabelWidth(px float32) *ProFormWLabelWidth sets the label width of a horizontal form.
func (*ProFormW) Loading 实验性
func (p *ProFormW) Loading() boolLoading reports the initial request in progress.
func (*ProFormW) NoReset 实验性
func (p *ProFormW) NoReset() *ProFormWNoReset hides the reset button.
func (*ProFormW) NoSubmitter 实验性
func (p *ProFormW) NoSubmitter() *ProFormWNoSubmitter hides the buttons (submit with Submit, e.g. from a modal).
func (*ProFormW) OnFinish 实验性
func (p *ProFormW) OnFinish(fn func(vals ProValues, done func(error))) *ProFormWOnFinish receives the values after a successful validation; call done (from any goroutine) when saved. The submit button spins meanwhile and a non-nil error is shown above the buttons.
func (*ProFormW) Readonly 实验性
func (p *ProFormW) Readonly(on bool) *ProFormWReadonly shows every field as its formatted read-only value (Ant ProForm readonly) and hides the submit / reset buttons; ProField.Readonly does it for one field. Read-only fields are not validated.
func (*ProFormW) Request 实验性
func (p *ProFormW) Request(fn func(done func(ProValues, error))) *ProFormWRequest loads the initial values asynchronously; call done from any goroutine. The form shows a loading mask meanwhile.
func (*ProFormW) Reset 实验性
func (p *ProFormW) Reset()Reset restores the initial values and clears validation.
func (*ProFormW) ResetText 实验性
func (p *ProFormW) ResetText(s string) *ProFormWResetText sets the reset button's text.
func (*ProFormW) Show 实验性
func (p *ProFormW) Show() *ProFormWShow builds the form.
func (*ProFormW) Submit 实验性
func (p *ProFormW) Submit()Submit validates (waiting for async rules) and calls OnFinish.
func (*ProFormW) SubmitText 实验性
func (p *ProFormW) SubmitText(s string) *ProFormWSubmitText sets the submit button's text.
func (*ProFormW) Submitter 实验性
func (p *ProFormW) Submitter(fn func(s *ProSubmitter)) *ProFormWSubmitter replaces the buttons.
func (*ProFormW) Submitting 实验性
func (p *ProFormW) Submitting() boolSubmitting reports validation or OnFinish in progress.
func (*ProFormW) Values 实验性
func (p *ProFormW) Values(v *ProValues) *ProFormWValues binds the values (otherwise the form keeps its own).
ProLayoutConfig 实验性
type ProLayoutConfig struct {
Title string
Logo *icon.Icon
Menu []MenuItem
Selected *string
Collapsed *bool
LightSider bool // explicitly request a light sider
NavTheme string // "light" (v3 default) or "dark"; LightSider still forces light
Breadcrumb []string // shown in the header
UserName string
Actions func() // extra header actions (left of the avatar)
Footer string
PageTitle string
// Layout is "side" (default: sider with logo and menu, header with
// the collapse toggle), "top" (header with logo and a horizontal
// menu, no sider) or "mix" (full-width header with logo and actions
// above a sider with the menu and a collapse trigger).
Layout string
// NoPadding drops the 24px padding of the content area, so a
// PageContainer (or any page) fills it edge to edge.
NoPadding bool
// Breakpoint collapses the sider when the window is narrower (side
// and mix layouts; XS = never).
Breakpoint Breakpoint
// SiderWidth overrides the expanded sider width (0: the theme's).
SiderWidth float32
// ContentWidth is "Fluid" (default) or "Fixed": the content is then
// centred in a 1152px GridContent in the top layout (Ant contentWidth).
ContentWidth string
// NoFixedHeader lets the header scroll away with the content (Ant
// fixedHeader=false, the v3 default). FixedHeader explicitly pins it.
NoFixedHeader bool
// FixedHeader explicitly pins the header; NoFixedHeader takes precedence.
FixedHeader bool
// NoFixSiderbar lets the sider scroll with the page (Ant
// fixSiderbar=false): sider and content share one scroll, so a long
// menu is reached by scrolling the page. By default the sider stays
// fixed and only the content area scrolls (side and mix layouts; in the
// side layout the header then scrolls with the page too).
NoFixSiderbar bool
// AutoBreadcrumb derives the breadcrumb from the menu path of
// *Selected (parent submenus, then the item) when Breadcrumb is empty;
// clicking an ancestor that is a menu item selects it. MenuPath gives
// the same path to the page (e.g. for PageContainer.Breadcrumb).
AutoBreadcrumb bool
// BreadcrumbRender adjusts the breadcrumb items (static or automatic)
// before they are shown; returning none hides the breadcrumb.
BreadcrumbRender func(items []BreadcrumbItem) []BreadcrumbItem
// Render hooks (Ant menuHeaderRender, headerRender ...). def builds the
// default part, so a hook can wrap or replace it.
//
// MenuHeaderRender builds the logo and title area (top of the sider;
// the start of the header in the top and mix layouts).
MenuHeaderRender func(def func(), collapsed bool)
// MenuFooterRender builds content under the sider menu (side layout).
MenuFooterRender func(collapsed bool)
// HeaderRender builds the whole header bar.
HeaderRender func(def func())
// HeaderContentRender builds the middle of the header: in the side
// layout it replaces the breadcrumb, in the top layout the horizontal
// menu, in the mix layout it follows the logo.
HeaderContentRender func()
// MenuItemRender rewrites every menu item (children first) before the
// menu is built: change labels, icons, Disabled, add Shortcut text.
// The menu draws the items itself, so the hook returns data, not UI.
MenuItemRender func(item MenuItem) MenuItem
// FooterRender builds the footer at the end of the content area in
// place of the default one (DefaultFooter with FooterLinks and Footer).
FooterRender func()
// FooterLinks are the links of the default footer, above the Footer
// text (Ant DefaultFooter links); read DefaultFooterW.Clicked through
// FooterRender to react, or give each link an OnClick.
FooterLinks []FooterLink
}ProLayoutConfig configures the admin shell.
ProListMetas 实验性
type ProListMetas[T any] struct {
Title func(row T) string
SubTitle func(c *Context, row T) // next to the title (tags)
Description func(row T) string
Avatar func(c *Context, row T)
Content func(c *Context, row T) // middle area
Actions func(c *Context, row T) // links at the end, split by bars
Extra func(c *Context, row T) // right-most (an image)
}ProListMetas maps a row to the parts of a ProList item. Every part is optional.
ProListW 实验性
type ProListW[T any] struct {
// contains filtered or unexported fields
}ProListW is a data-driven list (Ant Design Pro ProList): items built from metas, a toolbar with a title and actions, selection, expandable items, pagination, a loading state and a card grid mode.
ui.ProList(c, rows, metas).HeaderTitle("Projects").RowKey(key).
Selection(&sel).Pagination(5).Show()
func ProList 实验性
func ProList[T any](c *Context, rows []T, metas ProListMetas[T]) *ProListW[T]ProList starts a list over rows; chain options, then Show.
func (*ProListW[T]) Bordered 实验性
func (p *ProListW[T]) Bordered() *ProListW[T]Bordered frames the list.
func (*ProListW[T]) DefaultExpandAllRows 实验性
func (p *ProListW[T]) DefaultExpandAllRows(on bool) *ProListW[T]DefaultExpandAllRows controls the initial expansion of each row (default true).
func (*ProListW[T]) EmptyText 实验性
func (p *ProListW[T]) EmptyText(s string) *ProListW[T]EmptyText replaces the empty-state text.
func (*ProListW[T]) Err 实验性
func (p *ProListW[T]) Err() errorErr returns the error of the last Request.
func (*ProListW[T]) EstimatedItemHeight 实验性
func (p *ProListW[T]) EstimatedItemHeight(px float32) *ProListW[T]EstimatedItemHeight is the height Virtual assumes for an item not measured yet (List.EstimatedItemHeight).
func (*ProListW[T]) ExpandRowByClick 实验性
func (p *ProListW[T]) ExpandRowByClick() *ProListW[T]ExpandRowByClick toggles expansion when the row body is activated.
func (*ProListW[T]) Expandable 实验性
func (p *ProListW[T]) Expandable(fn func(c *Context, row T)) *ProListW[T]Expandable adds an expand toggle per item showing fn below it.
func (*ProListW[T]) ExpandedRowKeys 实验性
func (p *ProListW[T]) ExpandedRowKeys(keys *[]string) *ProListW[T]ExpandedRowKeys binds the expanded keys to application-owned state.
func (*ProListW[T]) Grid 实验性
func (p *ProListW[T]) Grid(n int) *ProListW[T]Grid lays the items out as cards in n columns.
func (*ProListW[T]) HeaderTitle 实验性
func (p *ProListW[T]) HeaderTitle(s string) *ProListW[T]HeaderTitle sets the toolbar title.
func (*ProListW[T]) Height 实验性
func (p *ProListW[T]) Height(px float32) *ProListW[T]Height fixes the height of the items' viewport (List.Height); the toolbar, selection bar and pager stay outside it.
func (*ProListW[T]) ID 实验性
func (p *ProListW[T]) ID() IDID returns the widget ID (valid after Show).
func (*ProListW[T]) IsLoading 实验性
func (p *ProListW[T]) IsLoading() boolIsLoading reports a Request in flight.
func (*ProListW[T]) ItemLayout 实验性
func (p *ProListW[T]) ItemLayout(s string) *ProListW[T]ItemLayout selects horizontal (default) or vertical item actions.
func (*ProListW[T]) Loading 实验性
func (p *ProListW[T]) Loading(on bool) *ProListW[T]Loading shows the loading mask.
func (*ProListW[T]) OnItemClick 实验性
func (p *ProListW[T]) OnItemClick(fn func(row T)) *ProListW[T]OnItemClick makes the items (cards in grid mode) clickable.
func (*ProListW[T]) Page 实验性
func (p *ProListW[T]) Page() intPage returns the current page (1-based).
func (*ProListW[T]) Pagination 实验性
func (p *ProListW[T]) Pagination(n int) *ProListW[T]Pagination shows n items per page with a pager.
func (*ProListW[T]) Reload 实验性
func (p *ProListW[T]) Reload()Reload loads the current page again (valid after Show).
func (*ProListW[T]) Request 实验性
func (p *ProListW[T]) Request(fn func(page, size int) ([]T, int, error)) *ProListW[T]Request loads the list page by page from a server: fn runs on a background goroutine with the 1-based page and the page size (set with Pagination, default 10) and returns the page's rows and the total count. The rows passed to ProList are ignored; the list shows a loading mask while a page loads and an error with a retry button when it fails.
func (*ProListW[T]) RowExpandable 实验性
func (p *ProListW[T]) RowExpandable(fn func(T) bool) *ProListW[T]RowExpandable determines which rows offer an expand control.
func (*ProListW[T]) RowKey 实验性
func (p *ProListW[T]) RowKey(f func(T) string) *ProListW[T]RowKey gives rows stable keys (selection and expansion follow them; default: the row index).
func (*ProListW[T]) Selection 实验性
func (p *ProListW[T]) Selection(keys *[]string) *ProListW[T]Selection adds a checkbox per item bound to the selected keys.
func (*ProListW[T]) SelectionChanged 实验性
func (p *ProListW[T]) SelectionChanged() boolSelectionChanged reports a selection change in the last Show.
func (*ProListW[T]) Show 实验性
func (p *ProListW[T]) Show() *ProListW[T]Show builds the list.
func (*ProListW[T]) Split 实验性
func (p *ProListW[T]) Split(on bool) *ProListW[T]Split toggles the lines between items (default on).
func (*ProListW[T]) ToolBar 实验性
func (p *ProListW[T]) ToolBar(fn func()) *ProListW[T]ToolBar builds actions at the right of the toolbar.
func (*ProListW[T]) Total 实验性
func (p *ProListW[T]) Total() intTotal returns the total count reported by Request.
func (*ProListW[T]) Virtual 实验性
func (p *ProListW[T]) Virtual() *ProListW[T]Virtual builds only the items in view (List.Virtual; needs Height). Item heights, expanded items included, are measured as they come into view and cached by RowKey; selection and expansion are kept by key and do not depend on which items are built. Keyboard focus in an item scrolled out of view is lost, as in the non-virtual Height form.
ProRequest 实验性
type ProRequest struct {
Page, PageSize int
Sort []SortState
Filters map[string][]string
Params map[string]string // query form values (non-empty only)
// ExtParams is the value given to ProTableW.Params (Ant params); a
// map[string]string / map[string]any is also merged into Params
// (the query form wins on a shared key).
ExtParams any
}ProRequest is what the request function receives.
ProResult 实验性
type ProResult[T any] struct {
Rows []T
Total int
Err error
}ProResult is delivered back by the request function (from any goroutine).
ProSettings 实验性
type ProSettings struct {
NavTheme string // "light", "dark" or "realDark"
PrimaryColor theme.Color // zero: the theme's brand color
Layout string // "side" (default), "top" or "mix"
ContentWidth string // "Fluid" (default) or "Fixed"
FixedHeader bool
FixSiderbar bool
ColorWeak bool
Compact bool
// contains filtered or unexported fields
}ProSettings are the shell settings edited by SettingDrawer.
func DefaultProSettings 实验性
func DefaultProSettings() ProSettingsDefaultProSettings returns Pro v3 defaults: light menu, side layout, fluid content, scrolling header and fixed side menu.
func (ProSettings) Apply 实验性
func (s ProSettings) Apply(cfg *ProLayoutConfig)Apply copies the layout settings into cfg.
ProSkeletonW 实验性
type ProSkeletonW struct {
// contains filtered or unexported fields
}ProSkeletonW builds a page skeleton.
func ProSkeleton 实验性
func ProSkeleton(c *Context, kind string) *ProSkeletonWProSkeleton starts a page skeleton of kind (SkeletonList, SkeletonResult or SkeletonDescriptions; "" = list). Defaults: active, with page header, 2 statistics, a toolbar and 5 list rows (4 table rows on the descriptions page).
Pro v3 picks the statistic count from the first breakpoint key that is true; antd's screens put xs/sm first, so in a browser that is always 2 (xs and sm both map to 2). Tango renders that observed default, not the md/xl entries of the lookup table.
func (*ProSkeletonW) Active 实验性
func (s *ProSkeletonW) Active(on bool) *ProSkeletonWActive turns the shimmer on or off.
func (*ProSkeletonW) Layout 实验性
func (s *ProSkeletonW) Layout(o ...layout.Option) *ProSkeletonWLayout applies layout options to the skeleton.
func (*ProSkeletonW) List 实验性
func (s *ProSkeletonW) List(n int) *ProSkeletonWList sets the number of list rows (list type, default 5) or table rows (descriptions type, default 4); 0 hides the list, or the divider and table. The list toolbar is controlled by Toolbar alone.
func (*ProSkeletonW) PageHeader 实验性
func (s *ProSkeletonW) PageHeader(on bool) *ProSkeletonWPageHeader shows or hides the page header placeholder.
func (*ProSkeletonW) Show 实验性
func (s *ProSkeletonW) Show() *BoxShow builds the skeleton.
func (*ProSkeletonW) Statistic 实验性
func (s *ProSkeletonW) Statistic(n int) *ProSkeletonWStatistic sets the number of statistic placeholders (list type; 0 hides them; default 2).
func (*ProSkeletonW) Toolbar 实验性
func (s *ProSkeletonW) Toolbar(on bool) *ProSkeletonWToolbar shows or hides the list toolbar placeholder.
ProStatisticW 实验性
type ProStatisticW struct {
// contains filtered or unexported fields
}ProStatisticW is the standalone Pro statistic (StatisticCard.Statistic). It shares StatisticCard's statistic renderer without adding a card surface.
func ProStatistic 实验性
func ProStatistic(c *Context, title string) *ProStatisticWProStatistic starts a compact Pro statistic. ui.Statistic is the antd statistic; this entry adds Pro layout, descriptions, status, tip and trend.
func (*ProStatisticW) Description 实验性
func (w *ProStatisticW) Description(fn func()) *ProStatisticWDescription builds description content.
func (*ProStatisticW) Icon 实验性
func (w *ProStatisticW) Icon(ic *icon.Icon) *ProStatisticWIcon adds a leading icon.
func (*ProStatisticW) Prefix 实验性
func (w *ProStatisticW) Prefix(s string) *ProStatisticWPrefix adds text before the value.
func (*ProStatisticW) Show 实验性
func (w *ProStatisticW) Show() *ProStatisticWShow builds a standalone statistic. Consecutive standalone statistics have a 4px block gap, as in Pro's `& + &` rule.
func (*ProStatisticW) StatisticLayout 实验性
func (w *ProStatisticW) StatisticLayout(s string) *ProStatisticWStatisticLayout sets vertical, horizontal or inline layout.
func (*ProStatisticW) Status 实验性
func (w *ProStatisticW) Status(s string) *ProStatisticWStatus adds a status dot.
func (*ProStatisticW) Suffix 实验性
func (w *ProStatisticW) Suffix(s string) *ProStatisticWSuffix adds text after the value.
func (*ProStatisticW) Tooltip 实验性
func (w *ProStatisticW) Tooltip(s string) *ProStatisticWTooltip adds a title tooltip.
func (*ProStatisticW) Trend 实验性
func (w *ProStatisticW) Trend(s string) *ProStatisticWTrend sets the trend direction.
func (*ProStatisticW) TrendColors 实验性
func (w *ProStatisticW) TrendColors(up, down theme.Color) *ProStatisticWTrendColors overrides the trend colors.
func (*ProStatisticW) Value 实验性
func (w *ProStatisticW) Value(v float64, precision int) *ProStatisticWValue formats a numeric value.
func (*ProStatisticW) ValueColor 实验性
func (w *ProStatisticW) ValueColor(col theme.Color) *ProStatisticWValueColor overrides the value color.
func (*ProStatisticW) ValueText 实验性
func (w *ProStatisticW) ValueText(s string) *ProStatisticWValueText sets a preformatted value.
ProSubmitter 实验性
type ProSubmitter struct {
// contains filtered or unexported fields
}ProSubmitter is passed to a custom submitter.
func (*ProSubmitter) Context 实验性
func (s *ProSubmitter) Context() *ContextContext returns the build context.
func (*ProSubmitter) Loading 实验性
func (s *ProSubmitter) Loading() boolLoading reports a running submit (show it on the submit button).
func (*ProSubmitter) Reset 实验性
func (s *ProSubmitter) Reset()Reset restores the initial values.
func (*ProSubmitter) Submit 实验性
func (s *ProSubmitter) Submit()Submit validates and submits the form.
ProTableLocale 实验性
type ProTableLocale struct {
Query, Reload, Density, DensityDefault, DensityMiddle, DensityCompact string
ColumnSetting, ColumnDisplay, ClearSelection string
LoadErrorFmt string // alert text, arg: error message
// contains filtered or unexported fields
}ProTableLocale holds the ProTable search form and toolbar texts.
ProTableW 实验性
type ProTableW[T any] struct {
// contains filtered or unexported fields
}ProTableW is a query list page: an auto-generated query form, a toolbar (refresh, density, column settings, fullscreen) and a table fed by an asynchronous request function.
func ProTable 实验性
func ProTable[T any](c *Context, cols []ProColumn[T]) *ProTableW[T]ProTable starts a ProTable; set Request, then Show.
ConfigProvider.Defaults("ProTable", ...) keys: "search", "bordered", "options" (bool), "pagination" (false, a page size or Props{"pageSize": n}), "size" (density: "small" | "middle" | "large"), "headerTitle" (string), "polling" (time.Duration or milliseconds).
func (*ProTableW[T]) Bordered 实验性
func (p *ProTableW[T]) Bordered() *ProTableW[T]Bordered draws cell borders.
func (*ProTableW[T]) ColumnsState 实验性
func (p *ProTableW[T]) ColumnsState(s *TableColumnState) *ProTableW[T]ColumnsState binds the column state (order, visibility, widths, pinned side) to *s, so the application controls it (Ant columnsState.value).
func (*ProTableW[T]) DragSort 实验性
func (p *ProTableW[T]) DragSort(fn func(from, to int)) *ProTableW[T]DragSort adds a drag handle column (Ant Design Pro DragSortTable): dropping a row calls fn with the indices of the moved row and of the row it was dropped on, both in the current page (Rows). Reorder the data (locally or on the server) and Reload, or reorder the page in place with MovePageRow.
func (*ProTableW[T]) Expandable 实验性
func (p *ProTableW[T]) Expandable(fn func(row T)) *ProTableW[T]Expandable adds detail panels.
func (*ProTableW[T]) FullScreen 实验性
func (p *ProTableW[T]) FullScreen(on bool) *ProTableW[T]FullScreen enables the fullscreen toolbar option (v3 default: false).
func (*ProTableW[T]) Loading 实验性
func (p *ProTableW[T]) Loading() boolLoading reports a pending request.
func (*ProTableW[T]) MovePageRow 实验性
func (p *ProTableW[T]) MovePageRow(from, to int)MovePageRow moves row from to the position of row to in the current page without a new request (valid after Show; use it from DragSort).
func (*ProTableW[T]) NoOptions 实验性
func (p *ProTableW[T]) NoOptions() *ProTableW[T]NoOptions hides the toolbar setting icons (Ant options={false}).
func (*ProTableW[T]) NoPagination 实验性
func (p *ProTableW[T]) NoPagination() *ProTableW[T]NoPagination drops the pager: requests ask for every row (PageSize 0).
func (*ProTableW[T]) NoSearch 实验性
func (p *ProTableW[T]) NoSearch() *ProTableW[T]NoSearch hides the query form.
func (*ProTableW[T]) NoTableAlert 实验性
func (p *ProTableW[T]) NoTableAlert() *ProTableW[T]NoTableAlert hides the selection bar (Ant tableAlertRender={false}).
func (*ProTableW[T]) OnColumnsStateChange 实验性
func (p *ProTableW[T]) OnColumnsStateChange(fn func(TableColumnState)) *ProTableW[T]OnColumnsStateChange is called with the new column state after the user changes it in the column settings or by resizing (Ant columnsState.onChange).
func (*ProTableW[T]) PageSize 实验性
func (p *ProTableW[T]) PageSize(n int) *ProTableW[T]PageSize sets the initial page size (default 10).
func (*ProTableW[T]) Params 实验性
func (p *ProTableW[T]) Params(v any) *ProTableW[T]Params sets external request parameters (Ant params): a change of the value (compared by its printed form) requests page 1 again. The value reaches the request as ProRequest.ExtParams; maps are also merged into ProRequest.Params.
func (*ProTableW[T]) PausePolling 实验性
func (p *ProTableW[T]) PausePolling()PausePolling stops polling until ResumePolling (valid after Show).
func (*ProTableW[T]) PersistColumnsState 实验性
func (p *ProTableW[T]) PersistColumnsState(key string, store ColumnsStateStore) *ProTableW[T]PersistColumnsState loads the column state from store under key once and saves every change there (Ant columnsState.persistenceKey); the store decides where the state lives.
func (*ProTableW[T]) Polling 实验性
func (p *ProTableW[T]) Polling(d time.Duration) *ProTableW[T]Polling requests the current page again every d after the previous result arrived (0: off). Polling requests keep the rows on screen without the loading mask; PausePolling / ResumePolling control it.
func (*ProTableW[T]) PollingPaused 实验性
func (p *ProTableW[T]) PollingPaused() boolPollingPaused reports whether polling is paused.
func (*ProTableW[T]) Reload 实验性
func (p *ProTableW[T]) Reload()Reload requests the data again (valid after Show).
func (*ProTableW[T]) Request 实验性
func (p *ProTableW[T]) Request(fn func(req ProRequest, done func(ProResult[T]))) *ProTableW[T]Request sets the data source. It is called on the UI thread whenever the page, sort, filters or query change; call done (from any goroutine) with the page rows and total. The table shows a loading mask meanwhile and an error banner if Err is set.
func (*ProTableW[T]) ResumePolling 实验性
func (p *ProTableW[T]) ResumePolling()ResumePolling restarts paused polling (valid after Show); the next poll is due one interval after the last result.
func (*ProTableW[T]) RowClass 实验性
func (p *ProTableW[T]) RowClass(fn func(row T) RowStyle) *ProTableW[T]RowClass styles rows (see TableW.RowClass).
func (*ProTableW[T]) RowHeight 实验性
func (p *ProTableW[T]) RowHeight(h float32) *ProTableW[T]RowHeight overrides the row height derived from the density (TableW.RowHeight).
func (*ProTableW[T]) RowKey 实验性
func (p *ProTableW[T]) RowKey(f func(T) string) *ProTableW[T]RowKey gives rows stable keys (selection across pages).
func (*ProTableW[T]) Rows 实验性
func (p *ProTableW[T]) Rows() []TRows returns the rows of the current page.
func (*ProTableW[T]) ScrollX 实验性
func (p *ProTableW[T]) ScrollX(w float32) *ProTableW[T]ScrollX sets the table's scroll width.
func (*ProTableW[T]) ScrollY 实验性
func (p *ProTableW[T]) ScrollY(maxH float32) *ProTableW[T]ScrollY bounds the table body to maxH (TableW.ScrollY): the header stays in place and only the visible rows of the page are built, so a page of many thousand rows stays fast. The toolbar, search form, alert and pager stay outside the scrolling body. Default 0: unbounded, every row of the page is built.
func (*ProTableW[T]) Selection 实验性
func (p *ProTableW[T]) Selection(keys *[]string) *ProTableW[T]Selection binds selected row keys (kept across pages).
func (*ProTableW[T]) Show 实验性
func (p *ProTableW[T]) Show() *ProTableW[T]Show builds the ProTable.
func (*ProTableW[T]) Table 实验性
func (p *ProTableW[T]) Table() *TableWTable returns the inner table of the last Show.
func (*ProTableW[T]) TableAlertOptionRender 实验性
func (p *ProTableW[T]) TableAlertOptionRender(fn func(keys []string, clear func())) *ProTableW[T]TableAlertOptionRender replaces the actions of the selection bar (the default clear link), e.g. with batch operations (Ant tableAlertOptionRender).
func (*ProTableW[T]) TableAlertRender 实验性
func (p *ProTableW[T]) TableAlertRender(fn func(keys []string, clear func())) *ProTableW[T]TableAlertRender replaces the text of the selection bar (Ant tableAlertRender); clear empties the selection.
func (*ProTableW[T]) Title 实验性
func (p *ProTableW[T]) Title(s string) *ProTableW[T]Title sets the toolbar title.
func (*ProTableW[T]) ToolBar 实验性
func (p *ProTableW[T]) ToolBar(fn func()) *ProTableW[T]ToolBar adds actions (e.g. a "新建" button) left of the toolbar icons.
func (*ProTableW[T]) Toolbar 实验性
func (p *ProTableW[T]) Toolbar(fn func(*ListToolBarW)) *ProTableW[T]Toolbar configures the public ListToolBar used by ProTable (search, subtitle, tooltip, filters, tabs and menus). ToolBar still adds actions.
func (*ProTableW[T]) Virtual 实验性
func (p *ProTableW[T]) Virtual() *ProTableW[T]Virtual is TableW.Virtual for the inner table: with ScrollY the body is windowed either way, Virtual states the intent and, like TableW.Virtual, takes the theme's Table V2 row height where it has one (Element Plus). Otherwise rows keep the height of the density (the density setting) unless RowHeight overrides it.
ProValues 实验性
type ProValues map[string]anyProValues holds form values by field key. The Go type depends on the value type: string (text, select, radio ...), float64 (digit, money, percent, rate, slider, progress), time.Time (date, dateTime), [2]time.Time (dateRange), []string (multiSelect, checkbox), bool (switch). A missing key is an empty value.
func (ProValues) Bool 实验性
func (v ProValues) Bool(k string) boolBool returns a switch value.
func (ProValues) Clone 实验性
func (v ProValues) Clone() ProValuesClone copies the map (slices are copied too).
func (ProValues) DigitRange 实验性
func (v ProValues) DigitRange(k string) [2]float64DigitRange returns a number range; a missing value or end is NaN.
func (ProValues) Files 实验性
func (v ProValues) Files(k string) []UploadFileFiles returns an upload value.
func (ProValues) Float 实验性
func (v ProValues) Float(k string) float64Float returns a number value (0 when missing or not a number).
func (ProValues) Parts 实验性
func (v ProValues) Parts(k string) []anyParts returns the value of a field set (nil when missing).
func (ProValues) Range 实验性
func (v ProValues) Range(k string) [2]time.TimeRange returns a date range value.
func (ProValues) String 实验性
func (v ProValues) String(k string) stringString returns the value of k as text ("" when missing).
func (ProValues) Strings 实验性
func (v ProValues) Strings(k string) []stringStrings returns a multi-value (multiSelect, checkbox, cascader path).
func (ProValues) Time 实验性
func (v ProValues) Time(k string) time.TimeTime returns a date value (zero when missing).
ProgressW
type ProgressW struct {
// contains filtered or unexported fields
}ProgressW is the full progress indicator: line / circle / dashboard types, steps, gradients, success segment, inside text, stripes and indeterminate motion.
func Progress
func Progress(c *Context, percent float64) *ProgressWProgress adds a progress indicator (percent 0..100): a line bar by default, Circle/Dashboard for rings.
func (*ProgressW) A11yLabel
func (p *ProgressW) A11yLabel(s string) *ProgressWA11yLabel sets the accessible name (default: the Locale's "progress").
func (*ProgressW) Circle
func (p *ProgressW) Circle(size float32) *ProgressWCircle is Type("circle") with a diameter.
func (*ProgressW) Color
func (p *ProgressW) Color(col theme.Color) *ProgressWColor overrides the bar color.
func (*ProgressW) ColorFunc
func (p *ProgressW) ColorFunc(fn func(percent float64) theme.Color) *ProgressWColorFunc picks the bar color from the percentage (Element color function; a color array is a ColorFunc with thresholds).
func (*ProgressW) Dashboard
func (p *ProgressW) Dashboard(size float32) *ProgressWDashboard is Type("dashboard") with a diameter.
func (*ProgressW) Format
func (p *ProgressW) Format(f func(percent float64) string) *ProgressWFormat customises the info text.
func (*ProgressW) GapDegree
func (p *ProgressW) GapDegree(d float64) *ProgressWGapDegree sets the ring opening in degrees (dashboard default 75°; a circle with GapDegree opens too, like antd).
func (*ProgressW) GapPlacement
func (p *ProgressW) GapPlacement(s string) *ProgressWGapPlacement sets where the ring opening sits: "bottom" (default), "top", "start" or "end" (logical: mirrored in RTL). antd 6 gapPlacement (gapPosition is deprecated there).
func (*ProgressW) Gradient
func (p *ProgressW) Gradient(a, b theme.Color) *ProgressWGradient paints the bar from a to b.
func (*ProgressW) HideInfo
func (p *ProgressW) HideInfo() *ProgressWHideInfo hides the percentage text / status icon.
func (*ProgressW) Indeterminate
func (p *ProgressW) Indeterminate() *ProgressWIndeterminate shows an endlessly moving segment (Element).
func (*ProgressW) Layout
func (p *ProgressW) Layout(o ...layout.Option) *ProgressWLayout applies layout options.
func (*ProgressW) PercentPosition
func (p *ProgressW) PercentPosition(align, typ string) *ProgressWPercentPosition places the info text of a line bar (antd 6 percentPosition): align "start", "center" or "end" (default); typ "outer" (default; center puts it under the bar) or "inner" (inside the filled part, like Element text-inside).
func (*ProgressW) RailColor
func (p *ProgressW) RailColor(col theme.Color) *ProgressWRailColor sets the color of the unfilled rail (antd railColor).
func (*ProgressW) ShowInfo
func (p *ProgressW) ShowInfo() *ProgressWShowInfo shows the percentage text / status icon. It is the default, except for a line bar under a theme whose ProgressToken.ShowInfo is false (shadcn: like shadcn/ui's Progress, only the bar unless asked).
func (*ProgressW) Small
func (p *ProgressW) Small() *ProgressWSmall uses the compact size.
func (*ProgressW) Square
func (p *ProgressW) Square() *ProgressWSquare uses butt line caps instead of round ones.
func (*ProgressW) Status
func (p *ProgressW) Status(s string) *ProgressWStatus: "active" (Ant shimmer), "success", "exception", "warning".
func (*ProgressW) Steps
func (p *ProgressW) Steps(n int) *ProgressWSteps splits the bar (or ring) into n segments.
func (*ProgressW) StepsGap
func (p *ProgressW) StepsGap(px float32) *ProgressWStepsGap sets the gap between step segments in px (antd steps.gap; default 2).
func (*ProgressW) Striped
func (p *ProgressW) Striped(flow bool) *ProgressWStriped draws diagonal stripes; flow animates them.
func (*ProgressW) StrokeWidth
func (p *ProgressW) StrokeWidth(w float32) *ProgressWStrokeWidth sets the bar thickness / ring width in px.
func (*ProgressW) Success
func (p *ProgressW) Success(pct float64) *ProgressWSuccess shows the first pct percent in the success color (Ant success).
func (*ProgressW) TextInside
func (p *ProgressW) TextInside() *ProgressWTextInside draws the percentage inside the bar (Element text-inside).
func (*ProgressW) TrailColor
func (p *ProgressW) TrailColor(col theme.Color) *ProgressWTrailColor sets the rail color.
Deprecated: use RailColor (antd 6 renamed trailColor to railColor).
func (*ProgressW) Type
func (p *ProgressW) Type(t string) *ProgressWType selects "line", "circle" or "dashboard".
func (*ProgressW) Width
func (p *ProgressW) Width(px float32) *ProgressWWidth sets the line length (or circle diameter).
PromptItem 实验性
type PromptItem struct {
Key string
Label string
Description string
Icon *icon.Icon
Disabled bool
// contains filtered or unexported fields
}PromptItem is one suggestion card of Prompts.
PromptsW 实验性
type PromptsW struct {
// contains filtered or unexported fields
}PromptsW is a group of clickable prompt suggestion cards (the empty state of a chat, follow-up questions under an answer). Not to be confused with Prompt, the input dialog.
func Prompts 实验性
func Prompts(c *Context, items []PromptItem) *PromptsWPrompts adds prompt cards for items.
if k, ok := ui.Prompts(c, prompts).Title("试试这样问").Wrap().Clicked(); ok { ask(k) }
func (*PromptsW) CardWidth 实验性
func (w *PromptsW) CardWidth(px float32) *PromptsWCardWidth sets the minimum card width when wrapping (default 200).
func (*PromptsW) Clicked 实验性
func (w *PromptsW) Clicked() (string, bool)Clicked returns the key of the card activated this frame.
func (*PromptsW) Layout 实验性
func (w *PromptsW) Layout(opts ...layout.Option) *PromptsWLayout applies layout options to the group.
func (*PromptsW) Title 实验性
func (w *PromptsW) Title(s string) *PromptsWTitle shows a heading above the cards (also the accessible name).
func (*PromptsW) Vertical 实验性
func (w *PromptsW) Vertical() *PromptsWVertical stacks the cards in a column.
func (*PromptsW) Wrap 实验性
func (w *PromptsW) Wrap() *PromptsWWrap lets the cards wrap onto more rows instead of shrinking.
Props 实验性
type Props map[string]anyProps are default properties of one component, by property name ("size", "round", "duration" ...). Components document the keys they read.
QRCodeLocale 实验性
type QRCodeLocale struct {
Expired, Refresh, Scanned string
// contains filtered or unexported fields
}QRCodeLocale holds the QRCode status masks.
QRCodeW 实验性
type QRCodeW struct {
// contains filtered or unexported fields
}QRCodeW renders a QR code (Ant Design QRCode / Element has none; the Element flavor keeps the same component with Element tokens).
func QRCode 实验性
func QRCode(c *Context, value string) *QRCodeWQRCode adds a QR code for value (default 160px, level M, bordered). An empty value draws nothing (Ant renders null), keeping the box size.
func (*QRCodeW) A11yLabel 实验性
func (q *QRCodeW) A11yLabel(s string) *QRCodeWA11yLabel sets the accessible name (default: the encoded value).
func (*QRCodeW) Bg 实验性
func (q *QRCodeW) Bg(col theme.Color) *QRCodeWBg sets the background color.
func (*QRCodeW) BoostLevel 实验性
func (q *QRCodeW) BoostLevel(on bool) *QRCodeWBoostLevel(false) keeps the requested error-correction level; by default (Ant boostLevel true) the level is raised as far as the code keeps the same version (size).
func (*QRCodeW) Bordered 实验性
func (q *QRCodeW) Bordered(on bool) *QRCodeWBordered toggles the outer border.
func (*QRCodeW) Color 实验性
func (q *QRCodeW) Color(col theme.Color) *QRCodeWColor sets the module color.
func (*QRCodeW) Icon 实验性
func (q *QRCodeW) Icon(img image.Image) *QRCodeWIcon draws img in the center (use level "H" so the code stays readable).
func (*QRCodeW) IconSize 实验性
func (q *QRCodeW) IconSize(px float32) *QRCodeWIconSize sets the center icon size (default 40).
func (*QRCodeW) Level 实验性
func (q *QRCodeW) Level(l string) *QRCodeWLevel sets the error-correction level: "L", "M", "Q" or "H".
func (*QRCodeW) MarginSize 实验性
func (q *QRCodeW) MarginSize(n int) *QRCodeWMarginSize adds a quiet zone of n modules around the code (Ant marginSize, default 0).
func (*QRCodeW) Matrix 实验性
func (q *QRCodeW) Matrix() *QRMatrixMatrix returns the encoded matrix (nil if encoding failed).
func (*QRCodeW) Refreshed 实验性
func (q *QRCodeW) Refreshed() boolRefreshed reports a click on the "点击刷新" action of an expired code.
func (*QRCodeW) Size 实验性
func (q *QRCodeW) Size(px float32) *QRCodeWSize sets the outer size in px.
func (*QRCodeW) Status 实验性
func (q *QRCodeW) Status(s string) *QRCodeWStatus sets "active" (default), "expired", "loading" or "scanned".
QRLevel 实验性
type QRLevel uint8QRLevel is the error-correction level.
Append-only: never reorder or insert; the zero value stays QRLevelL.
const (
QRLevelL QRLevel = iota // ~7% recovery
QRLevelM // ~15%
QRLevelQ // ~25%
QRLevelH // ~30%
)实验性
func ParseQRLevel 实验性
func ParseQRLevel(s string) QRLevelParseQRLevel maps "L","M","Q","H" (any case) to a level; unknown → M.
QRMatrix 实验性
type QRMatrix struct {
Version int
Level QRLevel
Mask int
Size int
// contains filtered or unexported fields
}QRMatrix is an encoded symbol without quiet zone. Dark(x, y) reports a dark module at column x, row y.
func EncodeQR 实验性
func EncodeQR(s string, level QRLevel) (*QRMatrix, error)EncodeQR encodes text at the smallest version that fits level. Digits use numeric mode, [0-9A-Z $%*+-./:] alphanumeric mode, anything else UTF-8 bytes.
func (*QRMatrix) Dark 实验性
func (m *QRMatrix) Dark(x, y int) boolDark reports whether module (x, y) is dark. Out of range is light.
QueryFilterW 实验性
type QueryFilterW struct {
// contains filtered or unexported fields
}QueryFilterW is a collapsible query form (Ant Design Pro QueryFilter): fields flow in 1–4 columns by width with the buttons in the last cell; beyond the first row they fold behind an expand link. ProTable uses it for its search form.
q := ui.QueryFilter(c, fields).Values(&query).Show()
if q.Searched() { reload(q.Params()) }
func QueryFilter 实验性
func QueryFilter(c *Context, fields []ProField) *QueryFilterWQueryFilter starts a query form over fields; chain options, then Show.
ConfigProvider.Defaults("QueryFilter", ...) keys: "labelWidth" (number), "defaultCollapsed" (bool, false = start expanded), "searchText", "resetText" (string).
func (*QueryFilterW) DefaultExpanded 实验性
func (q *QueryFilterW) DefaultExpanded() *QueryFilterWDefaultExpanded starts with every field shown.
func (*QueryFilterW) ID 实验性
func (q *QueryFilterW) ID() IDID returns the widget ID (valid after Show).
func (*QueryFilterW) LabelWidth 实验性
func (q *QueryFilterW) LabelWidth(px float32) *QueryFilterWLabelWidth sets the label width (default 80).
func (*QueryFilterW) Loading 实验性
func (q *QueryFilterW) Loading(on bool) *QueryFilterWLoading spins the search button.
func (*QueryFilterW) Params 实验性
func (q *QueryFilterW) Params() map[string]stringParams returns the non-empty values as text (dates as 2006-01-02).
func (*QueryFilterW) ResetClicked 实验性
func (q *QueryFilterW) ResetClicked() boolResetClicked reports a reset in the last Show.
func (*QueryFilterW) ResetText 实验性
func (q *QueryFilterW) ResetText(s string) *QueryFilterWResetText sets the reset button's text.
func (*QueryFilterW) SearchText 实验性
func (q *QueryFilterW) SearchText(s string) *QueryFilterWSearchText sets the search button's text.
func (*QueryFilterW) Searched 实验性
func (q *QueryFilterW) Searched() boolSearched reports a search (or a reset, which searches again) in the last Show.
func (*QueryFilterW) Show 实验性
func (q *QueryFilterW) Show() *QueryFilterWShow builds the query form.
func (*QueryFilterW) Values 实验性
func (q *QueryFilterW) Values(v *ProValues) *QueryFilterWValues binds the values (otherwise the filter keeps its own).
RadioGroupW
type RadioGroupW struct {
// contains filtered or unexported fields
}RadioGroupW is a group of mutually exclusive options.
func RadioGroup
func RadioGroup(c *Context, val *string, opts []Option) *RadioGroupWRadioGroup adds radio options bound to *val.
func (*RadioGroupW) A11yLabel
func (g *RadioGroupW) A11yLabel(s string) *RadioGroupWA11yLabel names the group for screen readers (inside a FormItem the item label is used).
func (*RadioGroupW) Block
func (g *RadioGroupW) Block() *RadioGroupWBlock stretches the group to the full width and shares it equally among the options (antd block, typically with Buttons).
func (*RadioGroupW) Border
func (g *RadioGroupW) Border() *RadioGroupWBorder draws each radio with a frame (see RadioW.Border); it has no effect on the button style.
func (*RadioGroupW) Buttons
func (g *RadioGroupW) Buttons() *RadioGroupWButtons renders the group as segmented buttons.
func (*RadioGroupW) Changed
func (g *RadioGroupW) Changed() boolChanged reports a selection change this frame.
func (*RadioGroupW) Disabled
func (g *RadioGroupW) Disabled(on bool) *RadioGroupWDisabled disables every option of the group (radios or buttons).
func (*RadioGroupW) Orientation
func (g *RadioGroupW) Orientation(o string) *RadioGroupWOrientation sets the direction of the options: "horizontal" (default) or "vertical" (antd 6 orientation). Other values are ignored.
func (*RadioGroupW) Size
func (g *RadioGroupW) Size(s ControlSize) *RadioGroupWSize sets the size of the buttons (and of the radios: label font and Border height).
func (*RadioGroupW) Solid
func (g *RadioGroupW) Solid() *RadioGroupWSolid fills the selected button with the primary color.
func (*RadioGroupW) Vertical
func (g *RadioGroupW) Vertical() *RadioGroupWVertical stacks the options in a column (antd 6 vertical); buttons join top to bottom.
RadioW
type RadioW struct {
// contains filtered or unexported fields
}RadioW is a single radio button.
func Radio
func Radio(c *Context, label string, checked bool) *RadioWRadio adds a radio button; it reports Clicked so the caller can select it.
func (*RadioW) Border
func (w *RadioW) Border() *RadioWBorder draws a frame around the circle and the label (Element el-radio border); a checked one gets a brand-colored frame.
func (*RadioW) Clicked
func (w *RadioW) Clicked() boolClicked reports activation.
func (*RadioW) Disabled
func (w *RadioW) Disabled(on bool) *RadioWfunc (*RadioW) Size
func (w *RadioW) Size(s ControlSize) *RadioWSize sets the radio size: the label font and the height of the Border style.
func (*RadioW) Status
func (w *RadioW) Status(s string) *RadioWStatus sets the validation status ("error" marks the radio invalid).
RangePickerW 实验性
type RangePickerW struct {
// contains filtered or unexported fields
}RangePickerW selects a date range in two adjacent month panels.
func RangePicker 实验性
func RangePicker(c *Context, val *[2]time.Time) *RangePickerWRangePicker adds a date range input bound to *val ([start, end], zero = empty). The first click picks one end, the second click the other; the result is ordered. Picker switches to week, month, quarter or year ranges. Each end can also be typed: printable keys edit the active end in place; Enter (or leaving the field) applies valid text, invalid text is dropped.
func (*RangePickerW) A11yLabel 实验性
func (w *RangePickerW) A11yLabel(s string) *RangePickerWA11yLabel sets the accessible name (inside a FormItem the item label is used; otherwise the two placeholders).
func (*RangePickerW) AllowClear 实验性
func (w *RangePickerW) AllowClear(on bool) *RangePickerWfunc (*RangePickerW) Changed 实验性
func (w *RangePickerW) Changed() boolChanged reports a committed range this frame.
func (*RangePickerW) Disabled 实验性
func (w *RangePickerW) Disabled(on bool) *RangePickerWDisabled disables the picker.
func (*RangePickerW) DisabledDate 实验性
func (w *RangePickerW) DisabledDate(fn func(time.Time) bool) *RangePickerWDisabledDate marks days that cannot be picked.
func (*RangePickerW) DisabledTime 实验性
func (w *RangePickerW) DisabledTime(fn func(day time.Time, end bool) DisabledTimes) *RangePickerWDisabledTime disables hours, minutes and seconds per day in the ShowTime columns (Ant disabledTime with type "start" / "end"): fn receives the drafted day of an end (UTC midnight) and end=false for the start, true for the end. A range with a disabled clock cannot be confirmed.
func (*RangePickerW) Format 实验性
func (w *RangePickerW) Format(f string) *RangePickerWfunc (*RangePickerW) IsOpen 实验性
func (w *RangePickerW) IsOpen() boolIsOpen reports whether the panels are shown.
func (*RangePickerW) Layout 实验性
func (w *RangePickerW) Layout(o ...layout.Option) *RangePickerWfunc (*RangePickerW) MaxDate 实验性
func (w *RangePickerW) MaxDate(t time.Time) *RangePickerWMaxDate limits the pickable dates (Ant maxDate), like MinDate.
func (*RangePickerW) MinDate 实验性
func (w *RangePickerW) MinDate(t time.Time) *RangePickerWMinDate limits the pickable dates (Ant minDate): periods wholly before t cannot be picked or typed, and the panel arrows stop at t's page.
func (*RangePickerW) Open 实验性
func (w *RangePickerW) Open() *RangePickerWOpen forces the panels open (screenshots, tests).
func (*RangePickerW) Order 实验性
func (w *RangePickerW) Order(on bool) *RangePickerWOrder toggles sorting the two ends (Ant order, on by default). With Order(false) the first pick is the start and the second the end, even when the end comes earlier.
func (*RangePickerW) Picker 实验性
func (w *RangePickerW) Picker(p PickerType) *RangePickerWPicker sets the granularity of both ends: PickerDate (default), PickerWeek, PickerMonth, PickerQuarter or PickerYear (Ant picker, Element type="monthrange" / "yearrange"). Ends are the first days of their periods (UTC midnights, like DatePicker with Picker); ShowTime is ignored.
func (*RangePickerW) Placeholder 实验性
func (w *RangePickerW) Placeholder(start, end string) *RangePickerWfunc (*RangePickerW) Placement 实验性
func (w *RangePickerW) Placement(p Placement) *RangePickerWPlacement sets where the panels open: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement); they flip when there is no room.
func (*RangePickerW) Presets 实验性
func (w *RangePickerW) Presets(p ...DatePreset) *RangePickerWfunc (*RangePickerW) Separator 实验性
func (w *RangePickerW) Separator(s string) *RangePickerWSeparator sets the text between the two ends (Ant separator; default the Locale's RangeSeparator).
func (*RangePickerW) ShowTime 实验性
func (w *RangePickerW) ShowTime() *RangePickerWShowTime adds start / end time columns under the month panels and an OK button (Ant RangePicker showTime, Element type="datetimerange"): days and times are drafts until OK (or Enter on the picked end day) commits. The default format becomes "2006-01-02 15:04:05"; a format without seconds hides the second columns.
func (*RangePickerW) Size 实验性
func (w *RangePickerW) Size(s ControlSize) *RangePickerWfunc (*RangePickerW) Status 实验性
func (w *RangePickerW) Status(s string) *RangePickerWfunc (*RangePickerW) Variant 实验性
func (w *RangePickerW) Variant(v string) *RangePickerWVariant sets the frame look: "outlined" (default), "filled", "borderless" or "underlined".
func (*RangePickerW) Width 实验性
func (w *RangePickerW) Width(px float32) *RangePickerWRateW
type RateW struct {
// contains filtered or unexported fields
}RateW is a star rating (Ant Rate / Element el-rate).
func Rate
func Rate(c *Context, val *float64) *RateWRate adds a rating bound to *val (0..count, steps of 1 or 0.5).
func (*RateW) A11yLabel
func (w *RateW) A11yLabel(s string) *RateWA11yLabel sets the accessible name (default: the Locale's "rating"; inside a FormItem the item label is used).
func (*RateW) AllowClear
func (w *RateW) AllowClear(on bool) *RateWAllowClear lets a click on the current value reset it to 0 (default on).
func (*RateW) AllowHalf
func (w *RateW) AllowHalf() *RateWAllowHalf enables half-star values.
func (*RateW) Changed
func (w *RateW) Changed() boolChanged reports a new value this frame.
func (*RateW) Character
func (w *RateW) Character(s string) *RateWCharacter replaces the star with a text character (e.g. "A", "好").
func (*RateW) CharacterFunc
func (w *RateW) CharacterFunc(fn func(i int) string) *RateWCharacterFunc draws the character fn returns for star i (0-based; Ant character as a function of the index).
func (*RateW) Color
func (w *RateW) Color(col theme.Color) *RateWColor overrides the active color.
func (*RateW) Colors
func (w *RateW) Colors(cols ...theme.Color) *RateWColors sets the active color by the value (Element colors): a value at or below the low threshold uses the first color, below the high threshold the second, from it on the third. One color applies to every value; Color overrides them all.
func (*RateW) Count
func (w *RateW) Count(n int) *RateWCount sets the number of stars (default 5).
func (*RateW) Disabled
func (w *RateW) Disabled(on bool) *RateWDisabled makes the rating read-only.
func (*RateW) Hovered
func (w *RateW) Hovered() float64Hovered returns the value previewed under the pointer (0 = none).
func (*RateW) Icons
func (w *RateW) Icons(on, void *icon.Icon) *RateWIcons replaces the star icons: on for the filled part, void for the empty one (Element icons / void-icon; nil keeps the star).
func (*RateW) Keyboard
func (w *RateW) Keyboard(on bool) *RateWKeyboard enables or disables the arrow / Home / End keys (Ant keyboard, default on).
func (*RateW) Large
func (w *RateW) Large() *RateWLarge uses the large star size (Ant size="large": 25px; Element keeps 18px in a 40px row).
func (*RateW) ScoreFormat
func (w *RateW) ScoreFormat(fn func(v float64) string) *RateWScoreFormat formats the score of ShowScore (Element score-template; by default the bare number).
func (*RateW) ShowScore
func (w *RateW) ShowScore() *RateWShowScore shows the numeric value after the stars.
func (*RateW) Size
func (w *RateW) Size(px float32) *RateWSize sets the star size in px (Ant 20, Element 18).
func (*RateW) Small
func (w *RateW) Small() *RateWSmall uses the small star size (Ant size="small": 15px; Element 14px).
func (*RateW) Texts
func (w *RateW) Texts(t ...string) *RateWTexts shows a description after the stars, one per star (Element show-text).
func (*RateW) Thresholds
func (w *RateW) Thresholds(low, high float64) *RateWThresholds sets the values that switch Colors (Element low-threshold / high-threshold; default 2 and 4).
func (*RateW) Tooltips
func (w *RateW) Tooltips(tips ...string) *RateWTooltips shows a tooltip over the star under the pointer, one text per star (Ant tooltips); "" entries show none.
func (*RateW) VoidColor
func (w *RateW) VoidColor(col theme.Color) *RateWVoidColor sets the color of the empty stars (Element void-color / disabled-void-color).
ResultW
type ResultW struct {
// contains filtered or unexported fields
}ResultW is a result page: a status icon or illustration, a title, a subtitle, actions (Extra) and optional content (Body).
func Result
func Result(c *Context, status, title string) *ResultWResult starts a result page; set options, then call Show or Body.
func (*ResultW) Body
func (w *ResultW) Body(fn func()) *BoxBody builds the result; fn (optional) fills the grey content panel below the actions (Ant) or the bottom slot (Element).
func (*ResultW) Extra
func (w *ResultW) Extra(fn func()) *ResultWExtra builds the action area (usually buttons).
func (*ResultW) Icon
func (w *ResultW) Icon(fn func()) *ResultWIcon replaces the status icon with custom content.
func (*ResultW) Show
func (w *ResultW) Show() *BoxShow builds the result without extra content.
func (*ResultW) SubTitle
func (w *ResultW) SubTitle(s string) *ResultWSubTitle sets the secondary text below the title.
RichTextW 实验性
type RichTextW struct {
// contains filtered or unexported fields
}RichTextW is a paragraph of spans.
func RichText 实验性
func RichText(c *Context, spans ...Span) *RichTextWRichText adds a wrapping paragraph made of spans.
ui.RichText(c, ui.Span{Text: "普通、"}, ui.Span{Text: "加粗", Bold: true}, ui.Span{Text: "链接", Link: "https://…"})
func (*RichTextW) Align 实验性
func (w *RichTextW) Align(a TextAlign) *RichTextWAlign aligns lines inside the paragraph box.
func (*RichTextW) ClickedLink 实验性
func (w *RichTextW) ClickedLink() stringClickedLink returns the URL of a link clicked this frame ("" if none).
func (*RichTextW) Color 实验性
func (w *RichTextW) Color(col theme.Color) *RichTextWColor sets the default text color.
func (*RichTextW) HoveredLink 实验性
func (w *RichTextW) HoveredLink() stringHoveredLink returns the URL under the pointer ("" if none).
func (*RichTextW) ID 实验性
func (w *RichTextW) ID() IDID returns the paragraph's widget ID.
func (*RichTextW) Layout 实验性
func (w *RichTextW) Layout(opts ...layout.Option) *RichTextWLayout applies layout options.
func (*RichTextW) Pre 实验性
func (w *RichTextW) Pre() *RichTextWPre keeps spaces and tabs and only breaks at newlines or when a line is too long (code blocks).
func (*RichTextW) Selectable 实验性
func (w *RichTextW) Selectable() *RichTextWSelectable lets the user select the text with the pointer (double click selects a word, triple click the paragraph) and copy it with Cmd/Ctrl+C; Cmd/Ctrl+A selects the whole paragraph while it has focus.
func (*RichTextW) Selection 实验性
func (w *RichTextW) Selection() stringSelection returns the selected text ("" if none).
func (*RichTextW) Size 实验性
func (w *RichTextW) Size(px float32) *RichTextWSize sets the base font size.
RouteInfo 实验性
type RouteInfo struct {
InLayout bool // built inside a ProLayout content area
Layout string // "side", "top" or "mix"
Collapsed bool // sider collapsed
IsMobile bool // window narrower than MD
HasSiderMenu bool // side and mix layouts
Breadcrumb []string // the shell's breadcrumb
BreadcrumbItems []BreadcrumbItem // structured route breadcrumb, including navigation callbacks
PageTitle string
Selected string // selected menu key
ContentWidth string // "Fluid" or "Fixed"
FixedHeader bool
FixSiderbar bool // the sider stays while the content scrolls
}RouteInfo is the shell state seen by the content of a ProLayout.
func RouteContext 实验性
func RouteContext(c *Context) RouteInfoRouteContext returns the state of the innermost ProLayout being built around the caller.
RowEditorTableW 实验性
type RowEditorTableW[T any] struct {
// contains filtered or unexported fields
}RowEditorTableW is an editable table that edits one whole row at a time (Pro Components v3 RowEditorTable): double-click a row (or press Enter on one of its cells) to edit every editable cell of it; Enter or moving focus out of the row validates all of its editors and saves, Escape cancels and drops the drafts (a new row is removed). It is an EditableProTable preset, bordered and without pagination by default.
func RowEditorTable 实验性
func RowEditorTable[T any](c *Context, cols []ProColumn[T], rows *[]T) *RowEditorTableW[T]RowEditorTable starts a row-editing table over *rows; chain options, then Show.
ConfigProvider.Defaults("RowEditorTable", ...) keys: "bordered" (bool, default true), "size", "pagination" (page size or Props{"pageSize": n}; default none).
func (*RowEditorTableW[T]) AddAtTop 实验性
func (w *RowEditorTableW[T]) AddAtTop() *RowEditorTableW[T]AddAtTop puts new rows (and the add button) above the data.
func (*RowEditorTableW[T]) AddRow 实验性
func (w *RowEditorTableW[T]) AddRow() stringAddRow adds a new draft row in edit mode and returns its key ("" when NewRow is not set or another row is being edited).
func (*RowEditorTableW[T]) Bordered 实验性
func (w *RowEditorTableW[T]) Bordered(on bool) *RowEditorTableW[T]Bordered turns the cell borders on or off (default on).
func (*RowEditorTableW[T]) Cancel 实验性
func (w *RowEditorTableW[T]) Cancel()Cancel leaves row editing without saving (as Escape does).
func (*RowEditorTableW[T]) Changed 实验性
func (w *RowEditorTableW[T]) Changed() boolChanged reports a change of *rows in the last Show.
func (*RowEditorTableW[T]) Edit 实验性
func (w *RowEditorTableW[T]) Edit(k string)Edit starts editing the row with key k (valid after Show).
func (*RowEditorTableW[T]) EditingKey 实验性
func (w *RowEditorTableW[T]) EditingKey() stringEditingKey returns the key of the edited row ("" when none).
func (*RowEditorTableW[T]) Errors 实验性
func (w *RowEditorTableW[T]) Errors(k string) map[string]stringErrors returns the validation messages of row k by column key.
func (*RowEditorTableW[T]) ID 实验性
func (w *RowEditorTableW[T]) ID() IDID returns the widget ID (valid after Show).
func (*RowEditorTableW[T]) MaxLength 实验性
func (w *RowEditorTableW[T]) MaxLength(n int) *RowEditorTableW[T]MaxLength hides the add button once there are n rows.
func (*RowEditorTableW[T]) NewRow 实验性
func (w *RowEditorTableW[T]) NewRow(fn func() T) *RowEditorTableW[T]NewRow shows the "add a row" button (see EditableProTableW.NewRow); the new row opens in edit mode with focus in its first editor.
func (*RowEditorTableW[T]) OnSave 实验性
func (w *RowEditorTableW[T]) OnSave(fn func(row T, index int, done func(error))) *RowEditorTableW[T]OnSave receives a validated row (index -1 for a new row) before it is written back (see EditableProTableW.OnSave).
func (*RowEditorTableW[T]) Pagination 实验性
func (w *RowEditorTableW[T]) Pagination(n int) *RowEditorTableW[T]Pagination pages the rows locally, n per page (default: no pagination).
func (*RowEditorTableW[T]) RowEditable 实验性
func (w *RowEditorTableW[T]) RowEditable(fn func(row T) bool) *RowEditorTableW[T]RowEditable limits which rows can be edited.
func (*RowEditorTableW[T]) RowKey 实验性
func (w *RowEditorTableW[T]) RowKey(f func(T) string) *RowEditorTableW[T]RowKey gives rows stable keys (default: the row index).
func (*RowEditorTableW[T]) Save 实验性
func (w *RowEditorTableW[T]) Save()Save validates the edited row and saves it (as Enter does).
func (*RowEditorTableW[T]) Saved 实验性
func (w *RowEditorTableW[T]) Saved() boolSaved reports a row written back in the last Show.
func (*RowEditorTableW[T]) ScrollX 实验性
func (w *RowEditorTableW[T]) ScrollX(px float32) *RowEditorTableW[T]ScrollX sets the table's scroll width.
func (*RowEditorTableW[T]) ScrollY 实验性
func (w *RowEditorTableW[T]) ScrollY(maxH float32) *RowEditorTableW[T]ScrollY bounds the table body to maxH (EditableProTableW.ScrollY): only the visible rows are built. The edited row is always built, even scrolled out of view, so its draft and focus survive; starting to edit it (Edit), focus moving into it (Tab), typing in it and a failed validation scroll it into view. Default 0: unbounded, every row is built.
func (*RowEditorTableW[T]) Show 实验性
func (w *RowEditorTableW[T]) Show() *RowEditorTableW[T]Show builds the table.
func (*RowEditorTableW[T]) Size 实验性
func (w *RowEditorTableW[T]) Size(s ControlSize) *RowEditorTableW[T]Size sets the density.
func (*RowEditorTableW[T]) Table 实验性
func (w *RowEditorTableW[T]) Table() *TableWTable returns the inner table of the last Show.
func (*RowEditorTableW[T]) Title 实验性
func (w *RowEditorTableW[T]) Title(s string) *RowEditorTableW[T]Title sets the toolbar title.
func (*RowEditorTableW[T]) ToolBar 实验性
func (w *RowEditorTableW[T]) ToolBar(fn func()) *RowEditorTableW[T]ToolBar adds actions at the right of the toolbar.
func (*RowEditorTableW[T]) Validating 实验性
func (w *RowEditorTableW[T]) Validating(k string) boolValidating reports async validation or a save in flight for row k.
func (*RowEditorTableW[T]) Virtual 实验性
func (w *RowEditorTableW[T]) Virtual() *RowEditorTableW[T]Virtual is TableW.Virtual for the inner table (see EditableProTableW.Virtual): with ScrollY the body is windowed either way; rows keep the height of the density (Size) unless the theme has a Table V2 row height (Element Plus).
RowStyle 实验性
type RowStyle struct {
// Status tints the row with a palette background ("success",
// "warning", "error", "info", "processing"), like Element Plus'
// success-row / warning-row classes.
Status string
// Bg sets the row background (wins over Status).
Bg theme.Color
// Text colors the text of plain (Text) cells; Render cells style
// their own widgets.
Text theme.Color
// Bold draws plain cell text in medium weight.
Bold bool
}RowStyle styles one body row (RowClass). Zero fields keep the default look; hover, selection and the current-row highlight still win over Bg.
Rule
type Rule struct {
// contains filtered or unexported fields
}Rule validates a form value; build rules with Required, MinLen, MaxLen, Pattern, Email, Match, Check or AsyncCheck.
func AsyncCheck 实验性
func AsyncCheck(fn func(v string, done func(msg string))) RuleAsyncCheck validates asynchronously (a server lookup): fn starts the check and calls done (from any goroutine) with an error message or "". It runs after the synchronous rules pass, once per value; the item shows a "validating" hint meanwhile.
func Check
func Check(fn func(v string) string) RuleCheck wraps a custom validator returning an error message or "".
func Email
func Email(msg string) RuleEmail checks a simple e-mail shape.
func Match
func Match(other *string, msg string) RuleMatch fails when the value differs from *other (confirm password). Give the item Dependencies(otherName) to re-check when the other field changes.
func MaxLen
func MaxLen(n int, msg string) RuleMaxLen fails when the value has more than n characters.
func MinLen
func MinLen(n int, msg string) RuleMinLen fails when the value has fewer than n characters (empty passes; combine with Required).
func Pattern
func Pattern(re string, msg string) RulePattern fails when a non-empty value does not match re.
func Required
func Required(msg string) RuleRequired fails on an empty value.
func (Rule) Warning
func (r Rule) Warning() RuleWarning turns the rule into a warning: a failing value shows the message in the warning color and status, but Validate still passes (Ant rule warningOnly).
RuleOf 实验性
type RuleOf[T any] struct {
// contains filtered or unexported fields
}RuleOf validates a form value of type T; build them with RequiredValue, MinValue, MaxValue, RangeValue, RequiredItems, MinItems, MaxItems, MustBeTrue or CheckValue, and attach them with RulesOf.
func CheckValue 实验性
func CheckValue[T any](fn func(v T) string) RuleOf[T]CheckValue wraps a custom validator returning an error message or "".
func MaxItems 实验性
func MaxItems[E any](n int, msg string) RuleOf[[]E]MaxItems fails when the slice has more than n elements.
func MaxValue 实验性
func MaxValue[T cmp.Ordered](hi T, msg string) RuleOf[T]MaxValue fails when the value is above hi.
func MinItems 实验性
func MinItems[E any](n int, msg string) RuleOf[[]E]MinItems fails when a non-empty slice has fewer than n elements (combine with RequiredItems).
func MinValue 实验性
func MinValue[T cmp.Ordered](lo T, msg string) RuleOf[T]MinValue fails when the value is below lo.
func MustBeTrue 实验性
func MustBeTrue(msg string) RuleOf[bool]MustBeTrue fails unless the value is true ("I agree to the terms"); the item shows the required mark.
func RangeValue 实验性
func RangeValue[T cmp.Ordered](lo, hi T, msg string) RuleOf[T]RangeValue fails outside [lo, hi].
func RequiredItems 实验性
func RequiredItems[E any](msg string) RuleOf[[]E]RequiredItems fails on an empty slice (checkbox group, multi-select, upload list).
func RequiredValue 实验性
func RequiredValue[T comparable](msg string) RuleOf[T]RequiredValue fails on the zero value (0, false, "", nil).
func (RuleOf[T]) Warning 实验性
func (r RuleOf[T]) Warning() RuleOf[T]Warning turns the rule into a warning (see Rule.Warning).
Runner
type Runner struct {
// contains filtered or unexported fields
}Runner drives one window: it queues input, runs the page function, lays out, paints and presents. All methods except Invalidate, Post and Close must be called on the UI thread. Invalidate and Close are safe from any goroutine; so is Post when a thread is bound or the window implements UIPoster, while on a headless runner (neither) Post runs fn inline on the caller, which must then be on the UI thread. The UI thread is the one bound with BindThread, or the host's main thread when none is bound. Development builds (-tags tango_dev) panic when a bound runner is used off its thread.
With uihost.Open, uihost.Attach and tan dev, the UI thread is the app's main thread. Dedicated macOS UI threads are currently used only for internal testing. A headless Driver runs on the caller's thread. Use Post to update page state or call Runner methods from a background goroutine. The thread checks cover Runner and Context state on bound runners.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func NewRunner
func NewRunner(page func(*Context), o RunnerOptions) *RunnerNewRunner creates a runner for page. Call Attach before Frame.
func Open 实验性
func Open(h Host, opts WindowOptions, page func(*Context), ropts RunnerOptions) (*Runner, error)Open creates a Runner for page and asks host to put it in a window.
func (*Runner) AccessibilityTree 实验性
func (r *Runner) AccessibilityTree() *a11y.TreeAccessibilityTree returns the semantics tree of the last frame, or nil when accessibility is off.
func (*Runner) Animating
func (r *Runner) Animating() boolAnimating reports whether the last frame had running transitions.
func (*Runner) Attach
func (r *Runner) Attach(w Window)Attach binds the runner to its window.
func (*Runner) BindThread 实验性
func (r *Runner) BindThread(t *uithread.Thread)BindThread makes t the runner's UI thread: Post queues work there and, in development builds, the UI-thread entry points panic when called from elsewhere. Call it once, before Attach; only the host can end the binding (corehook.ReturnRunnerToMain, when it hands the window back to its main thread), never bind it again. Experimental: used by the platform host (uihost).
func (*Runner) ClearKeyboardInset
func (r *Runner) ClearKeyboardInset()ClearKeyboardInset removes the SetKeyboardInset override. UI thread.
func (*Runner) ClearSafeArea
func (r *Runner) ClearSafeArea()ClearSafeArea removes the SetSafeArea override.
func (*Runner) Close
func (r *Runner) Close()Close releases resources. It may be called from any goroutine.
func (*Runner) Composing 实验性
func (r *Runner) Composing() boolComposing reports whether an input method is composing (a non-empty input.Composition has not been committed or cancelled yet) as of the latest frame. A host whose main thread decides on keys without the UI thread (window shortcuts) reads it after Frame.
Experimental: used by the platform host (uihost).
func (*Runner) Context
func (r *Runner) Context() *ContextContext exposes the context (tests, advanced integrations).
func (*Runner) DragRegions 实验性
func (r *Runner) DragRegions() []geom.RectDragRegions returns the parts of the window, in window logical pixels, where a primary-button press in the latest frame lands on a self-drawn TitleBar's drag area (not on a control inside it or on anything drawn above it) and so would move the window. Only title bars that act on the runner's own window (no TitleBarW.Frame, not Manual) count, and the list is empty while any layer (Overlay) is open, since a press then may first have to close it. Call it after Frame; it allocates a new slice.
Experimental: used by the platform host (uihost), which may start the move itself on the main thread.
func (*Runner) DropFiles 实验性
func (r *Runner) DropFiles(p geom.Point, paths []string)DropFiles delivers files dropped at p (window logical pixels) to the DropZone under it: its Dropped returns them during the next frame. Files dropped outside every zone are discarded. UI thread only.
func (*Runner) EnableAccessibility 实验性
func (r *Runner) EnableAccessibility(on bool)EnableAccessibility builds the semantics tree every frame even when the window is not an AccessibilityHost (or reports it disabled): tests, automation and hosts that enable it explicitly. Off again leaves the decision to the host.
func (*Runner) FileDrag 实验性
func (r *Runner) FileDrag() (geom.Point, bool)FileDrag returns the position of a file drag in host window logical pixels.
func (*Runner) FileDragLeave 实验性
func (r *Runner) FileDragLeave()FileDragLeave reports that the file drag left the window, was cancelled or was dropped (hosts call it before DropFiles).
func (*Runner) FileDragOver 实验性
func (r *Runner) FileDragOver(p geom.Point)FileDragOver reports files dragged over the window at p (window logical pixels), when the drag enters and as it moves. Hosts call it on the UI thread (uihost does from platform.CanvasDropTarget).
func (*Runner) Frame
func (r *Runner) Frame() errorFrame processes queued input, rebuilds the UI and presents it.
func (*Runner) FrameMetrics 实验性
func (r *Runner) FrameMetrics() (size geom.Size, scale float32)FrameMetrics returns the viewport and effective device-pixel scale to use when rendering List again, for example to capture a screenshot.
func (*Runner) HandleEvent
func (r *Runner) HandleEvent(e input.Event)HandleEvent queues an input event and requests a frame.
func (*Runner) Invalidate
func (r *Runner) Invalidate()Invalidate requests a frame. It is safe to call from any goroutine (it only forwards to Window.Invalidate, which hosts must make thread-safe); the frame itself still runs on the UI thread.
func (*Runner) List
func (r *Runner) List() *paint.ListList returns the display list in UI logical pixels (debugging, GPU hosts). FrameMetrics gives the parameters for rendering it.
func (*Runner) NativeRegions 实验性
func (r *Runner) NativeRegions() []NativeRegionNativeRegions returns the native views of the latest frame in build order (later ones stack above earlier ones). Call it after Frame (or from Window.Present); it allocates a new slice.
func (*Runner) NextWake
func (r *Runner) NextWake() time.TimeNextWake returns the requested wake time (zero if none).
func (*Runner) PerformAction 实验性
func (r *Runner) PerformAction(id a11y.NodeID, act a11y.Action, arg string) errorPerformAction asks the widget behind node id to perform act (from a screen reader, voice control or a test). arg is the new value for SetValue (text, or a number for sliders and spin buttons). The node and action must be in the last reported tree; the action runs at the start of the next frame, which this call requests. It must be called on the UI thread.
func (*Runner) PointerPos 实验性
func (r *Runner) PointerPos() (geom.Point, bool)PointerPos returns the last pointer position in the window and whether the pointer is inside it (hosts placing drops that carry no point).
func (*Runner) Post 实验性
func (r *Runner) Post(fn func())Post runs fn on the UI thread, then requests a frame. It never blocks. On a bound runner (BindThread) fn is queued on that thread; otherwise, when the attached window implements UIPoster, it is queued through PostUI. Either way any goroutine may call Post, and a Post from the page function runs fn after the frame. A headless runner (no bound thread, no UIPoster: Driver, tests) runs fn on the calling goroutine before Post returns, so the caller must be on the UI thread. After Close, fn is dropped, also when it was queued before.
func (*Runner) SetKeyboardInset
func (r *Runner) SetKeyboardInset(in geom.Insets)SetKeyboardInset sets the window's soft-keyboard inset (logical pixels), taking precedence over KeyboardInsetWindow, and requests a frame. Hosts that are told about keyboard changes call it instead of implementing KeyboardInsetWindow. UI thread.
func (*Runner) SetReduceMotion
func (r *Runner) SetReduceMotion(on bool)SetReduceMotion turns the reduced-motion preference on or off (see RunnerOptions.ReduceMotion) and requests a frame.
func (*Runner) SetSafeArea
func (r *Runner) SetSafeArea(in geom.Insets)SetSafeArea sets the window's safe-area insets (logical pixels), taking precedence over SafeAreaWindow, and requests a frame. Hosts that are told about inset changes (iOS safeAreaInsetsDidChange, Android WindowInsets listeners) call it instead of implementing SafeAreaWindow.
func (*Runner) SetTheme
func (r *Runner) SetTheme(t *theme.Theme)SetTheme switches the theme and requests a frame.
func (*Runner) SetTouchPointerEmulation 实验性
func (r *Runner) SetTouchPointerEmulation(on bool)SetTouchPointerEmulation turns the pointer events synthesized from the first finger of a touch gesture on (the default) or off. Hosts that already deliver emulated mouse events for touches turn it off.
func (*Runner) SetUIScale 实验性
func (r *Runner) SetUIScale(scale float32)SetUIScale requests a window-wide UI scale for the next frame. A value of 1 is 100%; nonpositive and nonfinite values reset to 1, and other values are clamped to [0.25, 4]. Call on the UI thread.
func (*Runner) TitleBarActed 实验性
func (r *Runner) TitleBarActed(p geom.Point, act WindowAction)TitleBarActed tells the runner that the host itself performed act (WindowActionMaximize or WindowActionRestore) for a double click at p on a TitleBar's drag area (see DragRegions): the next frame's TitleBarW.Action of the bar under p reports act without performing it again. UI thread; it does not request a frame.
Experimental: used by the platform host (uihost).
func (*Runner) TrimCaches 实验性
func (r *Runner) TrimCaches()TrimCaches asks the runner's renderer to discard rebuildable caches and requests another frame. Call on the UI thread, between frames. It does not clear application state, editor LineCaches, current Layouts or the current presented pixels. A renderer without Trim() is left alone.
func (*Runner) UIScale 实验性
func (r *Runner) UIScale() float32UIScale returns the requested UI scale (1 is 100%). Call on the UI thread.
RunnerOptions
type RunnerOptions struct {
// UIScale is the initial logical UI scale. Zero defaults to 1.
UIScale float32
Theme *theme.Theme // default theme.AntDesign()
// Renderer overrides the CPU renderer (GPU backends). When it is not a
// *paint.CPU the runner calls Window.Present(nil) after rendering.
Renderer paint.Renderer
// Clock overrides time.Now (tests, deterministic screenshots).
Clock func() time.Time
// NoAnimations makes every transition jump to its end state.
NoAnimations bool
// ReduceMotion honours the user's "reduce motion" preference: every
// transition (Anim, AnimFrom, enter/leave motion, chart growth)
// jumps to its end value and decorative loops (skeleton shimmer,
// badge pulse) stand still. Unlike NoAnimations it does not change
// timers such as hover delays. Hosts that track the OS setting call
// Runner.SetReduceMotion when it changes.
ReduceMotion bool
// Content says what the window mostly shows, which lets the host pick
// a renderer suited to it (see ContentData). The host reads it once,
// when the window is created; it is ignored when Renderer or the
// TANGO_RENDERER environment variable selects a renderer.
Content ContentKind
}RunnerOptions configure a Runner.
只有部分成员是稳定的:未标「实验性」的方法和下列以外的字段受兼容性承诺约束。
实验性 实验性成员:UIScale、Renderer、Content
SafeAreaWindow 实验性
type SafeAreaWindow interface {
// SafeAreaInsets returns the distances, in logical pixels, from each
// edge of the content area to the region that is fully visible and
// free of system controls.
SafeAreaInsets() geom.Insets
}SafeAreaWindow is implemented by windows that know the parts of their content area covered by system UI: the status bar, a display notch or camera cut-out, rounded corners, the home indicator, on-screen navigation buttons. The Runner polls it every frame, like Size.
SchemaFormW 实验性
type SchemaFormW struct {
// contains filtered or unexported fields
}SchemaFormW renders a form from a field schema in one of the form shells (Ant Design Pro BetaSchemaForm): the same []ProField drives ProForm, ModalForm, DrawerForm, StepsForm, QueryFilter or LightFilter. Nested lists are fields of ValueType ValueFormList with ProField.List.
ui.SchemaForm(c, schema).LayoutType(ui.SchemaLayoutModalForm).
Open(&open).Title("新建规则").Values(&vals).
OnFinish(func(v ui.ProValues, done func(error)) { go save(v, done) }).
Show()
func SchemaForm 实验性
func SchemaForm(c *Context, schema []ProField) *SchemaFormWSchemaForm starts a form over schema; chain options, then Show.
ConfigProvider.Defaults("SchemaForm", ...) keys: "layoutType" (one of the SchemaLayout* names).
func (*SchemaFormW) Columns 实验性
func (s *SchemaFormW) Columns(n int) *SchemaFormWColumns lays the fields out in n grid columns (form shells).
func (*SchemaFormW) Finished 实验性
func (s *SchemaFormW) Finished() boolFinished reports a completed submit of a form shell, once.
func (*SchemaFormW) LayoutType 实验性
func (s *SchemaFormW) LayoutType(t SchemaLayoutType) *SchemaFormWLayoutType selects the form shell (default SchemaLayoutForm).
func (*SchemaFormW) OnFinish 实验性
func (s *SchemaFormW) OnFinish(fn func(vals ProValues, done func(error))) *SchemaFormWOnFinish receives the validated values of the form shells; call done (from any goroutine) when saved.
func (*SchemaFormW) Open 实验性
func (s *SchemaFormW) Open(open *bool) *SchemaFormWOpen binds the visibility of ModalForm and DrawerForm.
func (*SchemaFormW) Params 实验性
func (s *SchemaFormW) Params() map[string]stringParams returns the filter values as text after a QueryFilter or LightFilter Show (nil for the form shells).
func (*SchemaFormW) Readonly 实验性
func (s *SchemaFormW) Readonly(on bool) *SchemaFormWReadonly shows the values read-only (Form, ModalForm, DrawerForm).
func (*SchemaFormW) Searched 实验性
func (s *SchemaFormW) Searched() boolSearched reports a search of QueryFilter or a change of LightFilter.
func (*SchemaFormW) Show 实验性
func (s *SchemaFormW) Show() *SchemaFormWShow builds the shell.
func (*SchemaFormW) Title 实验性
func (s *SchemaFormW) Title(t string) *SchemaFormWTitle sets the dialog title of ModalForm and DrawerForm.
func (*SchemaFormW) Values 实验性
func (s *SchemaFormW) Values(v *ProValues) *SchemaFormWValues binds the values (otherwise the shell keeps its own).
func (*SchemaFormW) Width 实验性
func (s *SchemaFormW) Width(px float32) *SchemaFormWWidth sets the dialog / drawer width, or the StepsForm form width.
SchemaLayoutType 实验性
type SchemaLayoutType stringSchemaLayoutType selects the form shell of a SchemaForm.
const (
SchemaLayoutForm SchemaLayoutType = "Form" // ProForm (default)
SchemaLayoutModalForm SchemaLayoutType = "ModalForm" // ProForm in a Modal (needs Open)
SchemaLayoutDrawerForm SchemaLayoutType = "DrawerForm" // ProForm in a Drawer (needs Open)
SchemaLayoutStepsForm SchemaLayoutType = "StepsForm" // one step per run of fields with the same Group
SchemaLayoutQueryFilter SchemaLayoutType = "QueryFilter" // query form with search / reset
SchemaLayoutLightFilter SchemaLayoutType = "LightFilter" // compact filter pills
)Form shells of SchemaForm.LayoutType.
实验性
ScrollBox
type ScrollBox struct {
*Box
// contains filtered or unexported fields
}ScrollBox is a scrollable container with overlay scrollbars that appear on hover; drag a thumb to scroll, click the track to jump there, wheel or trackpad anywhere inside.
func Scroll
func Scroll(c *Context, fn func(), opts ...layout.Option) *ScrollBoxScroll creates a vertically scrolling column. Give it a bounded height (Grow inside a sized parent, or layout.H/MaxH).
func ScrollH
func ScrollH(c *Context, fn func(), opts ...layout.Option) *ScrollBoxScrollH creates a horizontally scrolling row.
func (*ScrollBox) Always
func (s *ScrollBox) Always() *ScrollBoxAlways keeps the scrollbars visible instead of showing them on hover.
func (*ScrollBox) Both
func (s *ScrollBox) Both() *ScrollBoxBoth scrolls on both axes.
func (*ScrollBox) MaxOffset
func (s *ScrollBox) MaxOffset() (x, y float64)MaxOffset returns the maximum logical offsets measured by the last paint. Subtract PaintedOffset from it to get the remaining scroll range.
func (*ScrollBox) Offset
func (s *ScrollBox) Offset() (x, y float64)Offset returns the scroll offset: the content position at the viewport's top-left corner (top-right in RTL, where x counts from the right end).
func (*ScrollBox) PaintedOffset
func (s *ScrollBox) PaintedOffset() (x, y float64)PaintedOffset returns the logical scroll offset used by the last paint. It stays at that position until scheduled scrolling is drawn.
func (*ScrollBox) Reveal
func (s *ScrollBox) Reveal(y, h float64) *ScrollBoxReveal scrolls the minimum amount that makes the vertical content range [y, y+h) visible (no-op before the first paint). Use it to keep a keyboard-selected row in view.
func (*ScrollBox) ScrollTo
func (s *ScrollBox) ScrollTo(x, y float64) *ScrollBoxScrollTo sets the scroll offset (clamped at paint). x is logical: 0 is the inline start, which is the right end in RTL.
func (*ScrollBox) ScrollToSmooth
func (s *ScrollBox) ScrollToSmooth(y float32, dur time.Duration) *ScrollBoxScrollToSmooth animates the vertical offset to y.
SearchW
type SearchW struct {
// contains filtered or unexported fields
}SearchW is an input with a search button (Ant Input.Search, Element input with an append search button).
func Search
func Search(c *Context, val *string) *SearchWSearch adds a search box bound to *val.
func (*SearchW) A11yLabel
func (w *SearchW) A11yLabel(s string) *SearchWA11yLabel sets the accessible name of the search box (inside a FormItem the item label is used; the placeholder is the last resort).
func (*SearchW) AllowClear
func (w *SearchW) AllowClear() *SearchWfunc (*SearchW) Changed
func (w *SearchW) Changed() boolChanged reports an edit of the text.
func (*SearchW) Disabled
func (w *SearchW) Disabled(on bool) *SearchWfunc (*SearchW) EnterButton
func (w *SearchW) EnterButton(s string) *SearchWEnterButton replaces the icon button with a primary button labelled s.
func (*SearchW) InputID
func (w *SearchW) InputID() IDInputID returns the ID of the inner editor (focus it with c.SetFocus).
func (*SearchW) Layout
func (w *SearchW) Layout(o ...layout.Option) *SearchWfunc (*SearchW) Loading
func (w *SearchW) Loading(on bool) *SearchWLoading shows a spinner in the button.
func (*SearchW) Placeholder
func (w *SearchW) Placeholder(s string) *SearchWfunc (*SearchW) Searched
func (w *SearchW) Searched() boolSearched reports a search request (button click or Enter).
func (*SearchW) Size
func (w *SearchW) Size(s ControlSize) *SearchWfunc (*SearchW) Status
func (w *SearchW) Status(s string) *SearchWfunc (*SearchW) Variant
func (w *SearchW) Variant(v string) *SearchWVariant sets the look of the field like InputW.Variant (antd Input.Search variant). ConfigProvider Defaults: "Search" "variant", falling back to "Input".
func (*SearchW) Width
func (w *SearchW) Width(px float32) *SearchWSegmentedShape
type SegmentedShape stringSegmentedShape is the outline of a Segmented control.
const (
SegmentedShapeDefault SegmentedShape = "default" // the control's corner radius
SegmentedShapeRound SegmentedShape = "round" // pill-shaped track and thumb (Ant shape="round")
)SegmentedW
type SegmentedW struct {
// contains filtered or unexported fields
}SegmentedW is a segmented control (Ant Segmented / Element el-segmented).
func Segmented
func Segmented(c *Context, val *string, opts []Option) *SegmentedWSegmented adds a segmented control bound to *val.
func (*SegmentedW) A11yLabel
func (w *SegmentedW) A11yLabel(s string) *SegmentedWA11yLabel sets the accessible name of the group (inside a FormItem the item label is used).
func (*SegmentedW) Block
func (w *SegmentedW) Block() *SegmentedWBlock stretches the control to its container, items share the width.
func (*SegmentedW) Changed
func (w *SegmentedW) Changed() boolChanged reports a new selection this frame.
func (*SegmentedW) Disabled
func (w *SegmentedW) Disabled(on bool) *SegmentedWDisabled disables every option.
func (*SegmentedW) Icons
func (w *SegmentedW) Icons(ics ...*icon.Icon) *SegmentedWIcons sets an icon per option (nil entries allowed).
func (*SegmentedW) ItemRender
func (w *SegmentedW) ItemRender(fn func(o Option, selected bool)) *SegmentedWItemRender builds the content of every option in place of its icon and label (Element el-segmented default slot, Ant options[].label as a node): fn runs inside the segment, which centres what it adds, with the option and whether it is the selected one. The option label stays the accessible name; a hint per option is a Tooltip around the content.
ui.Segmented(c, &v, opts).ItemRender(func(o ui.Option, sel bool) {
ui.Icon(c, icons[o.Value])
ui.Text(c, o.Label).Size(12)
})
func (*SegmentedW) Orientation
func (w *SegmentedW) Orientation(o string) *SegmentedWOrientation sets the direction: "horizontal" (default) or "vertical" (Ant v6 orientation, Element direction). Other values are ignored.
func (*SegmentedW) Shape
func (w *SegmentedW) Shape(s SegmentedShape) *SegmentedWShape sets the outline: SegmentedShapeRound makes the track and the thumb pill-shaped.
func (*SegmentedW) Size
func (w *SegmentedW) Size(s ControlSize) *SegmentedWSize sets the control size.
func (*SegmentedW) Tooltips
func (w *SegmentedW) Tooltips(tips ...string) *SegmentedWTooltips shows a tooltip per option while the pointer is over it (Ant options[].tooltip); "" entries show none.
func (*SegmentedW) Vertical
func (w *SegmentedW) Vertical() *SegmentedWVertical stacks the options top to bottom (Ant orientation="vertical", Element direction="vertical"); they share the width of the widest one and the up / down arrow keys move the selection.
SelectW
type SelectW struct {
// contains filtered or unexported fields
}SelectW is a dropdown select.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func Select
func Select(c *Context, val *string, opts []Option) *SelectWSelect adds a single-value select bound to *val.
func (*SelectW) A11yLabel
func (w *SelectW) A11yLabel(s string) *SelectWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*SelectW) AllowClear
func (w *SelectW) AllowClear() *SelectWfunc (*SelectW) AllowCreate
func (w *SelectW) AllowCreate() *SelectWAllowCreate offers the typed text as a new option when no label equals it (Element allow-create); read it with Created. Implies Searchable.
func (*SelectW) Changed
func (w *SelectW) Changed() boolChanged reports a new selection this frame.
func (*SelectW) Created
func (w *SelectW) Created() (string, bool)Created returns the value of an entry created with AllowCreate this frame.
func (*SelectW) DataVersion
func (w *SelectW) DataVersion(v int) *SelectWDataVersion tells the select that the option slice was modified in place (the virtual dropdown caches by slice identity and this number).
func (*SelectW) Debounce
func (w *SelectW) Debounce(d time.Duration) *SelectWDebounce sets the delay before a Remote call.
func (*SelectW) Disabled
func (w *SelectW) Disabled(on bool) *SelectWfunc (*SelectW) FilterMethod
func (w *SelectW) FilterMethod(fn func(query string, o Option) bool) *SelectWFilterMethod replaces the case-insensitive label match of the search text with fn (same as VirtualSelect.FilterMethod); it is not used with Remote, whose results are already filtered. Implies Searchable.
func (*SelectW) Groups 实验性
func (w *SelectW) Groups(groups []OptionGroup) *SelectWGroups shows the options under titled groups (Ant OptGroup, Element el-option-group); the opts passed to Select are ignored. Options can also be grouped with Option.Group.
func (*SelectW) IsOpen
func (w *SelectW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*SelectW) LabelRender 实验性
func (w *SelectW) LabelRender(fn func(o Option) string) *SelectWLabelRender sets the text shown for the selected value (Ant labelRender). fn also receives values that are not among the options, as Option{Label: value, Value: value}.
func (*SelectW) Layout
func (w *SelectW) Layout(o ...layout.Option) *SelectWfunc (*SelectW) ListHeight
func (w *SelectW) ListHeight(px float32) *SelectWListHeight sets the maximum dropdown height with or without virtual scrolling (Ant listHeight, 256).
func (*SelectW) Loading
func (w *SelectW) Loading(on bool) *SelectWLoading shows a spinner and the loading text in the dropdown.
func (*SelectW) NotFoundContent 实验性
func (w *SelectW) NotFoundContent(s string) *SelectWNotFoundContent sets the text of an empty dropdown (Ant notFoundContent, Element no-data-text / no-match-text); by default the Locale's NoData.
func (*SelectW) Open
func (w *SelectW) Open() *SelectWOpen forces the dropdown open (screenshots, tests).
func (*SelectW) OpenChanged 实验性
func (w *SelectW) OpenChanged() boolOpenChanged reports that the dropdown opened or closed this frame (Ant onOpenChange, Element visible-change); read IsOpen for the new state.
func (*SelectW) OptionRender 实验性
func (w *SelectW) OptionRender(fn func(o Option, s OptionState)) *SelectWOptionRender builds each option row's content with fn (row background, highlight and selection marks stay).
func (*SelectW) Placeholder
func (w *SelectW) Placeholder(s string) *SelectWfunc (*SelectW) Placement 实验性
func (w *SelectW) Placement(p Placement) *SelectWPlacement sets where the dropdown opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement bottomLeft / bottomRight / topLeft / topRight; Element placement). It flips when there is no room. ConfigProvider.Defaults("Select", "placement") takes the Ant names.
func (*SelectW) Prefix 实验性
func (w *SelectW) Prefix(ic *icon.Icon) *SelectWPrefix shows ic before the value (Ant prefix).
func (*SelectW) PrefixText 实验性
func (w *SelectW) PrefixText(s string) *SelectWPrefixText shows s before the value (Ant prefix, Element prefix slot), e.g. a field name inside the frame.
func (*SelectW) Remote
func (w *SelectW) Remote(fn func(query string)) *SelectWRemote turns on server-side search: fn receives the typed text after Debounce (300ms by default) and should replace the options. Pair it with Loading while the request runs. Implies Searchable.
func (*SelectW) Searchable
func (w *SelectW) Searchable() *SelectWfunc (*SelectW) Size
func (w *SelectW) Size(s ControlSize) *SelectWfunc (*SelectW) Status
func (w *SelectW) Status(s string) *SelectWfunc (*SelectW) SuffixIcon 实验性
func (w *SelectW) SuffixIcon(ic *icon.Icon) *SelectWSuffixIcon replaces the dropdown arrow with ic (Ant suffixIcon, Element suffix-icon); it is not rotated and also stays while searching. The clear button still takes its place on hover with AllowClear.
func (*SelectW) Variant 实验性
func (w *SelectW) Variant(v FieldVariant) *SelectWVariant sets the frame look (FieldOutlined by default).
func (*SelectW) Virtual
func (w *SelectW) Virtual(on bool) *SelectWVirtual forces the virtual dropdown on or off; by default lists longer than 100 options are virtual (only the visible rows are built). With false, grouped and custom-rendered lists also build every row.
func (*SelectW) Width
func (w *SelectW) Width(px float32) *SelectWSenderW 实验性
type SenderW struct {
// contains filtered or unexported fields
}SenderW is the chat input: an auto-growing multi-line editor where Enter sends and Shift+Enter inserts a line break, with an attachment strip, @ / command suggestions, a toolbar and a send / stop button.
func Sender 实验性
func Sender(c *Context, val *string) *SenderWSender adds a chat input bound to *val. Read Submitted each frame and clear *val after sending:
s := ui.Sender(c, &draft).Loading(busy).Commands(cmds)
if s.Submitted() { send(draft); draft = "" }
if s.Stopped() { cancel() }
func (*SenderW) A11yLabel 实验性
func (w *SenderW) A11yLabel(s string) *SenderWA11yLabel sets the accessible name of the editor (default: placeholder).
func (*SenderW) AttachButton 实验性
func (w *SenderW) AttachButton() *SenderWAttachButton shows a paperclip button in the toolbar (see AttachClicked; the application opens its file dialog).
func (*SenderW) AttachClicked 实验性
func (w *SenderW) AttachClicked() boolAttachClicked reports a click on the attach button.
func (*SenderW) Attachments 实验性
func (w *SenderW) Attachments(files *[]ChatAttachment) *SenderWAttachments shows *files as removable chips above the editor; a click on a chip's remove button deletes it from the slice (see Removed).
func (*SenderW) AutoSize 实验性
func (w *SenderW) AutoSize(minRows, maxRows int) *SenderWAutoSize sets the visible rows the editor grows between (default 1..8).
func (*SenderW) Changed 实验性
func (w *SenderW) Changed() boolChanged reports an edit of the text this frame.
func (*SenderW) Commands 实验性
func (w *SenderW) Commands(opts []Option) *SenderWCommands suggests opts after '/' (shown as "/value label").
func (*SenderW) Disabled 实验性
func (w *SenderW) Disabled(on bool) *SenderWDisabled disables the whole input.
func (*SenderW) Header 实验性
func (w *SenderW) Header(fn func()) *SenderWHeader adds content at the top of the input (quoted message, context chips).
func (*SenderW) ID 实验性
func (w *SenderW) ID() IDID returns the editor's ID (focus it with c.SetFocus).
func (*SenderW) Layout 实验性
func (w *SenderW) Layout(opts ...layout.Option) *SenderWLayout applies layout options to the outer frame.
func (*SenderW) Loading 实验性
func (w *SenderW) Loading(on bool) *SenderWLoading shows the stop button instead of the send button; Enter does not send and Escape (or the button) reports Stopped.
func (*SenderW) MaxLength 实验性
func (w *SenderW) MaxLength(n int) *SenderWMaxLength limits the number of characters.
func (*SenderW) Mentions 实验性
func (w *SenderW) Mentions(opts []Option) *SenderWMentions suggests opts after '@' (filtered by what follows it).
func (*SenderW) Picked 实验性
func (w *SenderW) Picked() (prefix string, o Option, ok bool)Picked returns the suggestion inserted this frame and its prefix.
func (*SenderW) Placeholder 实验性
func (w *SenderW) Placeholder(s string) *SenderWPlaceholder replaces the default placeholder.
func (*SenderW) Removed 实验性
func (w *SenderW) Removed() (int, bool)Removed returns the index of the attachment removed this frame.
func (*SenderW) Stopped 实验性
func (w *SenderW) Stopped() boolStopped reports a click on the stop button (or Escape) while loading.
func (*SenderW) Submitted 实验性
func (w *SenderW) Submitted() boolSubmitted reports Enter or a click on the send button with something to send (text or attachments).
func (*SenderW) Suggest 实验性
func (w *SenderW) Suggest(prefix string, src func(query string) []Option) *SenderWSuggest opens a suggestion list when prefix is typed at the start of the text or after a space; src returns the options for the text typed after it so far. The chosen option's Value replaces the query.
func (*SenderW) Toolbar 实验性
func (w *SenderW) Toolbar(fn func()) *SenderWToolbar adds controls to the start of the bottom row (model select, mode switch …); the send button stays at the end.
SettingDrawerLocale 实验性
type SettingDrawerLocale struct {
Open, Title string // trigger (accessible name, tooltip) and drawer title
NavTheme, Light, Dark, RealDark string // menu style section and its choices
PrimaryColor string
Layout, Side, Top, Mix string // navigation mode section and its choices
ContentWidth, Fluid, Fixed string
FixedHeader, FixSiderbar, ColorWeak string
Other, Compact string
ColorFmt string // swatch name, arg: hex ("主题色 %s")
// contains filtered or unexported fields
}SettingDrawerLocale holds the ProLayout SettingDrawer texts.
SettingDrawerW 实验性
type SettingDrawerW struct {
// contains filtered or unexported fields
}SettingDrawerW builds a SettingDrawer.
func SettingDrawer 实验性
func SettingDrawer(c *Context, s *ProSettings) *SettingDrawerWSettingDrawer starts the settings drawer editing *s; chain options, then Show.
ConfigProvider.Defaults("SettingDrawer", ...) keys: "hideColors", "hideLayout", "hideOther" (bool) hide those sections.
func (*SettingDrawerW) Changed 实验性
func (w *SettingDrawerW) Changed() boolChanged reports a settings change this frame.
func (*SettingDrawerW) Colors 实验性
func (w *SettingDrawerW) Colors(cols []theme.Color) *SettingDrawerWColors replaces the preset theme colors.
func (*SettingDrawerW) NoTrigger 实验性
func (w *SettingDrawerW) NoTrigger() *SettingDrawerWNoTrigger hides the floating button (open it with Open).
func (*SettingDrawerW) Open 实验性
func (w *SettingDrawerW) Open(v *bool) *SettingDrawerWOpen binds the open state (otherwise the drawer keeps its own).
func (*SettingDrawerW) Show 实验性
func (w *SettingDrawerW) Show() *SettingDrawerWShow builds the trigger and, when open, the drawer.
ShortcutCaptureWindow 实验性
type ShortcutCaptureWindow interface {
SetShortcutCapture(on bool)
}ShortcutCaptureWindow is an optional host capability for shortcut recorders. While capture is on, window shortcuts (including those enabled in text fields) and native menu accelerators must yield to the focused canvas. This is not text input: it must not enable IME or a software keyboard. System-reserved keys and global OS hotkeys are outside this capability. The runner releases capture on completion, cancel, blur or removal. Calls are made on the UI thread, only when the requested state changes.
SiderBoxW
type SiderBoxW struct {
*Box
// contains filtered or unexported fields
}SiderBoxW is the side column Sider returns; it embeds the column's Box.
func Sider
func Sider(c *Context, width float32, collapsed bool, fn func(), opts ...layout.Option) *SiderBoxWSider is a side column of fixed width (the theme's collapsed width when collapsed, animated). CollapsibleSider adds the collapse trigger and breakpoint collapsing.
SiderW 实验性
type SiderW struct {
// contains filtered or unexported fields
}SiderW builds a collapsible Sider (Ant Layout.Sider collapsible).
ui.CollapsibleSider(c, 200, &collapsed).Breakpoint(ui.LG).Body(menu)
ConfigProvider.Defaults("Sider", ...) keys: "breakpoint" (Breakpoint), "collapsedWidth" (float32), "theme" ("light" | "dark").
func CollapsibleSider 实验性
func CollapsibleSider(c *Context, width float32, collapsed *bool) *SiderWCollapsibleSider starts a sider whose collapsed state lives in *collapsed: a trigger bar at the bottom toggles it and Breakpoint collapses it on narrow windows. Chain options, then Body.
func (*SiderW) Body 实验性
func (s *SiderW) Body(fn func(), opts ...layout.Option) *BoxBody builds the sider with fn as its content.
func (*SiderW) Breakpoint 实验性
func (s *SiderW) Breakpoint(bp Breakpoint) *SiderWBreakpoint collapses the sider when the window becomes narrower than bp and expands it when it grows past it again (Ant breakpoint).
func (*SiderW) Broken 实验性
func (s *SiderW) Broken() boolBroken reports whether the window is narrower than the breakpoint.
func (*SiderW) Changed 实验性
func (s *SiderW) Changed() boolChanged reports a collapse change by the trigger or the breakpoint.
func (*SiderW) CollapsedWidth 实验性
func (s *SiderW) CollapsedWidth(px float32) *SiderWCollapsedWidth sets the width when collapsed (default the theme's).
func (*SiderW) Light 实验性
func (s *SiderW) Light() *SiderWLight uses the light sider colors (Ant theme="light").
func (*SiderW) NoTrigger 实验性
func (s *SiderW) NoTrigger() *SiderWNoTrigger hides the bottom trigger (collapse from elsewhere).
func (*SiderW) ReverseArrow 实验性
func (s *SiderW) ReverseArrow() *SiderWReverseArrow flips the trigger arrow (a sider on the end side: the right, or the left in a right-to-left scope).
SkeletonW 实验性
type SkeletonW struct {
// contains filtered or unexported fields
}SkeletonW is a loading placeholder: optional avatar, a title bar and paragraph lines, with an optional shimmer ("active").
func Skeleton 实验性
func Skeleton(c *Context) *SkeletonWSkeleton starts a skeleton with a title and paragraph rows: three rows, or two next to an avatar or without a title (antd).
ConfigProvider.Defaults("Skeleton", ...) keys: "active", "round" (bool).
func (*SkeletonW) Active 实验性
func (s *SkeletonW) Active() *SkeletonWActive turns on the shimmer animation.
func (*SkeletonW) Avatar 实验性
func (s *SkeletonW) Avatar(square bool) *SkeletonWAvatar adds a round avatar placeholder (square=true for square).
func (*SkeletonW) AvatarSize 实验性
func (s *SkeletonW) AvatarSize(px float32) *SkeletonWAvatarSize sets the avatar placeholder size in px (antd avatar.size; default the large control height, 40).
func (*SkeletonW) Body 实验性
func (s *SkeletonW) Body(fn func()) *BoxBody builds the skeleton while loading, else fn.
func (*SkeletonW) Count 实验性
func (s *SkeletonW) Count(n int) *SkeletonWCount repeats the skeleton n times (Element count).
func (*SkeletonW) Loading 实验性
func (s *SkeletonW) Loading(on bool) *SkeletonWLoading switches between the skeleton (true) and the real content.
func (*SkeletonW) NoTitle 实验性
func (s *SkeletonW) NoTitle() *SkeletonWNoTitle hides the title bar.
func (*SkeletonW) ParagraphWidth 实验性
func (s *SkeletonW) ParagraphWidth(w ...float32) *SkeletonWParagraphWidth sets the paragraph line widths (antd paragraph.width): one value sets the last line, several set the lines in order; fractions when 0 < w <= 1, else px. The default last line is 61%.
func (*SkeletonW) Round 实验性
func (s *SkeletonW) Round() *SkeletonWRound uses pill-shaped bars.
func (*SkeletonW) Rows 实验性
func (s *SkeletonW) Rows(n int) *SkeletonWRows sets the paragraph rows (0 hides the paragraph).
func (*SkeletonW) Show 实验性
func (s *SkeletonW) Show() *BoxShow builds the skeleton.
func (*SkeletonW) Throttle 实验性
func (s *SkeletonW) Throttle(leading, trailing time.Duration) *SkeletonWThrottle delays the switch (EP throttle): the skeleton appears only after Loading(true) lasted leading and goes away only after Loading(false) lasted trailing (0: at once), so quick loads do not flash. The first frame shows the content unless ThrottleInitial(true).
func (*SkeletonW) ThrottleInitial 实验性
func (s *SkeletonW) ThrottleInitial(on bool) *SkeletonWThrottleInitial sets what a throttled skeleton shows before its first delay ends: true the skeleton, false (default) the content (EP throttle.initVal).
func (*SkeletonW) TitleWidth 实验性
func (s *SkeletonW) TitleWidth(w float32) *SkeletonWTitleWidth sets the title bar width (antd title.width): a fraction of the row when 0 < w <= 1, else px. The default is 38%, 50% next to an avatar, full width without a paragraph.
SliderLocale
type SliderLocale struct {
Min, Max string
// contains filtered or unexported fields
}SliderLocale holds the accessible names of the two SliderRange handles.
SliderW
type SliderW struct {
// contains filtered or unexported fields
}SliderW is a slider; chain modifiers after Slider / SliderRange.
func Slider
func Slider(c *Context, val *float64, min, max float64) *SliderWSlider adds a slider bound to *val in [min,max] (step 1).
ui.Slider(c, &v, 0, 100).Marks(map[float64]string{0: "0°C", 100: "100°C"}).Tooltip(nil)
ui.Slider(c, &v, 0, 100).Vertical(200)
ui.Slider(c, &v, 0, 10).Step(0.5).WithInput()
func SliderRange 实验性
func SliderRange(c *Context, lo, hi *float64, min, max float64) *SliderWSliderRange adds a two-handle slider bound to *lo and *hi (Ant range, Element range).
func (*SliderW) A11yLabel
func (w *SliderW) A11yLabel(s string) *SliderWA11yLabel sets the accessible name (inside a FormItem the item label is used). A range names its group; the handles are "minimum" / "maximum".
func (*SliderW) AllowCross
func (w *SliderW) AllowCross(on bool) *SliderWAllowCross sets whether a dragged range handle may pass the other one (they swap values and the dragged handle continues as the other end). Default true; false stops it at the other handle. Keyboard steps never cross.
func (*SliderW) ChangeComplete
func (w *SliderW) ChangeComplete() boolChangeComplete reports the end of a change (antd onChangeComplete): the frame the pointer is released after dragging changed the value, or a keyboard / number box / assistive change.
func (*SliderW) Changed
func (w *SliderW) Changed() boolChanged reports a value change this frame.
func (*SliderW) Disabled
func (w *SliderW) Disabled(on bool) *SliderWDisabled turns the slider off.
func (*SliderW) Dots
func (w *SliderW) Dots() *SliderWDots draws a dot at every step (Ant dots, Element show-stops).
func (*SliderW) Included
func (w *SliderW) Included(on bool) *SliderWIncluded sets whether the part from the start to the value (a range: between the handles) is filled (antd included, default true); false leaves the rail plain, for marks that are points rather than ranges.
func (*SliderW) Keyboard
func (w *SliderW) Keyboard(on bool) *SliderWKeyboard turns the arrow / Page / Home / End keys on (the default) or off (antd keyboard); the handles stay focusable.
func (*SliderW) Layout
func (w *SliderW) Layout(opts ...layout.Option) *SliderWLayout applies layout options to the slider row.
func (*SliderW) Marks
func (w *SliderW) Marks(m map[float64]string) *SliderWMarks labels values on the rail (a dot is drawn at each mark).
func (*SliderW) Pushable
func (w *SliderW) Pushable(gap float64) *SliderWPushable keeps range handles at least gap apart: moving one towards the other pushes it along (until it reaches the end of the slider). It turns crossing off. 0 disables.
func (*SliderW) Range
func (w *SliderW) Range(hi *float64) *SliderWRange turns the slider into a range: *val is the start, *hi the end.
func (*SliderW) Reverse
func (w *SliderW) Reverse() *SliderWReverse runs the slider the other way (antd reverse): max at the inline start (at the bottom when vertical). The arrow keys follow the visual direction.
func (*SliderW) Step
func (w *SliderW) Step(s float64) *SliderWStep sets the value granularity (0: continuous).
func (*SliderW) Tooltip
func (w *SliderW) Tooltip(format func(float64) string) *SliderWTooltip sets the tooltip formatter of the handle value (nil: the plain number). The tooltip shows while a handle is hovered, dragged or focused with the keyboard; TooltipOpen forces it.
func (*SliderW) TooltipOpen
func (w *SliderW) TooltipOpen(on bool) *SliderWTooltipOpen always shows (true) or never shows (false) the tooltips.
func (*SliderW) Vertical
func (w *SliderW) Vertical(height float32) *SliderWVertical lays the slider out vertically with the given height (min at the bottom).
func (*SliderW) WithInput
func (w *SliderW) WithInput() *SliderWWithInput adds InputNumbers bound to the values (Element show-input). A single horizontal slider has the box after the track; a range has the start box before the track and the end box after it. Vertically the boxes go below the track (a range: the end box above, the start box below).
SortOrder
type SortOrder uint8SortOrder is a column sort direction.
Append-only: never reorder or insert; the zero value stays SortNone.
const (
SortNone SortOrder = iota
SortAsc
SortDesc
)SortState
type SortState struct {
Column string // TableColumn.Key
Order SortOrder
}SortState is a column's sort, owned by the app (controlled) or by the table (uncontrolled).
SpaceW
type SpaceW struct {
// contains filtered or unexported fields
}SpaceW sets the spacing between inline items (Ant Space).
func Space
func Space(c *Context) *SpaceWSpace starts a horizontal group with the Small (8px) gap and centered items; chain options, then Body. ConfigProvider's Defaults("Space", Props{...}) keys: "size" (ControlSize), "orientation" ("horizontal" | "vertical").
ui.Space(c).Body(func() { ui.Button(c, "A"); ui.Button(c, "B") })
ui.Space(c).Orientation("vertical").Size(ui.Large).Body(fn)
ui.Space(c).Separator(func() { ui.VDivider(c) }).Body(fn)
func (*SpaceW) Align
func (s *SpaceW) Align(a layout.Align) *SpaceWAlign positions items on the cross axis (default center; start when vertical).
func (*SpaceW) Body
func (s *SpaceW) Body(fn func()) *BoxBody adds the items.
func (*SpaceW) Layout
func (s *SpaceW) Layout(o ...layout.Option) *SpaceWLayout applies extra layout options (margins, width, ...).
func (*SpaceW) Orientation
func (s *SpaceW) Orientation(o string) *SpaceWOrientation sets the direction: "horizontal" (default) or "vertical" (Ant v6 orientation, which replaces direction; Element direction). Vertical items align to the start. Other values are ignored.
func (*SpaceW) Separator
func (s *SpaceW) Separator(fn func()) *SpaceWSeparator builds a separator between every two items (Ant v6 separator, Element spacer), e.g. ui.VDivider or a Text; it is built once per gap, never before the first item or after the last.
func (*SpaceW) Size
func (s *SpaceW) Size(sz ControlSize) *SpaceWSize sets the gap with a size token (Small 8, Middle 16, Large 24).
func (*SpaceW) SizePx
func (s *SpaceW) SizePx(h, v float32) *SpaceWSizePx sets horizontal and vertical gaps in pixels.
func (*SpaceW) Split
func (s *SpaceW) Split(fn func()) *SpaceWSplit builds a separator between every two items (e.g. VDivider).
Deprecated: use Separator (Ant v6 renamed split to separator).
func (*SpaceW) Vertical
func (s *SpaceW) Vertical() *SpaceWVertical stacks the items.
func (*SpaceW) Wrap
func (s *SpaceW) Wrap() *SpaceWWrap wraps items onto new lines (horizontal only).
Span 实验性
type Span struct {
Text string
Bold bool
Italic bool // synthetic oblique (text.Style.Italic)
Strike bool
Underline bool
Code bool // inline code box, monospace
Mono bool // monospace without the box
Mark bool // highlighted background
Link string
Color theme.Color // zero: default color
Size float32 // 0: paragraph size
}Span is a run of styled inline text.
func ParseMarkdownInline 实验性
func ParseMarkdownInline(s string) []SpanParseMarkdownInline converts inline Markdown (emphasis, code, links...) into spans for RichText.
SpinW
type SpinW struct {
// contains filtered or unexported fields
}SpinW is a loading indicator: sizes, description, delayed show, progress percent and a nested mode (Wrap) that dims the wrapped content.
func Spin
func Spin(c *Context) *SpinWSpin adds a loading indicator; chain options. Wrap turns it into a container that covers its content while spinning:
ui.Spin(c).Size(ui.Large).Description("加载中")
ui.Spin(c).Spinning(loading).Wrap(func() { ... })
ConfigProvider.Defaults("Spin", ...) keys: "size", "delay", "description" ("tip" before antd 6).
func (*SpinW) Delay
func (s *SpinW) Delay(d time.Duration) *SpinWDelay shows the indicator only after spinning lasted d (avoids flashes); it hides at once when spinning stops (antd delay).
func (*SpinW) Description
func (s *SpinW) Description(t string) *SpinWDescription shows a text under the indicator (antd 6 description).
func (*SpinW) Indicator
func (s *SpinW) Indicator(ic *icon.Icon) *SpinWIndicator replaces the indicator with a spinning icon (antd indicator, EP spinner).
func (*SpinW) IndicatorSize
func (s *SpinW) IndicatorSize(px float32) *SpinWIndicatorSize sets a custom indicator size in px.
func (*SpinW) Percent
func (s *SpinW) Percent(p float64) *SpinWPercent replaces the indicator with a progress ring (0..100); at 0 the indicator still spins (antd).
func (*SpinW) PercentAuto
func (s *SpinW) PercentAuto() *SpinWPercentAuto shows a simulated progress that slows down as it nears 100 while spinning (antd percent="auto": every 200ms it advances 5% of the rest up to 30, 3% up to 70, 1% up to 96).
func (*SpinW) Size
func (s *SpinW) Size(sz ControlSize) *SpinWSize sets small, middle (default) or large.
func (*SpinW) Spinning
func (s *SpinW) Spinning(on bool) *SpinWSpinning toggles the indicator (default on).
func (*SpinW) Tip
func (s *SpinW) Tip(t string) *SpinWTip shows a text under the indicator.
Deprecated: use Description (antd 6 renamed tip to description).
func (*SpinW) Wrap
func (s *SpinW) Wrap(fn func()) *BoxWrap builds content and, while spinning, dims it and centers the indicator above it (Ant nested Spin).
SplitterPanelW 实验性
type SplitterPanelW struct {
// contains filtered or unexported fields
}SplitterPanelW is one pane of a Splitter.
func SplitterPanel 实验性
func SplitterPanel(c *Context) *SplitterPanelWSplitterPanel adds a pane; call it inside Splitter.Body.
func (*SplitterPanelW) AlwaysShowCollapse 实验性
func (p *SplitterPanelW) AlwaysShowCollapse(on bool) *SplitterPanelWAlwaysShowCollapse keeps the adjacent bar's collapse controls visible without hover, like antd's collapsible.showCollapsibleIcon=true. It applies to Collapsible and Tango's single-arrow CollapseToggle.
func (*SplitterPanelW) Body 实验性
func (p *SplitterPanelW) Body(fn func()) *SplitterPanelWBody sets the pane content.
func (*SplitterPanelW) CollapseOffsets 实验性
func (p *SplitterPanelW) CollapseOffsets(expanded, collapsed float32) *SplitterPanelWCollapseOffsets sets the toggle center's distance from the bar in logical pixels. Positive values shift it toward the expanded pane, or toward its neighbor when collapsed. Use with CollapseToggle.
func (*SplitterPanelW) CollapseToggle 实验性
func (p *SplitterPanelW) CollapseToggle(collapseTip, expandTip string) *SplitterPanelWCollapseToggle shows a single arrow on the adjacent bar, like an IDE side bar: it points at this pane and collapses it, then flips and restores the saved size. Hovering the arrow shows collapseTip (expandTip while collapsed); the tips also name the button for screen readers and default to the locale's Collapse / Expand. Enter on the bar toggles it.
func (*SplitterPanelW) Collapsed 实验性
func (p *SplitterPanelW) Collapsed(on bool) *SplitterPanelWCollapsed controls whether this pane is folded. Use Collapsible or CollapseToggle to add a bar control and OnCollapse to accept its changes.
func (*SplitterPanelW) Collapsible 实验性
func (p *SplitterPanelW) Collapsible() *SplitterPanelWCollapsible shows collapse arrows on the adjacent bars.
func (*SplitterPanelW) DefaultPercent 实验性
func (p *SplitterPanelW) DefaultPercent(f float32) *SplitterPanelWDefaultPercent sets the initial size as a fraction (0.3 = 30%).
func (*SplitterPanelW) DefaultSize 实验性
func (p *SplitterPanelW) DefaultSize(px float32) *SplitterPanelWDefaultSize sets the initial size in pixels.
func (*SplitterPanelW) Max 实验性
func (p *SplitterPanelW) Max(px float32) *SplitterPanelWMax sets the maximum size in pixels.
func (*SplitterPanelW) MaxPercent 实验性
func (p *SplitterPanelW) MaxPercent(f float32) *SplitterPanelWfunc (*SplitterPanelW) Min 实验性
func (p *SplitterPanelW) Min(px float32) *SplitterPanelWMin sets the minimum size in pixels.
func (*SplitterPanelW) MinPercent 实验性
func (p *SplitterPanelW) MinPercent(f float32) *SplitterPanelWMinPercent / MaxPercent limit the size as a fraction of the splitter (antd min / max "20%"); with Min / Max too, the tighter limit wins. A minimum above the maximum keeps the pane at the minimum.
func (*SplitterPanelW) OnCollapse 实验性
func (p *SplitterPanelW) OnCollapse(fn func(bool)) *SplitterPanelWOnCollapse reports whether a bar action folded or restored this pane. Programmatic changes to Collapsed do not emit this callback.
func (*SplitterPanelW) OnResize 实验性
func (p *SplitterPanelW) OnResize(fn func(float32)) *SplitterPanelWOnResize reports an expanded pane's new size in logical pixels when a bar is moved by the user. Lazy pointer drags report on release.
func (*SplitterPanelW) Resizable 实验性
func (p *SplitterPanelW) Resizable(on bool) *SplitterPanelWResizable(false) locks the bars next to this pane.
func (*SplitterPanelW) Size 实验性
func (p *SplitterPanelW) Size(px float32) *SplitterPanelWSize controls the expanded pane size in logical pixels along the splitter's axis. A pane without Size shares the remaining space. Use OnResize to accept changes made with the bar.
SplitterW 实验性
type SplitterW struct {
// contains filtered or unexported fields
}SplitterW lays panes side by side with draggable bars.
func Splitter 实验性
func Splitter(c *Context) *SplitterWSplitter starts a split view; chain options, then Body with SplitterPanel calls.
ConfigProvider.Defaults("Splitter", ...) keys: "orientation" ("vertical"; antd 6), "layout" (its deprecated name), "lazy", "withHandle" (bool).
Under shadcn/ui this is Resizable: a 1px border line, WithHandle adds the grip box of ResizableHandle withHandle.
func (*SplitterW) Body 实验性
func (s *SplitterW) Body(fn func()) *BoxBody builds the panes.
func (*SplitterW) Changed 实验性
func (s *SplitterW) Changed() boolChanged reports a resize or collapse this frame.
func (*SplitterW) DragEnded 实验性
func (s *SplitterW) DragEnded() (bar int, ok bool)DragEnded reports the bar whose pointer drag ended this frame (released or cancelled). In Lazy mode the sizes are already committed.
func (*SplitterW) DragStarted 实验性
func (s *SplitterW) DragStarted() (bar int, ok bool)DragStarted reports the bar (1-based: bar i sits before pane i) whose pointer drag began this frame.
func (*SplitterW) Dragging 实验性
func (s *SplitterW) Dragging() boolDragging reports whether a bar is being dragged with the pointer.
func (*SplitterW) KeyboardMinimumCap 实验性
func (s *SplitterW) KeyboardMinimumCap(fraction float32) *SplitterWKeyboardMinimumCap caps each pane's keyboard-only minimum to the given fraction of the adjacent pair's total size. A non-positive value uses the pane minima unchanged. Pointer dragging always uses the pane minima.
func (*SplitterW) KeyboardStep 实验性
func (s *SplitterW) KeyboardStep(step, shiftStep float32) *SplitterWKeyboardStep sets arrow and Shift+arrow increments as fractions of the two adjacent panes' total size. A positive step also restricts arrows to the splitter's axis. Zero restores the default 10 px step.
func (*SplitterW) KeyboardStepPixels 实验性
func (s *SplitterW) KeyboardStepPixels(step, shiftStep float32) *SplitterWKeyboardStepPixels sets arrow and Shift+arrow increments in logical pixels. A positive step restricts arrows to the splitter's axis.
func (*SplitterW) Lazy 实验性
func (s *SplitterW) Lazy() *SplitterWLazy makes a drag show only a preview line; the panes keep their sizes until the pointer is released, then the new ratio is committed at once (Changed reports it on that frame). Keyboard resizing is unaffected.
func (*SplitterW) Orientation 实验性
func (s *SplitterW) Orientation(o string) *SplitterWOrientation lays the panes out "horizontal" (default, side by side) or "vertical" (antd 6 orientation; layout deprecated).
func (*SplitterW) PixelSizes 实验性
func (s *SplitterW) PixelSizes() []float32PixelSizes returns the effective pane sizes in logical pixels along the splitter's axis, excluding the bars. Call it after Body.
func (*SplitterW) Sizes 实验性
func (s *SplitterW) Sizes() []float32Sizes returns the pane sizes as fractions.
func (*SplitterW) Style 实验性
func (s *SplitterW) Style(opts ...layout.Option) *SplitterWStyle applies layout options (give the splitter a size, e.g. layout.H(200)).
func (*SplitterW) Vertical 实验性
func (s *SplitterW) Vertical() *SplitterWVertical stacks panes top to bottom.
Deprecated: use Orientation("vertical") (antd 6 orientation).
func (*SplitterW) WithHandle 实验性
func (s *SplitterW) WithHandle() *SplitterWWithHandle draws a grip on every resizable bar (shadcn ResizableHandle withHandle).
StatisticCardDividerW 实验性
type StatisticCardDividerW struct {
// contains filtered or unexported fields
}StatisticCardDividerW is an explicit Pro statistic divider.
func StatisticCardDivider 实验性
func StatisticCardDivider(c *Context, orientation string) *StatisticCardDividerWStatisticCardDivider builds StatisticCard.Divider. Empty orientation reads the Defaults key "orientation" and otherwise defaults to vertical.
func (*StatisticCardDividerW) Layout 实验性
func (w *StatisticCardDividerW) Layout(opts ...layout.Option) *StatisticCardDividerWLayout applies layout options to the divider.
StatisticCardLocale 实验性
type StatisticCardLocale struct {
Up, Down string
// contains filtered or unexported fields
}StatisticCardLocale holds the accessible names of the trend marks.
StatisticCardOperationW 实验性
type StatisticCardOperationW struct {
// contains filtered or unexported fields
}StatisticCardOperationW is an operator between statistics.
func StatisticCardOperation 实验性
func StatisticCardOperation(c *Context, value string) *StatisticCardOperationWStatisticCardOperation builds StatisticCard.Operation using heading-4 typography and Pro's marginLG block spacing.
func (*StatisticCardOperationW) Layout 实验性
func (w *StatisticCardOperationW) Layout(opts ...layout.Option) *StatisticCardOperationWLayout applies layout options to the operation.
StatisticCardW 实验性
type StatisticCardW struct {
// contains filtered or unexported fields
}StatisticCardW builds a StatisticCard.
func StatisticCard 实验性
func StatisticCard(c *Context, title string) *StatisticCardWStatisticCard starts a statistic card titled title (the statistic's label; use CardTitle for a card header). Chain options, then Show.
func (*StatisticCardW) Bordered 实验性
func (w *StatisticCardW) Bordered() *StatisticCardWBordered draws a border.
func (*StatisticCardW) Card 实验性
func (w *StatisticCardW) Card() *ProCardWCard returns the underlying ProCard (valid after Show for queries).
func (*StatisticCardW) CardTitle 实验性
func (w *StatisticCardW) CardTitle(s string) *StatisticCardWCardTitle shows a card header with title (the statistic keeps its own).
func (*StatisticCardW) Chart 实验性
func (w *StatisticCardW) Chart(fn func()) *StatisticCardWChart builds the chart area (a chart.Tiny*, any chart, or content).
func (*StatisticCardW) ChartPlace 实验性
func (w *StatisticCardW) ChartPlace(p string) *StatisticCardWChartPlace puts the chart below (ChartBottom, default), left or right of the statistic.
func (*StatisticCardW) Clicked 实验性
func (w *StatisticCardW) Clicked() boolClicked reports a click on a hoverable card.
func (*StatisticCardW) ColSpan 实验性
func (w *StatisticCardW) ColSpan(span int) *StatisticCardWColSpan sizes the card in a parent ProCard / StatisticCardGroup row.
func (*StatisticCardW) Desc 实验性
func (w *StatisticCardW) Desc(title, value, trend string) *StatisticCardWDesc adds an inline statistic under the value ("Week 12% ▲"); trend is "up", "down" or "".
func (*StatisticCardW) Description 实验性
func (w *StatisticCardW) Description(fn func()) *StatisticCardWDescription builds custom content under the value.
func (*StatisticCardW) Extra 实验性
func (w *StatisticCardW) Extra(fn func()) *StatisticCardWExtra builds the header actions.
func (*StatisticCardW) Footer 实验性
func (w *StatisticCardW) Footer(fn func()) *StatisticCardWFooter builds a footer below a divider.
func (*StatisticCardW) Ghost 实验性
func (w *StatisticCardW) Ghost() *StatisticCardWGhost removes the card background and outer padding.
func (*StatisticCardW) Hoverable 实验性
func (w *StatisticCardW) Hoverable() *StatisticCardWHoverable lifts the card on hover.
func (*StatisticCardW) Icon 实验性
func (w *StatisticCardW) Icon(ic *icon.Icon) *StatisticCardWIcon shows an icon left of the statistic.
func (*StatisticCardW) Layout 实验性
func (w *StatisticCardW) Layout(o ...layout.Option) *StatisticCardWLayout applies layout options to the card.
func (*StatisticCardW) Loading 实验性
func (w *StatisticCardW) Loading(on bool) *StatisticCardWLoading shows the card's loading placeholder.
func (*StatisticCardW) Prefix 实验性
func (w *StatisticCardW) Prefix(s string) *StatisticCardWPrefix sets text before the value (e.g. a currency sign).
func (*StatisticCardW) Show 实验性
func (w *StatisticCardW) Show() *StatisticCardWShow builds the card.
func (*StatisticCardW) StatisticLayout 实验性
func (w *StatisticCardW) StatisticLayout(mode string) *StatisticCardWStatisticLayout sets the statistic layout: vertical (default), horizontal (title and value at opposite ends), or inline (compact, secondary value).
func (*StatisticCardW) Status 实验性
func (w *StatisticCardW) Status(s string) *StatisticCardWStatus shows a colored dot before the title ("success", "processing", "warning", "error", "default").
func (*StatisticCardW) Suffix 实验性
func (w *StatisticCardW) Suffix(s string) *StatisticCardWSuffix sets text after the value (e.g. a unit).
func (*StatisticCardW) Tooltip 实验性
func (w *StatisticCardW) Tooltip(tip string) *StatisticCardWTooltip adds a question icon after the title showing tip on hover.
func (*StatisticCardW) Trend 实验性
func (w *StatisticCardW) Trend(dir string) *StatisticCardWTrend marks the value as rising ("up") or falling ("down").
func (*StatisticCardW) TrendColors 实验性
func (w *StatisticCardW) TrendColors(up, down theme.Color) *StatisticCardWTrendColors overrides the rising / falling colors (default: error red for up, success green for down, as in Pro).
func (*StatisticCardW) Value 实验性
func (w *StatisticCardW) Value(v float64, precision int) *StatisticCardWValue sets a number formatted with thousands separators.
func (*StatisticCardW) ValueColor 实验性
func (w *StatisticCardW) ValueColor(col theme.Color) *StatisticCardWValueColor colors the value.
func (*StatisticCardW) ValueText 实验性
func (w *StatisticCardW) ValueText(s string) *StatisticCardWValueText sets the value as preformatted text.
StatisticW
type StatisticW struct {
// contains filtered or unexported fields
}StatisticW shows a labelled number.
func Statistic
func Statistic(c *Context, title string, value float64, precision int) *StatisticWStatistic adds a statistic display. The value is shown with precision decimals, cut (not rounded) like antd and Element Plus; a negative precision shows the decimals the value has. NaN and ±Inf are shown as "NaN" and "Infinity".
ConfigProvider.Defaults("Statistic", ...) keys: "groupSeparator", "decimalSeparator" (string).
func (*StatisticW) Color
func (s *StatisticW) Color(col theme.Color) *StatisticWfunc (*StatisticW) CountUp
func (s *StatisticW) CountUp(v float64, precision int) *StatisticWCountUp animates the displayed value from 0 to v (precision digits) over the slow duration ×4 the first time the statistic appears.
func (*StatisticW) DecimalSeparator
func (s *StatisticW) DecimalSeparator(sep string) *StatisticWDecimalSeparator sets the decimal point (default ".").
func (*StatisticW) Formatter
func (s *StatisticW) Formatter(fn func(v float64) string) *StatisticWFormatter formats the value with fn instead (antd / Element formatter).
func (*StatisticW) GroupSeparator
func (s *StatisticW) GroupSeparator(sep string) *StatisticWGroupSeparator sets the thousands separator (default ",").
func (*StatisticW) Layout
func (s *StatisticW) Layout(o ...layout.Option) *StatisticWLayout applies layout options.
func (*StatisticW) Loading
func (s *StatisticW) Loading(on bool) *StatisticWLoading replaces the value with a skeleton bar.
func (*StatisticW) Prefix
func (s *StatisticW) Prefix(p string) *StatisticWfunc (*StatisticW) PrefixIcon
func (s *StatisticW) PrefixIcon(ic *icon.Icon) *StatisticWfunc (*StatisticW) Suffix
func (s *StatisticW) Suffix(p string) *StatisticWfunc (*StatisticW) Value
func (s *StatisticW) Value(v string) *StatisticWfunc (*StatisticW) ValueSize
func (s *StatisticW) ValueSize(px float32) *StatisticWValueSize sets the value font size (line height follows).
StatusBarItemW 实验性
type StatusBarItemW struct {
// contains filtered or unexported fields
}StatusBarItemW is one entry of a StatusBar: an icon, text, a count badge and a progress bar, in that order, any of them optional.
func StatusBarItem 实验性
func StatusBarItem(c *Context, label string) *StatusBarItemWStatusBarItem adds an entry to the StatusBar being built (outside a bar it draws the same, at the bar's height). label is the visible text and the accessible name; an icon-only item ("" label) is named by its Tooltip or A11yLabel.
Items are buttons by default: hover highlight, Tab stop, Enter / Space or a click report Clicked. Static makes a plain read-out.
func (*StatusBarItemW) A11yLabel 实验性
func (w *StatusBarItemW) A11yLabel(s string) *StatusBarItemWA11yLabel replaces the accessible name.
func (*StatusBarItemW) Badge 实验性
func (w *StatusBarItemW) Badge(n int) *StatusBarItemWBadge shows a count after the text (0 hides it; above 99 shows "99+").
func (*StatusBarItemW) BadgeText 实验性
func (w *StatusBarItemW) BadgeText(s string) *StatusBarItemWBadgeText shows s in the badge ("" hides it).
func (*StatusBarItemW) Clicked 实验性
func (w *StatusBarItemW) Clicked() boolClicked reports a click (or Enter / Space) on the item.
func (*StatusBarItemW) Disabled 实验性
func (w *StatusBarItemW) Disabled(on bool) *StatusBarItemWDisabled dims the item and stops it from reacting.
func (*StatusBarItemW) Hovered 实验性
func (w *StatusBarItemW) Hovered() boolHovered reports whether the pointer is over the item.
func (*StatusBarItemW) ID 实验性
func (w *StatusBarItemW) ID() IDID returns the item's ID.
func (*StatusBarItemW) Icon 实验性
func (w *StatusBarItemW) Icon(ic *icon.Icon) *StatusBarItemWIcon shows ic before the text.
func (*StatusBarItemW) Loading 实验性
func (w *StatusBarItemW) Loading(on bool) *StatusBarItemWLoading spins the icon (icon.Loading when the item has none): a task is running.
func (*StatusBarItemW) Progress 实验性
func (w *StatusBarItemW) Progress(p float64) *StatusBarItemWProgress shows a small determinate progress bar after the text; p runs from 0 to 1 (a negative p hides it). Use Loading for work of unknown length.
func (*StatusBarItemW) Static 实验性
func (w *StatusBarItemW) Static() *StatusBarItemWStatic makes the item a plain read-out: no hover highlight, not a Tab stop, never Clicked (a Tooltip still shows on hover).
func (*StatusBarItemW) Status 实验性
func (w *StatusBarItemW) Status(s string) *StatusBarItemWStatus fills the item with a status color ("warning", "error", "success", "info", "primary"), as VS Code marks problems or a remote connection.
func (*StatusBarItemW) Tooltip 实验性
func (w *StatusBarItemW) Tooltip(tip string) *StatusBarItemWTooltip shows tip above the item while the pointer rests on it or while it has keyboard focus; screen readers get it as the description (as the name of an icon-only item).
StatusBarLocale 实验性
type StatusBarLocale struct {
Label string // accessible name of the bar ("状态栏")
// contains filtered or unexported fields
}StatusBarLocale holds the StatusBar texts.
StatusBarW 实验性
type StatusBarW struct {
// contains filtered or unexported fields
}StatusBarW is the strip at the bottom of a workbench window (VS Code / JetBrains status bar): items at its start (Left) and end (Right).
func StatusBar 实验性
func StatusBar(c *Context) *StatusBarWStatusBar adds a status bar; fill its two sides with StatusBarItem:
ui.StatusBar(c).
Left(func() {
if ui.StatusBarItem(c, "main").Icon(icon.Branch).Tooltip("切换分支").Clicked() { ... }
ui.StatusBarItem(c, "").Icon(icon.Sync).Loading(true)
}).
Right(func() {
ui.StatusBarItem(c, "Ln 12, Col 5")
ui.StatusBarItem(c, "UTF-8").Static()
})
Left and right are logical: in RTL the sides swap. The bar stretches across its parent column; the left side clips when the items do not fit.
func (*StatusBarW) A11yLabel 实验性
func (s *StatusBarW) A11yLabel(name string) *StatusBarWA11yLabel replaces the accessible name (Locale.StatusBar.Label).
func (*StatusBarW) ID 实验性
func (s *StatusBarW) ID() IDID returns the bar's ID.
func (*StatusBarW) Layout 实验性
func (s *StatusBarW) Layout(o ...layout.Option) *StatusBarWLayout adds layout options to the bar (margins, width).
func (*StatusBarW) Left 实验性
func (s *StatusBarW) Left(fn func()) *StatusBarWLeft builds the items at the bar's start.
func (*StatusBarW) Right 实验性
func (s *StatusBarW) Right(fn func()) *StatusBarWRight builds the items at the bar's end.
func (*StatusBarW) Status 实验性
func (s *StatusBarW) Status(st string) *StatusBarWStatus fills the whole bar with a status color ("primary", "success", "warning", "error", "info"; "" the default neutral bar), as VS Code colors it while debugging or without a folder. Item text switches to the matching on-solid color.
StepDot
type StepDot struct {
Index int // 0-based step index
Status string // "wait", "process", "finish", "error" or the finish status ("success")
Title string // the step's title
Rect geom.Rect // the area of the default dot; draw around its center
Color theme.Color // the default dot color for Status
// Default draws the standard dot, so a renderer can decorate it.
Default func()
// contains filtered or unexported fields
}StepDot describes one dot to a custom dot renderer (DotRender).
StepItem
type StepItem struct {
Title string
SubTitle string
// Description is the text under the title.
//
// Deprecated: use Content (antd 6 items[].content).
Description string
Content string // text under the title (antd 6 content); wins over Description
Icon *icon.Icon // custom icon replaces the numbered circle
Status string // override: "wait", "process", "finish", "error"
Disabled bool // not clickable
// contains filtered or unexported fields
}StepItem is one entry of Steps.
StepsFormStep 实验性
type StepsFormStep struct {
Title, Description string
Fields []ProField
Columns int
// Children builds extra items after the fields (FormList ...).
Children func(f *FormW)
}StepsFormStep is one step of a StepsForm.
StepsFormW 实验性
type StepsFormW struct {
// contains filtered or unexported fields
}StepsFormW splits a form into steps (Ant Design Pro StepsForm): the current step's fields validate before moving on; the last step submits the values of all steps.
func StepsForm 实验性
func StepsForm(c *Context, steps []StepsFormStep) *StepsFormWStepsForm starts a step form; chain options, then Show.
func (*StepsFormW) Current 实验性
func (s *StepsFormW) Current() intCurrent returns the 0-based current step (valid after Show).
func (*StepsFormW) Finished 实验性
func (s *StepsFormW) Finished() boolFinished reports a completed submit of the last step, once.
func (*StepsFormW) OnFinish 实验性
func (s *StepsFormW) OnFinish(fn func(vals ProValues, done func(error))) *StepsFormWOnFinish receives the values after the last step validated; call done (from any goroutine) when saved.
func (*StepsFormW) SetCurrent 实验性
func (s *StepsFormW) SetCurrent(i int) *StepsFormWSetCurrent jumps to step i (no validation).
func (*StepsFormW) Show 实验性
func (s *StepsFormW) Show() *StepsFormWShow builds the steps and the current step's form.
func (*StepsFormW) Values 实验性
func (s *StepsFormW) Values(v *ProValues) *StepsFormWValues binds the values of all steps.
func (*StepsFormW) Width 实验性
func (s *StepsFormW) Width(px float32) *StepsFormWWidth sets the form width under the steps (default 600).
StepsW
type StepsW struct {
// contains filtered or unexported fields
}StepsW shows progress through a sequence: horizontal / vertical, dot style, small size, label placement, custom icons and clickable steps.
func Steps
func Steps(c *Context, items []StepItem) *StepsWSteps starts a step bar; chain options, then Show:
ui.Steps(c, items).Current(1).Status("error").Show()
ConfigProvider.Defaults("Steps", ...) keys: "type" ("default" | "navigation" | "inline" | "panel" | "dot"), "size" (ControlSize or "small"), "orientation" / "direction" ("vertical"), "titlePlacement" / "labelPlacement" ("vertical"), "variant" ("filled" | "outlined"), "progressDot" (bool), "maxCount" (int). The antd 6 names (orientation, titlePlacement, type "dot", items[].content) win over the deprecated ones.
Out-of-range Current values are kept: below 0 every step waits, past the last one every step is finished (antd).
func (*StepsW) Changed
func (s *StepsW) Changed() boolChanged reports a click on another step.
func (*StepsW) Clickable
func (s *StepsW) Clickable(cur *int) *StepsWClickable binds the current step and lets the user click any step.
func (*StepsW) Current
func (s *StepsW) Current(i int) *StepsWCurrent sets the 0-based current step.
func (*StepsW) Dot
func (s *StepsW) Dot() *StepsWDot uses the dot style (labels under the dots).
Deprecated: use Type("dot") (antd 6 type="dot", progressDot deprecated).
func (*StepsW) DotRender
func (s *StepsW) DotRender(fn func(l *paint.List, d StepDot)) *StepsWDotRender uses the dot style with dots drawn by fn (Ant progressDot as a function). fn gets the step index and status with the dot's rectangle, and may call d.Default to draw the standard dot first. It also draws the dots of the inline type.
ui.Steps(c, items).Current(1).DotRender(func(l *paint.List, d ui.StepDot) {
d.Default()
if d.Status == "process" {
p := d.Rect.Center()
l.StrokePath(paint.NewPath().Circle(p.X, p.Y, 8), paint.StrokeStyle{Width: 1}, d.Color)
}
})
func (*StepsW) FinishStatus
func (s *StepsW) FinishStatus(st string) *StepsWFinishStatus sets the status shown by finished steps ("success" paints them green, Element finish-status).
func (*StepsW) Initial
func (s *StepsW) Initial(n int) *StepsWInitial numbers the steps from initial+1; Current, Clickable and the bound value count from it too (antd initial).
func (*StepsW) Inline
func (s *StepsW) Inline() *StepsWInline uses the inline type (Ant type="inline"): a compact row of small dots on a line with the titles under them, sized to its content so it fits inside list rows and cards. Descriptions are not drawn; they stay in the accessible description.
func (*StepsW) LabelVertical
func (s *StepsW) LabelVertical() *StepsWLabelVertical puts titles under the icons.
Deprecated: use TitlePlacement("vertical").
func (*StepsW) MaxCount
func (s *StepsW) MaxCount(n int) *StepsWMaxCount shows at most n steps (n >= 3; antd 6.7 maxCount): the first, the last and the current step stay, the nearest ones fill the other slots and each hidden range becomes a disabled ellipsis step whose status sums it up (error if any hidden step failed, finish if all are done).
func (*StepsW) Orientation
func (s *StepsW) Orientation(o string) *StepsWOrientation lays the steps out "horizontal" (default) or "vertical" (antd 6 orientation; direction is its deprecated name).
func (*StepsW) Panel
func (s *StepsW) Panel() *StepsWPanel uses the panel type (Ant type="panel"): every step is an arrow-shaped panel sharing the row, the current one highlighted.
func (*StepsW) Percent
func (s *StepsW) Percent(p float64) *StepsWPercent shows the progress (0..100) of the current step as a ring around its icon (Ant percent).
func (*StepsW) Show
func (s *StepsW) Show() *StepsWShow builds the steps.
func (*StepsW) Size
func (s *StepsW) Size(sz ControlSize) *StepsWSize sets the size (Small or Middle).
func (*StepsW) Small
func (s *StepsW) Small() *StepsWSmall uses the small size.
func (*StepsW) Status
func (s *StepsW) Status(st string) *StepsWStatus sets the status of the current step ("process", "error", "finish", "wait").
func (*StepsW) TitlePlacement
func (s *StepsW) TitlePlacement(p string) *StepsWTitlePlacement puts the titles beside the icons ("horizontal", default) or under them ("vertical"; antd 6 titlePlacement, labelPlacement deprecated). Dot steps always put them under.
func (*StepsW) Type
func (s *StepsW) Type(t string) *StepsWType selects "default", "navigation" (Ant type="navigation": steps as tabs with chevrons, the current one underlined; Element's simple steps look the same way in the Element theme; "simple" is accepted too), "inline" (see Inline) or "panel" (see Panel).
func (*StepsW) Variant
func (s *StepsW) Variant(v string) *StepsWVariant picks "filled" (default) or "outlined" icons (antd 6 variant: outlined icons are rings in the status color on the container background, the current one on a light primary fill).
func (*StepsW) Vertical
func (s *StepsW) Vertical() *StepsWVertical stacks the steps.
Deprecated: use Orientation("vertical") (antd 6 orientation).
SwitchW
type SwitchW struct {
// contains filtered or unexported fields
}SwitchW is a toggle switch.
func Switch
func Switch(c *Context, val *bool) *SwitchWSwitch adds a switch bound to *val.
func SwitchValue 实验性
func SwitchValue[T comparable](c *Context, val *T, on, off T) *SwitchWSwitchValue adds a switch bound to an arbitrary value (Element active-value / inactive-value): it is on while *val == on, and toggling writes on or off into *val. Any other value shows the switch off.
func (*SwitchW) A11yLabel
func (w *SwitchW) A11yLabel(s string) *SwitchWA11yLabel sets the accessible name (a switch has no visible label; inside a FormItem the item label is used).
func (*SwitchW) ActionIcons
func (w *SwitchW) ActionIcons(on, off *icon.Icon) *SwitchWActionIcons shows an icon on the thumb (Element active-action-icon / inactive-action-icon), in the track color of the state. Either may be nil.
func (*SwitchW) BeforeChange
func (w *SwitchW) BeforeChange(fn func(next bool) bool) *SwitchWBeforeChange is asked before every toggle with the value the switch would take; returning false keeps the current value.
func (*SwitchW) BeforeChangeAsync
func (w *SwitchW) BeforeChangeAsync(fn func(next bool, done func(ok bool))) *SwitchWBeforeChangeAsync asks fn before every toggle; the switch shows loading and ignores clicks until fn calls done (from any goroutine, once): with true the switch takes next, with false it stays. done wakes the window.
func (*SwitchW) Changed
func (w *SwitchW) Changed() boolfunc (*SwitchW) Disabled
func (w *SwitchW) Disabled(on bool) *SwitchWfunc (*SwitchW) Icons
func (w *SwitchW) Icons(on, off *icon.Icon) *SwitchWIcons shows on / off icons inside the track (Element inline-prompt with active-icon / inactive-icon). Either may be nil.
func (*SwitchW) Large
func (w *SwitchW) Large() *SwitchWLarge selects the large switch.
func (*SwitchW) Loading
func (w *SwitchW) Loading(on bool) *SwitchWfunc (*SwitchW) OuterTexts
func (w *SwitchW) OuterTexts(on, off string) *SwitchWOuterTexts shows labels beside the track (Element active-text / inactive-text): off before it, on after it; the label of the current state takes the brand color. Clicking a label toggles the switch.
func (*SwitchW) Size
func (w *SwitchW) Size(s ControlSize) *SwitchWSize sets the switch size (Small, Middle or Large).
func (*SwitchW) Small
func (w *SwitchW) Small() *SwitchWfunc (*SwitchW) Texts
func (w *SwitchW) Texts(on, off string) *SwitchWTexts shows on / off text inside the track (Ant checkedChildren, Element inline-prompt).
func (*SwitchW) Width
func (w *SwitchW) Width(px float32) *SwitchWWidth sets the track width in px (Element width); by default the track has the theme's minimum width and grows to fit the inline texts.
TabItem
type TabItem struct {
Key, Label string
Icon *icon.Icon
Disabled bool
NoClose bool // no close button on this tab of a Closable bar
// contains filtered or unexported fields
}TabItem is a tab.
TableColumn
type TableColumn struct {
Key string
Title string
// Width fixes the width; 0 shares the remaining space by Grow (default
// 1), never below MinWidth (default 80).
Width float32
Grow float32
MinWidth float32
// Align aligns the cell and header text: AlignLeft / AlignRight
// (AlignStart / AlignEnd) follow the direction, so an end-aligned
// numeric column lines up on the left in RTL; AlignPhysicalLeft /
// AlignPhysicalRight never flip.
Align TextAlign
// Fixed pins the column ("left" | "right": start | end, see FixedLeft)
// while scrolling sideways.
Fixed string
// Ellipsis shows the full text in a tooltip when a truncated cell is
// hovered (text cells stay on one line).
Ellipsis bool
// Wrap lets the cell text wrap onto several lines; rows grow to fit
// their tallest cell (measured, also under virtual scrolling). Render
// cells of a Wrap column wrap their widgets and are measured after
// layout. Wrap and Ellipsis are exclusive: Wrap wins.
Wrap bool
// Hidden hides the column until it is enabled in the column settings.
Hidden bool
// Sortable shows the sorter. With Compare the table sorts locally;
// without it the app sorts (server-side) using the reported SortState.
Sortable bool
Compare func(a, b int) int
// SortMultiple > 0 lets this column take part in multi-column sorting;
// a higher value has a higher priority.
SortMultiple int
// DefaultSort is the initial order when the table owns its sort state.
DefaultSort SortOrder
// SortDirections lists the orders a sorter click cycles through
// (Ant Design sortDirections, Element Plus sort-orders); after the
// last one the column returns to unsorted. Empty: the table's
// SortDirections, by default ascending, descending.
SortDirections []SortOrder
// Filters lists the values of the filter dropdown. OnFilter filters
// locally (a row passes if it matches any selected value); without it
// the app filters using the reported filter state.
Filters []Option
FilterSearch bool // search box above the options
FilterSingle bool // radio instead of checkboxes
OnFilter func(row int, value string) bool
// FilterPanel replaces the option list with a custom panel.
FilterPanel func(p *TableFilterPanel)
// DefaultFilter is the initial filter of the column when the table
// owns its filter state, or when the bound Filters map has no entry
// for the column on the first frame (Ant Design defaultFilteredValue).
DefaultFilter []string
// FilterResetToDefault makes the filter's reset button restore
// DefaultFilter instead of clearing it (Ant Design
// filterResetToDefaultFilteredValue).
FilterResetToDefault bool
// Text returns the cell text; Render, if set, builds custom content
// (any widget: tags, badges, buttons, progress, avatars).
Text func(row int) string
Render func(row int)
// Children makes this a header group (multi-level header).
Children []TableColumn
// Editor makes the cells editable.
Editor *TableEditor
}TableColumn describes one column. Only Key/Title and one of Text/Render are needed; everything else is optional.
只有部分成员是稳定的:未标「实验性」的方法和下列以外的字段受兼容性承诺约束。
实验性 实验性成员:SortMultiple、SortDirections、FilterSearch、FilterSingle、FilterPanel、DefaultFilter、FilterResetToDefault、Editor
TableColumnState 实验性
type TableColumnState struct {
Order []string
Hidden map[string]bool
Widths map[string]float32
// Fixed overrides a top-level column's Fixed side: FixedLeft,
// FixedRight or "none" (unpinned).
Fixed map[string]string
}TableColumnState is the user-adjustable column layout: order, visibility and resized widths. ProTable's column settings edit it.
TableDropdownW 实验性
type TableDropdownW struct {
// contains filtered or unexported fields
}TableDropdownW is a row-action dropdown backed by DropdownW. Menu keys, disabled items, focus navigation and dismissal use the same menu model.
func TableDropdown 实验性
func TableDropdown(c *Context, items []MenuItem) *TableDropdownWTableDropdown starts a table-row action menu. Show uses an ellipsis trigger with a localized accessible name. Button selects the ordinary button variant (not a split button). ConfigProvider.Defaults keys: "disabled" (false), "trigger" (TriggerHover), "placement" (BottomStart).
func (*TableDropdownW) Button 实验性
func (w *TableDropdownW) Button(label string) *TableDropdownWButton uses an ordinary button with a down arrow, as TableDropdown.Button.
func (*TableDropdownW) Clicked 实验性
func (w *TableDropdownW) Clicked() stringClicked returns the menu key selected this frame, or an empty string.
func (*TableDropdownW) Disabled 实验性
func (w *TableDropdownW) Disabled(on bool) *TableDropdownWDisabled disables the trigger and menu.
func (*TableDropdownW) ID 实验性
func (w *TableDropdownW) ID() IDID returns the trigger wrapper ID after Show.
func (*TableDropdownW) IsOpen 实验性
func (w *TableDropdownW) IsOpen() boolIsOpen reports whether the menu is expanded.
func (*TableDropdownW) Label 实验性
func (w *TableDropdownW) Label(s string) *TableDropdownWLabel replaces the ellipsis with text.
func (*TableDropdownW) OnSelect 实验性
func (w *TableDropdownW) OnSelect(fn func(string)) *TableDropdownWOnSelect receives the selected menu key.
func (*TableDropdownW) Open 实验性
func (w *TableDropdownW) Open(on *bool) *TableDropdownWOpen binds the expanded state.
func (*TableDropdownW) Show 实验性
func (w *TableDropdownW) Show() *TableDropdownWShow builds the trigger and menu.
func (*TableDropdownW) Trigger 实验性
func (w *TableDropdownW) Trigger(t Trigger) *TableDropdownWTrigger chooses hover, click or context menu activation.
TableEditor 实验性
type TableEditor struct {
Kind string // "text" (default) | "number" | "select" | "date"
Options []Option
Precision int
Value func(row int) string // current value (default: column Text)
Set func(row int, v string) // commit
// Validate returns an error message for an invalid value.
Validate func(v string) string
// Render builds a custom editor for row-edit mode (EditableRows) in
// place of Kind, bound to the app's own draft; Error returns the
// message shown in a tip under it ("" when valid). EditableProTable
// uses it for ProField controls. Without Set the cell is not
// click-to-edit.
Render func(row int)
Error func(row int) string
}TableEditor makes a column's cells editable in place.
TableFilterPanel 实验性
type TableFilterPanel struct {
Values *[]string // draft values; Confirm applies them
// contains filtered or unexported fields
}TableFilterPanel is passed to custom filter panels.
func (*TableFilterPanel) Close 实验性
func (p *TableFilterPanel) Close()Close closes the panel without applying.
func (*TableFilterPanel) Confirm 实验性
func (p *TableFilterPanel) Confirm()Confirm applies the draft values and closes the panel.
func (*TableFilterPanel) Context 实验性
func (p *TableFilterPanel) Context() *ContextContext returns the build context.
func (*TableFilterPanel) Reset 实验性
func (p *TableFilterPanel) Reset()Reset clears the filter and closes the panel.
TableLocale
type TableLocale struct {
FilterSearch string // search box placeholder
FilterAll string // "all" entry of single-choice filters
Filter string // Element's apply button ("筛选")
// Column settings: group titles and pin actions.
FixedLeft, NoFixed, FixedRight, PinLeft, PinRight, Unpin string
// SelectRowFmt names a row's selection checkbox, arg: row number
// ("选择第 %d 行").
SelectRowFmt string
// Selection dropdown next to the header checkbox: its accessible name
// and the built-in SelectionPage / SelectionNone items.
Selections, SelectPage, SelectNone string
// SumText is the first cell of ShowSummary's row (Element Plus
// sum-text, "合计").
SumText string
// contains filtered or unexported fields
}TableLocale holds the Table filter dropdown texts not covered by the common Filter* fields.
TableSelection 实验性
type TableSelection struct {
Key string
Text string
OnSelect func(pageRows []int)
}TableSelection is an item of the header selection menu (Ant Design rowSelection.selections). Key is one of the Selection* constants or a custom key; custom items need Text and OnSelect, which receives the displayed data rows of the current page (change the selection there).
TableSpan 实验性
type TableSpan struct {
Row, Pos, Col int
Key string // column key
}TableSpan identifies a body cell for Span: Row is the data index, Pos the position among the displayed rows, Col the index of the leaf data column.
TableW
type TableW struct {
// contains filtered or unexported fields
}TableW is a data table (Ant Design Table / Element Plus Table + Table V2).
ui.Table(c, cols, len(data)).Selection(&sel).Sort(&sort).ScrollY(400).Show()
Rows are addressed by data index 0..rows-1 (or the ids given to Tree); column callbacks receive that index, so local sorting and filtering never change what a callback sees.
只有部分成员是稳定的:未标「实验性」的方法和全部字段受兼容性承诺约束。
func Table
func Table(c *Context, cols []TableColumn, rows int) *TableWTable starts a table over rows data rows; chain modifiers, then Show.
func (*TableW) A11yLabel
func (t *TableW) A11yLabel(s string) *TableWA11yLabel names the table (grid) for screen readers, e.g. the title of the card it sits in.
func (*TableW) Bordered
func (t *TableW) Bordered() *TableWBordered draws borders around every cell.
func (*TableW) Cancel 实验性
func (t *TableW) Cancel(row int)Cancel leaves row-edit mode without saving.
func (*TableW) CheckLinked 实验性
func (t *TableW) CheckLinked() *TableWCheckLinked turns on the parent/child linkage of tree selection (Ant Design rowSelection.checkStrictly false, Element Plus' default tree-props checkStrictly false): checking a row checks its descendants, a parent is checked once all its children are and shows a half state when only some are. By default (Ant Design checkStrictly true) rows are checked independently.
func (*TableW) CheckStrictly 实验性
func (t *TableW) CheckStrictly() *TableWCheckStrictly checks tree rows independently, without parent/child linkage. It is the default (Ant Design rowSelection.checkStrictly true); it overrides a ConfigProvider default of false. See CheckLinked.
func (*TableW) ColumnState 实验性
func (t *TableW) ColumnState(s *TableColumnState) *TableWColumnState binds column order, visibility and widths.
func (*TableW) CurrentChanged 实验性
func (t *TableW) CurrentChanged() boolCurrentChanged reports that the current row moved in the last Show (Element Plus current-change).
func (*TableW) CurrentRowKey 实验性
func (t *TableW) CurrentRowKey(key *string) *TableWCurrentRowKey binds the highlighted current row by key (Element Plus current-row-key / setCurrentRow); "" means none. It turns on HighlightCurrentRow; CurrentChanged reports clicks that moved it.
func (*TableW) DefaultExpandAllRows 实验性
func (t *TableW) DefaultExpandAllRows() *TableWDefaultExpandAllRows expands every expandable row and tree node on the first frame when the table owns the expansion state (Ant Design expandable.defaultExpandAllRows, Element Plus default-expand-all). Rows of TreeLazy whose children are not loaded stay closed.
func (*TableW) DisplayedRows
func (t *TableW) DisplayedRows() []intDisplayedRows returns the data rows shown on the current page, in order (valid after Show).
func (*TableW) DragSort 实验性
func (t *TableW) DragSort(fn func(from, to int)) *TableWDragSort adds a drag handle column; fn(from, to) moves data row from to the position of data row to.
func (*TableW) Edit 实验性
func (t *TableW) Edit(row int)Edit puts row into row-edit mode.
func (*TableW) EditableRows 实验性
func (t *TableW) EditableRows(keys *[]string) *TableWEditableRows binds the keys of rows in row-edit mode (every column with an Editor shows an input; use Save/Cancel from an action column).
func (*TableW) Edited 实验性
func (t *TableW) Edited() boolEdited reports a committed cell or row edit in the last Show.
func (*TableW) EmptyText
func (t *TableW) EmptyText(s string) *TableWEmptyText sets the empty-state description.
func (*TableW) ExpandChanged
func (t *TableW) ExpandChanged() boolExpandChanged reports an expand or tree toggle in the last Show.
func (*TableW) ExpandRowByClick 实验性
func (t *TableW) ExpandRowByClick() *TableWExpandRowByClick toggles a row's detail panel (Expandable) or tree children when the row is clicked (Ant Design expandable.expandRowByClick).
func (*TableW) Expandable
func (t *TableW) Expandable(render func(row int)) *TableWExpandable adds an expand column; render builds a row's detail panel.
func (*TableW) ExpandedKeys
func (t *TableW) ExpandedKeys(keys *[]string) *TableWExpandedKeys binds the expanded rows (controlled).
func (*TableW) FilterChanged
func (t *TableW) FilterChanged() boolFilterChanged reports a confirmed or reset filter in the last Show.
func (*TableW) Filters
func (t *TableW) Filters(f *map[string][]string) *TableWFilters binds the filter state: column key → selected values.
func (*TableW) Footer 实验性
func (t *TableW) Footer(fn func()) *TableWFooter builds a bar below the table body (Ant Design footer).
func (*TableW) HeaderHeight 实验性
func (t *TableW) HeaderHeight(px float32) *TableWHeaderHeight overrides the height of a header row (Element Plus Table V2 header-height); 0 keeps the height derived from the size.
func (*TableW) HideExpandColumn 实验性
func (t *TableW) HideExpandColumn() *TableWHideExpandColumn hides the expand column of Expandable (Ant Design expandable.showExpandColumn false); rows then expand by ExpandRowByClick, Enter or the bound ExpandedKeys.
func (*TableW) HideHeader 实验性
func (t *TableW) HideHeader() *TableWHideHeader hides the header row (Ant Design / Element Plus showHeader false). Sorting and filters stay bound but have no controls.
func (*TableW) HideSelectAll
func (t *TableW) HideSelectAll() *TableWHideSelectAll hides the header checkbox.
func (*TableW) HighlightCurrentRow
func (t *TableW) HighlightCurrentRow() *TableWHighlightCurrentRow keeps the clicked row highlighted (Element Plus).
func (*TableW) ID
func (t *TableW) ID() IDID returns the table's widget ID (valid after Show).
func (*TableW) Indent 实验性
func (t *TableW) Indent(px float32) *TableWIndent sets the per-level tree indent (default TableToken.IndentSize: 15, Element Plus 16).
func (*TableW) IsEditing 实验性
func (t *TableW) IsEditing(row int) boolIsEditing reports whether row is in row-edit mode.
func (*TableW) Loading
func (t *TableW) Loading(on bool) *TableWLoading shows a translucent mask with a spinner.
func (*TableW) Moved 实验性
func (t *TableW) Moved() boolMoved reports a drag-sort drop in the last Show.
func (*TableW) MultiSort
func (t *TableW) MultiSort(s *[]SortState) *TableWMultiSort binds multi-column sorting (columns with SortMultiple > 0).
func (*TableW) NoHover
func (t *TableW) NoHover() *TableWNoHover disables the row hover highlight.
func (*TableW) PageChanged
func (t *TableW) PageChanged() boolPageChanged reports a page or page-size change in the last Show.
func (*TableW) PageSizes
func (t *TableW) PageSizes(sizes ...int) *TableWPageSizes sets the page-size options of the pager.
func (*TableW) Pagination
func (t *TableW) Pagination(page, pageSize *int) *TableWPagination paginates locally: rows are all data; page is 1-based.
func (*TableW) PaginationConfig 实验性
func (t *TableW) PaginationConfig(fn func(p *PaginationW)) *TableWPaginationConfig customizes the pager after the table set it up (Ant Design's pagination object): fn receives it before Show, e.g. p.ShowTotal().ShowQuickJumper(). Like Ant Design, the table's pager shows no total by default and is small for Small and Middle tables.
func (*TableW) PaginationPlacement 实验性
func (t *TableW) PaginationPlacement(p ...string) *TableWPaginationPlacement places the pager: one top and/or one bottom placement (PageTopStart … PageBottomEnd); PageNone hides it while paging still applies. The default is PageBottomEnd.
func (*TableW) PreserveSelectedRowKeys 实验性
func (t *TableW) PreserveSelectedRowKeys() *TableWPreserveSelectedRowKeys keeps selected keys whose rows are no longer in the data (Ant Design preserveSelectedRowKeys, Element Plus reserve-selection). By default a selection change drops them, so with ServerPagination the selection covers the current page only.
func (*TableW) Resizable 实验性
func (t *TableW) Resizable() *TableWResizable lets the user drag header edges to resize columns.
func (*TableW) Resized 实验性
func (t *TableW) Resized() boolResized reports a column resize in the last Show.
func (*TableW) Revision 实验性
func (t *TableW) Revision(v uint64) *TableWRevision tells the table its data changed, so cached local sorting and filtering is recomputed (bump it whenever rows change in place).
func (*TableW) RowClass 实验性
func (t *TableW) RowClass(fn func(i int) RowStyle) *TableWRowClass styles rows: fn returns the style of data row i (background, status tint, text color, weight). It is the Ant rowClassName / Element row-class-name hook without CSS.
func (*TableW) RowClicked
func (t *TableW) RowClicked() intRowClicked returns the clicked data row or -1.
func (*TableW) RowDoubleClicked
func (t *TableW) RowDoubleClicked() intRowDoubleClicked returns the double-clicked data row or -1.
func (*TableW) RowExpandable
func (t *TableW) RowExpandable(f func(row int) bool) *TableWRowExpandable limits which rows can expand.
func (*TableW) RowHeight
func (t *TableW) RowHeight(h float32) *TableWRowHeight overrides the row height derived from the size.
func (*TableW) RowKey
func (t *TableW) RowKey(f func(int) string) *TableWRowKey gives rows stable keys (selection, expansion, editing).
func (*TableW) Save 实验性
func (t *TableW) Save(row int) boolSave validates the row's editors and commits them; it returns false and shows the errors when a value is invalid.
func (*TableW) ScrollToFirstRowOnChange 实验性
func (t *TableW) ScrollToFirstRowOnChange(on bool) *TableWScrollToFirstRowOnChange sets whether a page, sort or filter change scrolls a bounded body back to the first row (Ant Design scroll.scrollToFirstRowOnChange, default true).
func (*TableW) ScrollX
func (t *TableW) ScrollX(totalW float32) *TableWScrollX sets the scrollable content width (Ant's scroll.x).
func (*TableW) ScrollY
func (t *TableW) ScrollY(maxH float32) *TableWScrollY bounds the body height; the header (and a fixed summary) stay in place and only the visible rows are built, so huge tables stay fast.
func (*TableW) SelectDisabled
func (t *TableW) SelectDisabled(f func(row int) bool) *TableWSelectDisabled disables the selection box of some rows.
func (*TableW) SelectedKeys
func (t *TableW) SelectedKeys(keys *[]string) *TableWSelectedKeys binds the selection to row keys (RowKey). Keys survive paging, sorting and server-side data replacement.
func (*TableW) Selection
func (t *TableW) Selection(sel *[]int) *TableWSelection binds a multi-select column to data indices.
func (*TableW) SelectionChanged
func (t *TableW) SelectionChanged() boolSelectionChanged reports a selection change in the last Show.
func (*TableW) SelectionColumnWidth 实验性
func (t *TableW) SelectionColumnWidth(px float32) *TableWSelectionColumnWidth sets the width of the selection column (Ant Design rowSelection.columnWidth).
func (*TableW) SelectionFixed 实验性
func (t *TableW) SelectionFixed() *TableWSelectionFixed pins the selection column (and the expand column) to the start side (Ant Design rowSelection.fixed). Without it they are pinned when the first data column is.
func (*TableW) Selections 实验性
func (t *TableW) Selections(items ...TableSelection) *TableWSelections adds a menu next to the header checkbox (Ant Design rowSelection.selections). Without items it offers select all, select current page (when paginated), invert current page and clear.
func (*TableW) ServerPagination
func (t *TableW) ServerPagination(page, pageSize *int, total int) *TableWServerPagination shows a pager for server data: rows are the current page's rows and total is the count of all rows.
func (*TableW) Show
func (t *TableW) Show() *TableWShow builds the table.
func (*TableW) ShowOverflowTooltip 实验性
func (t *TableW) ShowOverflowTooltip() *TableWShowOverflowTooltip makes every text column ellipsis with a tooltip (Element Plus' table-level show-overflow-tooltip).
func (*TableW) ShowSorterTooltip 实验性
func (t *TableW) ShowSorterTooltip(on bool) *TableWShowSorterTooltip shows or hides the "click to sort" tooltip of sortable headers (Ant Design showSorterTooltip, default true). A theme whose TableToken.SorterTooltip is false (Element Plus) shows none.
func (*TableW) ShowSummary 实验性
func (t *TableW) ShowSummary() *TableWShowSummary adds Element Plus' default summary row (show-summary): the first data column shows Locale().Table.SumText, columns whose displayed texts are numbers show their sum, others stay empty. Use Summary for a custom summary-method.
func (*TableW) SingleSelect
func (t *TableW) SingleSelect() *TableWSingleSelect turns the selection column into radios.
func (*TableW) Size
func (t *TableW) Size(s ControlSize) *TableWSize picks the density: Large (default), Middle or Small (Element: default, Large, Small).
func (*TableW) Sort
func (t *TableW) Sort(s *SortState) *TableWSort binds single-column sorting (controlled).
func (*TableW) SortChanged
func (t *TableW) SortChanged() boolSortChanged reports a sorter click in the last Show.
func (*TableW) SortDirections 实验性
func (t *TableW) SortDirections(dirs ...SortOrder) *TableWSortDirections sets the orders a sorter click cycles through for every column without its own TableColumn.SortDirections (Ant Design sortDirections, Element Plus sort-orders). The default is SortAsc, SortDesc; after the last order the column returns to unsorted. SortDesc, SortAsc starts with descending; a single order toggles between it and unsorted.
func (*TableW) Span 实验性
func (t *TableW) Span(f func(s TableSpan) (rowSpan, colSpan int)) *TableWSpan merges body cells: return (rowSpan, colSpan); 0 hides a cell that a neighbour covers, (1,1) is a normal cell.
func (*TableW) Sticky 实验性
func (t *TableW) Sticky(offsetTop float32) *TableWSticky pins the header to the top of the scroll container the table scrolls in (the nearest ancestor Scroll, or StickyContainer), offset px below its top edge (Ant Design sticky.offsetHeader).
func (*TableW) StickyContainer 实验性
func (t *TableW) StickyContainer(id ID) *TableWStickyContainer names the scroll container (a ScrollBox ID) Sticky and StickySummary measure against (default: the nearest scrolling ancestor).
func (*TableW) StickySummary 实验性
func (t *TableW) StickySummary(offsetBottom float32) *TableWStickySummary pins the summary rows to the bottom of the scroll container, offset px above its bottom edge, while the table extends below it (Ant Design summary fixed + sticky.offsetSummary).
func (*TableW) Striped
func (t *TableW) Striped() *TableWStriped tints every other row.
func (*TableW) Summary 实验性
func (t *TableW) Summary(fn func(col string, rows []int) string) *TableWSummary adds a summary (totals) row; fn returns the text of each column for the displayed rows. Call it again for more rows.
func (*TableW) SummaryFixed 实验性
func (t *TableW) SummaryFixed() *TableWSummaryFixed keeps the summary visible under a scrolling body.
func (*TableW) Title 实验性
func (t *TableW) Title(fn func()) *TableWTitle builds a bar above the table (Ant Design title).
func (*TableW) Transposed 实验性
func (t *TableW) Transposed() *TableWTransposed swaps the axes for comparing records side by side: every TableColumn becomes a row and every record a column. The data model is unchanged (cols are the fields, rows the record count, callbacks get the record index).
The first column is the header column: it shows each field's Title in header style (Table HeaderBg / HeaderColor / HeaderFontWeight tokens), is a row header for assistive technology and is pinned to the inline start (the right edge in RTL) unless TransposedHeaderFixed(false). Each record column is at least TransposedColumnWidth wide (default 160; record columns share the width of a wider table equally) and shows the field's Text or Render for that record, aligned by the field's Align. The header row shows TransposedHeader's titles; without TransposedHeader there is no header row. Hidden fields are skipped and header groups (Children) are flattened to their leaves.
Transposition turns off, without error, every feature that addresses records as rows or fields as columns: sorting and filtering (Sort, MultiSort, Filters, column Sortable / Filters), row selection (Selection, SelectedKeys, Selections), expandable rows, Tree, Span, DragSort, editing (column Editor, EditableRows), Resizable, ColumnState, Summary, Pagination / ServerPagination, RowClass, HighlightCurrentRow, Sticky / StickySummary and the Wrap of field columns (cells stay one line; Ellipsis still works). The change queries (SortChanged, ...) report false. RowClicked / RowDoubleClicked return the record whose column was clicked (or -1 on the header column) and DisplayedRows lists every record.
ScrollX scrolls many records sideways (the header column stays pinned); ScrollY bounds the body height. Virtual is ignored: there are as many rows as fields (usually few) and record columns are not virtualized.
func (*TableW) TransposedColumnWidth 实验性
func (t *TableW) TransposedColumnWidth(px float32) *TableWTransposedColumnWidth sets the width of every record column of a Transposed table (default 160). It is a minimum: in a wider table the record columns share the free width equally (the header column keeps its width); when they do not fit, the body scrolls sideways.
func (*TableW) TransposedHeader 实验性
func (t *TableW) TransposedHeader(title func(row int) string) *TableWTransposedHeader titles the record columns of a Transposed table: title returns the column title of record row. Without it the transposed table has no header row.
func (*TableW) TransposedHeaderFixed 实验性
func (t *TableW) TransposedHeaderFixed(on bool) *TableWTransposedHeaderFixed pins the header column of a Transposed table to the inline start while the records scroll sideways (default on; the right edge in RTL).
func (*TableW) TransposedHeaderWidth 实验性
func (t *TableW) TransposedHeaderWidth(px float32) *TableWTransposedHeaderWidth sets the width of the header column of a Transposed table (default: the widest field title plus cell padding, at least 80).
func (*TableW) Tree 实验性
func (t *TableW) Tree(roots []int, children func(row int) []int) *TableWTree shows hierarchical data: roots are the top-level row ids and children lists a row's child rows.
func (*TableW) TreeLazy 实验性
func (t *TableW) TreeLazy(has func(row int) bool, load func(row int)) *TableWTreeLazy loads children on demand: has reports rows that have children not loaded yet; load is called once when such a row is expanded (the app fetches, appends children and calls Invalidate). A spinner shows meanwhile.
func (*TableW) TreeOpenKeys 实验性
func (t *TableW) TreeOpenKeys(keys *[]string) *TableWTreeOpenKeys binds the expanded tree nodes (controlled).
func (*TableW) Virtual 实验性
func (t *TableW) Virtual() *TableWVirtual is Table V2 mode: a bounded body (ScrollY) where only visible rows and columns are built. Rows are fixed-height unless a column wraps (Wrap): then visible rows are measured, the rest estimated, and the heights cached. With ScrollY the table always virtualizes; Virtual documents the intent.
TabsLocale
type TabsLocale struct {
More, Add string
// contains filtered or unexported fields
}TabsLocale holds the accessible names of the Tabs overflow and add buttons.
TabsW
type TabsW struct {
// contains filtered or unexported fields
}TabsW is a tab bar: line or card style, editable cards (close and add buttons), top / bottom / left / right placement, centered tabs and a scrolling tab list with a "more" dropdown for the tabs that do not fit.
func Tabs
func Tabs(c *Context, active *string, items []TabItem) *TabsWTabs adds a tab bar bound to the active key; render the panel yourself based on *active (or with Panel). Call Show after options.
ConfigProvider.Defaults("Tabs", ...) keys: "type" ("line" | "card" | "editable-card" | "border-card"), "size" (ControlSize), "centered" (bool), "tabPlacement" (Placement or Ant v6 "top" | "bottom" | "start" | "end"; the deprecated keys "placement" and "tabPosition" take "top" | "bottom" | "left" | "right" too), "stretch" (bool), "tabBarGutter" (px), "variant" ("default" | "line", the shadcn TabsList variant).
active may be nil (the Tabs keep the key themselves). When *active is not a key of items, the tab at the last active index (clamped; the first tab at first) becomes active, like Ant's Tabs when the active key goes away; Changed does not report that fallback.
Under shadcn/ui every combination is drawn as the segmented TabsList (muted track, background pill with shadow-sm): vertical placements stack the triggers, Closable adds a small x to each trigger, OnAdd a ghost + button after the list, Card switches to an outline track and BorderCard puts the list and panel in a bordered card.
func (*TabsW) ActiveTabFontWeight
func (t *TabsW) ActiveTabFontWeight(weight int) *TabsWActiveTabFontWeight sets the active tab label's font weight (100–900). Zero restores the theme weight.
func (*TabsW) AddIcon
func (t *TabsW) AddIcon(ic *icon.Icon) *TabsWAddIcon replaces the + of the add button (Ant addIcon).
func (*TabsW) Added
func (t *TabsW) Added() boolAdded reports a click on the add button this frame.
func (*TabsW) BeforeLeave
func (t *TabsW) BeforeLeave(fn func(newKey, oldKey string) bool) *TabsWBeforeLeave is asked before the active tab changes (Element before-leave): returning false keeps the current tab.
func (*TabsW) BorderCard
func (t *TabsW) BorderCard() *TabsWBorderCard puts the bar and the panel built by Panel in a bordered card whose header strip holds the tabs (Element type="border-card").
func (*TabsW) Card
func (t *TabsW) Card() *TabsWfunc (*TabsW) Centered
func (t *TabsW) Centered() *TabsWCentered centers the tabs in the bar.
func (*TabsW) Changed
func (t *TabsW) Changed() boolfunc (*TabsW) Closable
func (t *TabsW) Closable() *TabsWClosable makes an editable card bar (Ant type="editable-card", Element closable): every tab without NoClose gets a close button; read Closed. Delete or Backspace on a focused tab closes it too.
func (*TabsW) Closed
func (t *TabsW) Closed() stringClosed returns the key of the tab closed this frame ("" when none). The app removes it from the items (and picks a new active key).
func (*TabsW) Draggable
func (t *TabsW) Draggable() *TabsWDraggable lets the user reorder the tabs by dragging them (the moved tab becomes active); read the new order with Reordered. With the keyboard, Shift plus the shortcut modifier (Ctrl, Cmd on macOS) and the arrow keys move the focused tab.
func (*TabsW) Extra
func (t *TabsW) Extra(fn func()) *TabsWfunc (*TabsW) ExtraLeft
func (t *TabsW) ExtraLeft(fn func()) *TabsWExtraLeft builds content at the start of the bar, before the tabs (Ant tabBarExtraContent.left); Extra is the right one.
func (*TabsW) Height
func (t *TabsW) Height(px float32) *TabsWHeight fixes the height of a Left / Right Tabs (bar and panel); tabs that do not fit scroll and are listed in the more menu.
func (*TabsW) Indicator
func (t *TabsW) Indicator(size float32, align string) *TabsWIndicator sets the ink bar of line tabs (Ant v6 indicator): size is its length in px (0: the tab's extent; Element: the label's), align places it along the tab: "start", "center" (default) or "end".
func (*TabsW) IndicatorThickness
func (t *TabsW) IndicatorThickness(px float32) *TabsWIndicatorThickness sets the cross-axis thickness of a line-tab indicator in logical pixels. A non-positive value restores the theme thickness.
func (*TabsW) MoreIcon
func (t *TabsW) MoreIcon(ic *icon.Icon) *TabsWMoreIcon replaces the icon of the more button (Ant more.icon).
func (*TabsW) NoMargin
func (t *TabsW) NoMargin() *TabsWNoMargin drops the gap between the bar and the content (for a bar that sits at the bottom edge of a header, as in PageContainer).
func (*TabsW) OnAdd
func (t *TabsW) OnAdd(fn func()) *TabsWOnAdd shows the add button of an editable card bar; fn runs when it is clicked (Added reports it as well).
func (*TabsW) OnTearOff
func (t *TabsW) OnTearOff(fn func(key string, pos geom.Point)) *TabsWOnTearOff makes the tabs draggable and lets a tab be dragged out of the window: released outside, fn runs with its key and the release point, and TornOff reports them. pos is in the window's logical coordinates, so it lies outside the window's bounds (negative, or past its size); package ui does not know where the window is on the screen, so add the window's position (for a uihost window, tango.Surface.Bounds) to place a new window under the pointer. The bar does not remove the tab: the application opens it in a new window and removes it from the items.
func (*TabsW) Panel
func (t *TabsW) Panel(fn func()) *BoxPanel builds the content of the active tab in a tab panel (exposed to screen readers as the tabpanel labelled by the active tab). Call it after Show; rendering the panel without it works too. With Bottom, Left or Right placement the panel is placed next to the bar.
func (*TabsW) Placement
func (t *TabsW) Placement(p Placement) *TabsWPlacement puts the bar at the Top (default), Bottom, Left or Right of the panel built by Panel. Left and Right are logical: in a right-to-left scope a Left bar sits on the right (the start side), as the layout mirrors the row of bar and panel. This is Ant v6 tabPlacement (TabPlacement takes its string names; Left = "start", Right = "end").
func (*TabsW) RemoveIcon
func (t *TabsW) RemoveIcon(ic *icon.Icon) *TabsWRemoveIcon replaces the x of the close buttons (Ant removeIcon).
func (*TabsW) Reordered
func (t *TabsW) Reordered() []TabItemReordered returns the items in their new order after a drag or keyboard move this frame (nil when none). Assign it to the slice the bar is built from.
func (*TabsW) Show
func (t *TabsW) Show() *TabsWShow builds the tab bar.
func (*TabsW) Size
func (t *TabsW) Size(s ControlSize) *TabsWfunc (*TabsW) Stretch
func (t *TabsW) Stretch() *TabsWStretch makes the tabs of a horizontal bar share its width (Element stretch); the bar no longer scrolls.
func (*TabsW) TabBarGutter
func (t *TabsW) TabBarGutter(px float32) *TabsWTabBarGutter sets the space between two tabs (Ant tabBarGutter; the default comes from the theme: Ant 32 for line tabs, 2 for cards).
func (*TabsW) TabBarStyle
func (t *TabsW) TabBarStyle(opts ...layout.Option) *TabsWTabBarStyle applies layout options to the bar (padding, margin ...; Ant tabBarStyle). They apply after the theme's defaults.
func (*TabsW) TabClicked
func (t *TabsW) TabClicked() stringTabClicked returns the key of the tab clicked this frame, also when it is already active ("" when none; Ant onTabClick, Element tab-click).
func (*TabsW) TabItemHeight
func (t *TabsW) TabItemHeight(px float32) *TabsWTabItemHeight sets the height of horizontal tabs in logical pixels. A non-positive value restores the theme height.
func (*TabsW) TabPlacement
func (t *TabsW) TabPlacement(p string) *TabsWTabPlacement puts the bar by Ant v6 name: "top" (default), "bottom", "start" or "end" (logical sides: mirrored in RTL); "left" and "right" are accepted as their deprecated aliases. Same as Placement.
func (*TabsW) TornOff
func (t *TabsW) TornOff() (key string, pos geom.Point, ok bool)TornOff reports the tab torn off this frame and its release point (see OnTearOff).
func (*TabsW) Variant
func (t *TabsW) Variant(v string) *TabsWVariant picks the list look in every theme: "default" or "line" (line tabs: a transparent list with an underline under the active tab). Where the default bar is a segmented track (TabsToken.SegmentedList: the shadcn TabsList) "line" switches to line tabs; where the default is line tabs already (Ant, Element) it is the same look. Card and BorderCard pick their own types.
TagW
type TagW struct {
// contains filtered or unexported fields
}TagW is a small label.
func Tag
func Tag(c *Context, label string) *TagWTag adds a tag. color may be "success", "processing", "error", "warning", "default", an Ant preset ("blue", "magenta" ...; with the suffix "-inverse", e.g. "blue-inverse", the preset solid unless a Variant is set, like antd), a shadcn Badge variant ("primary", "secondary", "destructive", "outline", "ghost", "link") or a hex color.
ConfigProvider.Defaults("Tag", ...) keys: "size" (ControlSize), "effect", "variant", "color" (string), "bordered" (bool; deprecated, false = variant "filled"), "disabled" (bool).
func (*TagW) Borderless
func (t *TagW) Borderless() *TagWBorderless draws the tag without its border.
Deprecated: use Variant("filled") (antd 6 replaced bordered={false}).
func (*TagW) Closable
func (t *TagW) Closable() *TagWClosable shows a close icon. The tag becomes a "remove" button for the keyboard: Enter, Space, Delete or Backspace close it.
func (*TagW) CloseIcon
func (t *TagW) CloseIcon(ic *icon.Icon) *TagWCloseIcon replaces the close icon (antd closeIcon); it also makes the tag closable.
func (*TagW) Closed
func (t *TagW) Closed() boolClosed reports a click on the close icon (or a keyboard close); always false while disabled.
func (*TagW) Color
func (t *TagW) Color(col string) *TagWfunc (*TagW) Disabled
func (t *TagW) Disabled(on bool) *TagWDisabled greys the tag out (antd 6 disabled); a disabled closable tag does not close. ConfigProvider.ComponentDisabled applies too.
func (*TagW) Effect
func (t *TagW) Effect(e string) *TagWEffect sets the Element theme of the tag: "light" (tinted with a border; = Variant("outlined")), "dark" (solid color, white text; = Variant("solid")) or "plain" (container background, colored border and text). Variant wins when both are set.
func (*TagW) Icon
func (t *TagW) Icon(ic *icon.Icon) *TagWfunc (*TagW) Round
func (t *TagW) Round() *TagWRound draws a pill-shaped tag (Element round).
func (*TagW) Size
func (t *TagW) Size(sz ControlSize) *TagWSize sets small (20px), middle (default) or large (Element 32px) tags.
func (*TagW) Variant
func (t *TagW) Variant(v string) *TagWVariant sets the antd 6 variant: "filled" (tinted, no border; the default outside Element), "solid" (saturated color, light text) or "outlined" (tinted with a border; Element's default light effect).
TextAlign
type TextAlign uint8TextAlign aligns text inside its box. Start and End are logical: they resolve per line, so a right-to-left line (Arabic, Hebrew, or any line of an RTL scope) starts at the right edge.
Append-only: never reorder or insert; the zero value stays AlignStart.
const (
// AlignStart aligns each line to its start edge: left for LTR lines,
// right for RTL lines. It is the zero value.
AlignStart TextAlign = iota
// AlignCenter centers each line.
AlignCenter
// AlignEnd aligns each line to its end edge: right for LTR lines, left
// for RTL lines.
AlignEnd
// AlignPhysicalLeft always aligns to the left edge.
AlignPhysicalLeft
// AlignPhysicalRight always aligns to the right edge.
AlignPhysicalRight
)TextAreaW
type TextAreaW struct {
// contains filtered or unexported fields
}TextAreaW is a multi-line input with character count, auto-size, clear button and wheel scrolling (Ant Input.TextArea, Element type=textarea).
func TextArea
func TextArea(c *Context, val *string) *TextAreaWTextArea adds a multi-line input bound to *val.
func (*TextAreaW) A11yLabel
func (w *TextAreaW) A11yLabel(s string) *TextAreaWA11yLabel sets the accessible name. Inside a FormItem the item label is used; otherwise the placeholder is the last resort.
func (*TextAreaW) AllowClear
func (w *TextAreaW) AllowClear() *TextAreaWfunc (*TextAreaW) AutoSize
func (w *TextAreaW) AutoSize(minRows, maxRows int) *TextAreaWAutoSize grows the box with its content between minRows and maxRows (maxRows <= 0: unbounded); beyond maxRows the content scrolls.
func (*TextAreaW) Changed
func (w *TextAreaW) Changed() boolChanged reports an edit this frame.
func (*TextAreaW) Disabled
func (w *TextAreaW) Disabled(on bool) *TextAreaWfunc (*TextAreaW) Exceed
func (w *TextAreaW) Exceed() *TextAreaWExceed lets the text grow beyond MaxLength and marks it as an error instead of truncating.
func (*TextAreaW) Focused
func (w *TextAreaW) Focused() boolFocused reports keyboard focus.
func (*TextAreaW) ID
func (w *TextAreaW) ID() IDID returns the editor ID.
func (*TextAreaW) Layout
func (w *TextAreaW) Layout(o ...layout.Option) *TextAreaWfunc (*TextAreaW) MaxLength
func (w *TextAreaW) MaxLength(n int) *TextAreaWMaxLength limits the number of characters (see Exceed).
func (*TextAreaW) Placeholder
func (w *TextAreaW) Placeholder(s string) *TextAreaWfunc (*TextAreaW) ReadOnly
func (w *TextAreaW) ReadOnly() *TextAreaWReadOnly prevents edits but allows selection and scrolling (antd / Element readonly).
func (*TextAreaW) Rows
func (w *TextAreaW) Rows(n int) *TextAreaWRows sets the fixed number of visible rows (default 2, like antd's native textarea and Element's rows).
func (*TextAreaW) ShowCount
func (w *TextAreaW) ShowCount() *TextAreaWShowCount shows "count / max".
func (*TextAreaW) Status
func (w *TextAreaW) Status(s string) *TextAreaWfunc (*TextAreaW) Variant
func (w *TextAreaW) Variant(v string) *TextAreaWVariant sets the frame look like InputW.Variant: "outlined" (default), "filled", "borderless" or "underlined" (antd TextArea variant).
func (*TextAreaW) Width
func (w *TextAreaW) Width(px float32) *TextAreaWTextInputStateWindow 实验性
type TextInputStateWindow interface {
SetTextInputState(st input.TextInputState)
}TextInputStateWindow is implemented by windows whose input method can use the text around the caret. SetTextInputState is called after SetTextInput(true, …) whenever the focused field's state changes. When focus moves to a text widget without a state, the Runner turns text input off and on again so the platform forgets the old state.
ThoughtChainW 实验性
type ThoughtChainW struct {
// contains filtered or unexported fields
}ThoughtChainW is a vertical chain of steps with status icons, durations and collapsible details, optionally under a collapsible title.
func ThoughtChain 实验性
func ThoughtChain(c *Context, items []ChainItem) *ThoughtChainWThoughtChain adds a chain of steps.
ui.ThoughtChain(c, steps).Title("思考过程").Card()
func (*ThoughtChainW) Card 实验性
func (w *ThoughtChainW) Card() *ThoughtChainWCard draws the chain inside a bordered card.
func (*ThoughtChainW) DefaultCollapsed 实验性
func (w *ThoughtChainW) DefaultCollapsed() *ThoughtChainWDefaultCollapsed starts with the steps hidden (needs Title).
func (*ThoughtChainW) Expanded 实验性
func (w *ThoughtChainW) Expanded() boolExpanded reports whether the steps are shown.
func (*ThoughtChainW) ItemToggled 实验性
func (w *ThoughtChainW) ItemToggled() (string, bool)ItemToggled returns the key of the step whose detail was opened or closed this frame.
func (*ThoughtChainW) Layout 实验性
func (w *ThoughtChainW) Layout(opts ...layout.Option) *ThoughtChainWLayout applies layout options to the chain.
func (*ThoughtChainW) Title 实验性
func (w *ThoughtChainW) Title(s string) *ThoughtChainWTitle adds a header that collapses the chain and shows its progress.
func (*ThoughtChainW) Toggled 实验性
func (w *ThoughtChainW) Toggled() boolToggled reports a click on the title this frame.
TimePanelW 实验性
type TimePanelW struct {
// contains filtered or unexported fields
}TimePanelW is a standalone set of hour/minute/second columns.
func TimePanel 实验性
func TimePanel(c *Context, val *time.Time) *TimePanelWTimePanel adds hour/minute(/second) scroll columns bound to *val. It is focusable: Up/Down change the active column, Left/Right switch columns.
ConfigProvider.Defaults("TimePicker", ...) keys "format", "use12Hours", "hourStep", "minuteStep", "secondStep" and "hideDisabledOptions" apply.
func (*TimePanelW) A11yLabel 实验性
func (w *TimePanelW) A11yLabel(s string) *TimePanelWA11yLabel sets the accessible name (default: the Locale's SelectTime).
func (*TimePanelW) Changed 实验性
func (w *TimePanelW) Changed() boolChanged reports a new value this frame.
func (*TimePanelW) DisabledHours 实验性
func (w *TimePanelW) DisabledHours(fn func(h int) bool) *TimePanelWDisabledHours marks hours (0-23) that cannot be picked.
func (*TimePanelW) DisabledMinutes 实验性
func (w *TimePanelW) DisabledMinutes(fn func(h, m int) bool) *TimePanelWDisabledMinutes marks minutes of hour h that cannot be picked.
func (*TimePanelW) DisabledSeconds 实验性
func (w *TimePanelW) DisabledSeconds(fn func(h, m, s int) bool) *TimePanelWDisabledSeconds marks seconds of h:m that cannot be picked.
func (*TimePanelW) Format 实验性
func (w *TimePanelW) Format(f string) *TimePanelWFormat sets the Go layout that decides the columns ("15:04" or "15:04:05").
func (*TimePanelW) Height 实验性
func (w *TimePanelW) Height(px float32) *TimePanelWHeight sets the column height.
func (*TimePanelW) HideDisabledOptions 实验性
func (w *TimePanelW) HideDisabledOptions(on bool) *TimePanelWHideDisabledOptions leaves disabled options out of the columns.
func (*TimePanelW) Steps 实验性
func (w *TimePanelW) Steps(h, m, s int) *TimePanelWSteps sets the hour, minute and second steps.
func (*TimePanelW) Use12Hours 实验性
func (w *TimePanelW) Use12Hours() *TimePanelWUse12Hours shows a 12-hour clock with an AM / PM column.
TimePickerLocale
type TimePickerLocale struct {
StartTime, EndTime string // range placeholders
AM, PM string // 12-hour clock words
Meridiem string // accessible name of the AM / PM column
// contains filtered or unexported fields
}TimePickerLocale holds the TimePicker / TimeRangePicker texts.
TimePickerW
type TimePickerW struct {
// contains filtered or unexported fields
}TimePickerW is an input with a dropdown of time columns.
func TimePicker
func TimePicker(c *Context, val *time.Time) *TimePickerWTimePicker adds a time input bound to *val (zero = empty). The date part of a new value is today's date.
ConfigProvider.Defaults("TimePicker", ...) keys: "format", "placeholder", "use12Hours", "hourStep", "minuteStep", "secondStep", "allowClear", "width", "size", "variant", "hideDisabledOptions", "placement", "showNow", "needConfirm".
func (*TimePickerW) A11yLabel
func (w *TimePickerW) A11yLabel(s string) *TimePickerWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*TimePickerW) AllowClear
func (w *TimePickerW) AllowClear(on bool) *TimePickerWAllowClear toggles the clear button (on by default).
func (*TimePickerW) Changed
func (w *TimePickerW) Changed() boolChanged reports a committed value this frame.
func (*TimePickerW) Disabled
func (w *TimePickerW) Disabled(on bool) *TimePickerWDisabled disables the picker.
func (*TimePickerW) DisabledHours
func (w *TimePickerW) DisabledHours(fn func(h int) bool) *TimePickerWDisabledHours marks hours (0-23) that cannot be picked or typed.
func (*TimePickerW) DisabledMinutes
func (w *TimePickerW) DisabledMinutes(fn func(h, m int) bool) *TimePickerWDisabledMinutes marks minutes of hour h that cannot be picked or typed.
func (*TimePickerW) DisabledSeconds
func (w *TimePickerW) DisabledSeconds(fn func(h, m, s int) bool) *TimePickerWDisabledSeconds marks seconds of h:m that cannot be picked or typed.
func (*TimePickerW) Format
func (w *TimePickerW) Format(f string) *TimePickerWFormat sets the Go time layout, e.g. "15:04:05" (default), "15:04" or with Use12Hours "03:04 PM" (AM / PM are shown with the Locale words).
func (*TimePickerW) HideDisabledOptions
func (w *TimePickerW) HideDisabledOptions(on bool) *TimePickerWHideDisabledOptions leaves disabled hours, minutes and seconds out of the columns instead of greying them (Ant hideDisabledOptions).
func (*TimePickerW) HourStep
func (w *TimePickerW) HourStep(n int) *TimePickerWfunc (*TimePickerW) IsOpen
func (w *TimePickerW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*TimePickerW) Layout
func (w *TimePickerW) Layout(o ...layout.Option) *TimePickerWLayout applies layout options to the input frame.
func (*TimePickerW) MinuteStep
func (w *TimePickerW) MinuteStep(n int) *TimePickerWfunc (*TimePickerW) NeedConfirm
func (w *TimePickerW) NeedConfirm(on bool) *TimePickerWNeedConfirm keeps column picks as a draft until OK or Enter (Ant needConfirm; on by default for time pickers). With NeedConfirm(false) every pick in the columns (or arrow key step) sets the value at once, the panel stays open and the OK button is left out.
func (*TimePickerW) Open
func (w *TimePickerW) Open() *TimePickerWOpen forces the dropdown open (screenshots, tests).
func (*TimePickerW) Placeholder
func (w *TimePickerW) Placeholder(s string) *TimePickerWfunc (*TimePickerW) Placement
func (w *TimePickerW) Placement(p Placement) *TimePickerWPlacement sets where the columns open: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement); they flip when there is no room.
func (*TimePickerW) SecondStep
func (w *TimePickerW) SecondStep(n int) *TimePickerWfunc (*TimePickerW) ShowNow
func (w *TimePickerW) ShowNow(on bool) *TimePickerWShowNow toggles the Now link in the footer (Ant showNow, on by default).
func (*TimePickerW) Size
func (w *TimePickerW) Size(s ControlSize) *TimePickerWfunc (*TimePickerW) Status
func (w *TimePickerW) Status(s string) *TimePickerWfunc (*TimePickerW) Steps
func (w *TimePickerW) Steps(h, m, s int) *TimePickerWSteps sets the hour, minute and second steps at once.
func (*TimePickerW) Use12Hours
func (w *TimePickerW) Use12Hours() *TimePickerWUse12Hours shows a 12-hour clock: hours 12, 01 … 11 and an AM / PM column; the default format becomes "03:04:05 PM".
func (*TimePickerW) Variant
func (w *TimePickerW) Variant(v string) *TimePickerWVariant sets the frame look: "outlined" (default), "filled", "borderless" or "underlined".
func (*TimePickerW) Width
func (w *TimePickerW) Width(px float32) *TimePickerWTimeRangePickerW 实验性
type TimeRangePickerW struct {
// contains filtered or unexported fields
}TimeRangePickerW selects a start and an end time.
func TimeRangePicker 实验性
func TimeRangePicker(c *Context, val *[2]time.Time) *TimeRangePickerWTimeRangePicker adds a time range input bound to *val ([start, end], zero = empty). Both ends are edited in side-by-side columns and committed with OK (or Enter); the result is ordered by clock (see Order). Each end can also be typed: printable keys edit the active end, Enter applies valid text (and commits once both ends are set), invalid or disabled text is dropped.
ui.TimeRangePicker(c, &span).Format("15:04").MinuteStep(15)
ConfigProvider.Defaults("TimeRangePicker", ...) keys: "format", "separator", "use12Hours", "hourStep", "minuteStep", "secondStep", "allowClear", "width", "size", "variant", "hideDisabledOptions", "placeholder" ([2]string), "placement", "order".
func (*TimeRangePickerW) A11yLabel 实验性
func (w *TimeRangePickerW) A11yLabel(s string) *TimeRangePickerWA11yLabel sets the accessible name (inside a FormItem the item label is used; otherwise the two placeholders).
func (*TimeRangePickerW) AllowClear 实验性
func (w *TimeRangePickerW) AllowClear(on bool) *TimeRangePickerWfunc (*TimeRangePickerW) Changed 实验性
func (w *TimeRangePickerW) Changed() boolChanged reports a committed range this frame.
func (*TimeRangePickerW) Disabled 实验性
func (w *TimeRangePickerW) Disabled(on bool) *TimeRangePickerWDisabled disables the picker.
func (*TimeRangePickerW) DisabledHours 实验性
func (w *TimeRangePickerW) DisabledHours(fn func(h int) bool) *TimeRangePickerWDisabledHours marks hours (0-23) that cannot be picked.
func (*TimeRangePickerW) DisabledMinutes 实验性
func (w *TimeRangePickerW) DisabledMinutes(fn func(h, m int) bool) *TimeRangePickerWDisabledMinutes marks minutes of hour h that cannot be picked.
func (*TimeRangePickerW) DisabledSeconds 实验性
func (w *TimeRangePickerW) DisabledSeconds(fn func(h, m, s int) bool) *TimeRangePickerWDisabledSeconds marks seconds of h:m that cannot be picked.
func (*TimeRangePickerW) Format 实验性
func (w *TimeRangePickerW) Format(f string) *TimeRangePickerWFormat sets the Go time layout ("15:04:05" default, "15:04", or with Use12Hours "03:04 PM").
func (*TimeRangePickerW) HideDisabledOptions 实验性
func (w *TimeRangePickerW) HideDisabledOptions(on bool) *TimeRangePickerWHideDisabledOptions leaves disabled hours, minutes and seconds out of the columns instead of greying them (Ant hideDisabledOptions).
func (*TimeRangePickerW) HourStep 实验性
func (w *TimeRangePickerW) HourStep(n int) *TimeRangePickerWfunc (*TimeRangePickerW) IsOpen 实验性
func (w *TimeRangePickerW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*TimeRangePickerW) Layout 实验性
func (w *TimeRangePickerW) Layout(o ...layout.Option) *TimeRangePickerWfunc (*TimeRangePickerW) MinuteStep 实验性
func (w *TimeRangePickerW) MinuteStep(n int) *TimeRangePickerWfunc (*TimeRangePickerW) Open 实验性
func (w *TimeRangePickerW) Open() *TimeRangePickerWOpen forces the dropdown open (screenshots, tests).
func (*TimeRangePickerW) Order 实验性
func (w *TimeRangePickerW) Order(on bool) *TimeRangePickerWOrder toggles sorting the two ends by clock (Ant order, on by default). Order(false) keeps an end earlier than the start, e.g. an overnight shift 22:00 – 06:00.
func (*TimeRangePickerW) Placeholder 实验性
func (w *TimeRangePickerW) Placeholder(start, end string) *TimeRangePickerWfunc (*TimeRangePickerW) Placement 实验性
func (w *TimeRangePickerW) Placement(p Placement) *TimeRangePickerWPlacement sets where the columns open: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement); they flip when there is no room.
func (*TimeRangePickerW) SecondStep 实验性
func (w *TimeRangePickerW) SecondStep(n int) *TimeRangePickerWfunc (*TimeRangePickerW) Separator 实验性
func (w *TimeRangePickerW) Separator(s string) *TimeRangePickerWSeparator sets the text between the two ends (Ant separator, Element range-separator; default the Locale's RangeSeparator).
func (*TimeRangePickerW) Size 实验性
func (w *TimeRangePickerW) Size(s ControlSize) *TimeRangePickerWfunc (*TimeRangePickerW) Status 实验性
func (w *TimeRangePickerW) Status(s string) *TimeRangePickerWfunc (*TimeRangePickerW) Use12Hours 实验性
func (w *TimeRangePickerW) Use12Hours() *TimeRangePickerWUse12Hours shows 12-hour columns with AM / PM.
func (*TimeRangePickerW) Variant 实验性
func (w *TimeRangePickerW) Variant(v string) *TimeRangePickerWVariant sets the frame look: "outlined" (default), "filled", "borderless" or "underlined".
func (*TimeRangePickerW) Width 实验性
func (w *TimeRangePickerW) Width(px float32) *TimeRangePickerWTimeSelectW 实验性
type TimeSelectW struct {
// contains filtered or unexported fields
}TimeSelectW picks a "HH:MM" time from a fixed list generated by Start/End/Step.
func TimeSelect 实验性
func TimeSelect(c *Context, val *string) *TimeSelectWTimeSelect adds a time select bound to *val ("HH:MM", "" = empty). Defaults follow Element: 09:00–18:00 every 00:30.
ConfigProvider.Defaults("TimeSelect", ...) keys: "start", "end", "step", "placeholder", "clearable" (Element) / "allowClear", "size", "width", "variant".
func (*TimeSelectW) A11yLabel 实验性
func (w *TimeSelectW) A11yLabel(s string) *TimeSelectWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*TimeSelectW) Changed 实验性
func (w *TimeSelectW) Changed() boolChanged reports a new value this frame.
func (*TimeSelectW) Clearable 实验性
func (w *TimeSelectW) Clearable(on bool) *TimeSelectWClearable shows the clear icon on hover (default on).
func (*TimeSelectW) Disabled 实验性
func (w *TimeSelectW) Disabled(on bool) *TimeSelectWfunc (*TimeSelectW) End 实验性
func (w *TimeSelectW) End(s string) *TimeSelectWfunc (*TimeSelectW) IncludeEndTime 实验性
func (w *TimeSelectW) IncludeEndTime(on bool) *TimeSelectWIncludeEndTime adds End as the last option when the steps skip it, e.g. 09:00–17:45 every 00:30 ends with 17:45 (Element include-end-time).
func (*TimeSelectW) IsOpen 实验性
func (w *TimeSelectW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*TimeSelectW) Layout 实验性
func (w *TimeSelectW) Layout(o ...layout.Option) *TimeSelectWfunc (*TimeSelectW) MaxTime 实验性
func (w *TimeSelectW) MaxTime(s string) *TimeSelectWfunc (*TimeSelectW) MinTime 实验性
func (w *TimeSelectW) MinTime(s string) *TimeSelectWMinTime disables times at or before s; MaxTime disables times at or after s (Element semantics).
func (*TimeSelectW) Open 实验性
func (w *TimeSelectW) Open() *TimeSelectWOpen forces the dropdown open (screenshots, tests).
func (*TimeSelectW) Options 实验性
func (w *TimeSelectW) Options() []OptionOptions returns the generated items (Disabled marks MinTime/MaxTime).
func (*TimeSelectW) Placeholder 实验性
func (w *TimeSelectW) Placeholder(s string) *TimeSelectWfunc (*TimeSelectW) Placement 实验性
func (w *TimeSelectW) Placement(p Placement) *TimeSelectWPlacement sets where the list opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Element placement); it flips when there is no room.
func (*TimeSelectW) Size 实验性
func (w *TimeSelectW) Size(s ControlSize) *TimeSelectWfunc (*TimeSelectW) Start 实验性
func (w *TimeSelectW) Start(s string) *TimeSelectWStart / End / Step set the generated range ("HH:MM"; End is inclusive).
func (*TimeSelectW) Status 实验性
func (w *TimeSelectW) Status(s string) *TimeSelectWfunc (*TimeSelectW) Step 实验性
func (w *TimeSelectW) Step(s string) *TimeSelectWfunc (*TimeSelectW) Variant 实验性
func (w *TimeSelectW) Variant(v string) *TimeSelectWVariant sets the frame look: "outlined" (default), "filled", "borderless" or "underlined".
func (*TimeSelectW) Width 实验性
func (w *TimeSelectW) Width(px float32) *TimeSelectWTimelineItem 实验性
type TimelineItem struct {
Content string // main text (Ant v6 content)
Body func() // custom content (replaces Content)
// Title is the text on the opposite side of the axis (Ant v6 title);
// any item with a Title centers the axis of a vertical timeline.
Title string
// Deprecated: use Title.
Label string
Time string // Element: timestamp under (or above) the content
TimeTop bool // put Time above the content
// Color is a status ("primary", "success", "warning", "error", "info",
// "gray") or a hex color; empty uses the theme default.
Color string
DotIcon *icon.Icon // icon instead of the circle
Dot func() // fully custom dot node
Hollow bool // Element: hollow dot
Large bool // Element: larger dot
// Placement puts this item's content at the "start" or "end" side,
// overriding the Mode (Ant v6 items[].placement).
Placement string
// Loading shows a spinning dot (Ant v6 items[].loading); the axis
// entering it (leaving it under Reverse) is dotted where the theme's
// TimelineToken.BusyTailDashed says so.
Loading bool
// Center centers the dot vertically on the item (Element center).
Center bool
}TimelineItem is one event of a Timeline.
TimelineW 实验性
type TimelineW struct {
// contains filtered or unexported fields
}TimelineW shows events along a vertical axis.
func Timeline 实验性
func Timeline(c *Context, items []TimelineItem) *TimelineWTimeline starts a timeline; finish with Show.
ConfigProvider.Defaults("Timeline", ...) keys: "mode" ("start" | "end" | "alternate" | "alternate-reverse"; "left" / "right" are the deprecated names of start / end), "reverse" (bool), "orientation" ("vertical" | "horizontal"), "variant" ("outlined" | "filled").
func (*TimelineW) Horizontal 实验性
func (w *TimelineW) Horizontal() *TimelineWHorizontal lays the events out along a horizontal axis (Ant v6 orientation="horizontal"): every event takes an equal share of the width with its dot on the axis. Mode keeps its meaning with the axis turned: "left" / "start" puts the content under the axis, "right" / "end" above it, "alternate" alternates (first under); a Label goes to the opposite side. In RTL the events run from the right.
func (*TimelineW) Layout 实验性
func (w *TimelineW) Layout(o ...layout.Option) *TimelineWLayout applies layout options to the timeline (call after Show).
func (*TimelineW) Mode 实验性
func (w *TimelineW) Mode(m string) *TimelineWMode places the content: "start" (axis at the inline start, content after it; default), "end" (axis at the inline end), "alternate" (content alternates around a centered axis, the first item after it) or "alternate-reverse" (Element: the first item before it). "left" and "right" are the deprecated Ant names of "start" and "end". Items with a Title also center the axis. The sides are logical: in RTL "start" puts the axis at the right.
func (*TimelineW) Orientation 实验性
func (w *TimelineW) Orientation(o string) *TimelineWOrientation lays the events out "vertical" (default) or "horizontal" (Ant v6 orientation; same as Horizontal).
func (*TimelineW) Pending 实验性
func (w *TimelineW) Pending(label string) *TimelineWPending appends a "still in progress" item with a spinning dot.
func (*TimelineW) Reverse 实验性
func (w *TimelineW) Reverse() *TimelineWReverse lists the items in reverse order.
func (*TimelineW) Show 实验性
func (w *TimelineW) Show() *TimelineWShow builds the timeline.
func (*TimelineW) TitleSpan 实验性
func (w *TimelineW) TitleSpan(span float32) *TimelineWTitleSpan sets the share of the width, in 24ths, taken by the titles of a vertical timeline whose items have a Title (Ant titleSpan; default 12, the axis in the middle). Ignored with Mode("alternate").
func (*TimelineW) Variant 实验性
func (w *TimelineW) Variant(v string) *TimelineWVariant sets the dots: "outlined" (a ring, Ant's default) or "filled" (a solid dot, the Element and shadcn default). Empty keeps the theme's (TimelineToken.DotOutlined).
TimerType 实验性
type TimerType stringTimerType selects the direction of a StatisticTimer.
const (
// TimerCountdown counts down to the given deadline (as Countdown).
TimerCountdown TimerType = "countdown"
// TimerCountup counts up from the given start time.
TimerCountup TimerType = "countup"
)实验性
TitleBarLocale 实验性
type TitleBarLocale struct {
Minimize, Maximize, Restore string
WindowControls string // accessible name of the button group
// contains filtered or unexported fields
}TitleBarLocale holds the window button names of TitleBar and WindowControls (Close is Locale.Close, the full-screen pair Locale.Fullscreen / Locale.ExitFullscreen).
TitleBarW 实验性
type TitleBarW struct {
// contains filtered or unexported fields
}TitleBarW is the self-drawn title bar TitleBar returns.
func TitleBar 实验性
func TitleBar(c *Context) *TitleBarWTitleBar adds the title bar of a frameless window (SurfaceOptions Appearance.TitleBar = TitleBarNone, or TitleBarHidden on macOS):
ui.TitleBar(c).Icon(icon.Code).Title("Tango — main.go").
Menu(func() { ui.Menubar(c, menus) }).
Center(func() { ui.Search(c, &q) }).
Tools(func() { ui.IconButton(c, icon.Setting, "设置") })
Pressing the bar's empty parts moves the window and a double click maximizes or restores it; the window buttons follow the platform (see WindowControlsStyle). Everything acts on Context.Window when it implements WindowFrame (uihost windows do); without a frame the bar still draws and reports Action.
func (*TitleBarW) Action 实验性
func (t *TitleBarW) Action() WindowActionAction reports the window action the user asked for this frame (a window button, or a double click on the bar), "" for none. A host that handles double clicks on the bar itself (uihost windows with their own UI thread) has already performed the action when Action reports it, one frame later.
func (*TitleBarW) Center 实验性
func (t *TitleBarW) Center(fn func()) *TitleBarWCenter builds content in the middle of the bar (a command search box). Without it the title is centered on macOS and follows the menu elsewhere.
func (*TitleBarW) Controls 实验性
func (t *TitleBarW) Controls(s WindowControlsStyle) *TitleBarWControls picks the window button style (WindowControlsAuto by default).
func (*TitleBarW) Frame 实验性
func (t *TitleBarW) Frame(f WindowFrame) *TitleBarWFrame sets the window the bar drives, in place of Context.Window.
func (*TitleBarW) ID 实验性
func (t *TitleBarW) ID() IDID returns the bar's ID.
func (*TitleBarW) Icon 实验性
func (t *TitleBarW) Icon(ic *icon.Icon) *TitleBarWIcon shows the app icon at the bar's start.
func (*TitleBarW) Layout 实验性
func (t *TitleBarW) Layout(o ...layout.Option) *TitleBarWLayout adds layout options to the bar.
func (*TitleBarW) Manual 实验性
func (t *TitleBarW) Manual() *TitleBarWManual only reports window actions (Action) and leaves the window alone; dragging still moves it.
func (*TitleBarW) Menu 实验性
func (t *TitleBarW) Menu(fn func()) *TitleBarWMenu builds content after the icon (a Menubar, a project switcher).
func (*TitleBarW) Title 实验性
func (t *TitleBarW) Title(s string) *TitleBarWTitle sets the window title shown in the bar.
func (*TitleBarW) Tools 实验性
func (t *TitleBarW) Tools(fn func()) *TitleBarWTools builds content before the window buttons (layout toggles, notifications, the account menu).
ToggleGroupW 实验性
type ToggleGroupW struct {
// contains filtered or unexported fields
}ToggleGroupW is a set of toggles (shadcn/ui ToggleGroup).
func ToggleGroup 实验性
func ToggleGroup(c *Context, selected *[]string, opts []Option) *ToggleGroupWToggleGroup adds one toggle per option bound to the selected values (multiple selection; Single keeps at most one). The toggles touch, with only the outer corners rounded, unless Spacing separates them.
ConfigProvider.Defaults("ToggleGroup", ...) keys: "size", "variant" ("default" | "outline"), "spacing" (int).
func (*ToggleGroupW) A11yLabel 实验性
func (g *ToggleGroupW) A11yLabel(s string) *ToggleGroupWA11yLabel sets the accessible name of the group.
func (*ToggleGroupW) Changed 实验性
func (g *ToggleGroupW) Changed() boolChanged reports a selection change this frame.
func (*ToggleGroupW) Icons 实验性
func (g *ToggleGroupW) Icons(m map[string]*icon.Icon) *ToggleGroupWIcons draws icon-only toggles; the option labels stay their names.
func (*ToggleGroupW) Outline 实验性
func (g *ToggleGroupW) Outline() *ToggleGroupWOutline joins the toggles into one bordered strip.
func (*ToggleGroupW) Single 实验性
func (g *ToggleGroupW) Single() *ToggleGroupWSingle makes the group behave like radio buttons that can be cleared.
func (*ToggleGroupW) Size 实验性
func (g *ToggleGroupW) Size(s ControlSize) *ToggleGroupWSize sets the size of every toggle.
func (*ToggleGroupW) Spacing 实验性
func (g *ToggleGroupW) Spacing(n int) *ToggleGroupWSpacing sets the gap between the toggles in Tailwind spacing units of 4px (shadcn toggle-group spacing, default 0). With 0 the toggles touch and only the group's outer corners are rounded; otherwise every toggle is rounded (and bordered when outlined) on its own. Negative values are treated as 0.
func (*ToggleGroupW) Variant 实验性
func (g *ToggleGroupW) Variant(v string) *ToggleGroupWVariant sets the variant of every toggle: "default" or "outline". Other values are ignored.
ToggleW 实验性
type ToggleW struct {
// contains filtered or unexported fields
}ToggleW is a two-state button (shadcn/ui Toggle): transparent when off, accent-filled when on.
func Toggle 实验性
func Toggle(c *Context, label string, on *bool) *ToggleWToggle adds a toggle button bound to *on. label may be "" for an icon-only toggle (it still names the control for tests).
func (*ToggleW) A11yLabel 实验性
func (w *ToggleW) A11yLabel(s string) *ToggleWA11yLabel sets the accessible name (icon-only toggles built with an empty label).
func (*ToggleW) Changed 实验性
func (w *ToggleW) Changed() boolChanged reports a flip this frame.
func (*ToggleW) Disabled 实验性
func (w *ToggleW) Disabled(on bool) *ToggleWDisabled disables the toggle when on.
func (*ToggleW) ID 实验性
func (w *ToggleW) ID() IDID returns the widget ID.
func (*ToggleW) Icon 实验性
func (w *ToggleW) Icon(ic *icon.Icon) *ToggleWIcon puts an icon before the label (or alone when the label is shown only to tests: use IconOnly).
func (*ToggleW) IconOnly 实验性
func (w *ToggleW) IconOnly(ic *icon.Icon) *ToggleWIconOnly draws just the icon; the label stays the accessible name.
func (*ToggleW) Outline 实验性
func (w *ToggleW) Outline() *ToggleWOutline adds the input border and shadow (shadcn variant="outline").
func (*ToggleW) Size 实验性
func (w *ToggleW) Size(s ControlSize) *ToggleWSize sets the control size.
func (*ToggleW) Variant 实验性
func (w *ToggleW) Variant(v string) *ToggleWVariant sets the shadcn variant: "default" (transparent) or "outline". Other values are ignored.
ToolCallW 实验性
type ToolCallW struct {
// contains filtered or unexported fields
}ToolCallW is a collapsible card for one tool invocation: name, summary, status and duration in the header; arguments and result in the body.
func ToolCall 实验性
func ToolCall(c *Context, name string) *ToolCallWToolCall adds a tool call card for tool name.
ui.ToolCall(c, "read_file").Summary("src/main.go").Status(ui.ChainSuccess).
Duration(320*time.Millisecond).Args(`{"path":"src/main.go"}`).Result(out)
func (*ToolCallW) Args 实验性
func (w *ToolCallW) Args(s string) *ToolCallWArgs sets the arguments shown in the body (JSON by default, see Lang).
func (*ToolCallW) Body 实验性
func (w *ToolCallW) Body(fn func()) *ToolCallWBody adds custom content at the end of the expanded body (a diff, an image, an Approval).
func (*ToolCallW) DefaultOpen 实验性
func (w *ToolCallW) DefaultOpen() *ToolCallWDefaultOpen starts expanded.
func (*ToolCallW) Duration 实验性
func (w *ToolCallW) Duration(d time.Duration) *ToolCallWDuration shows how long the call took.
func (*ToolCallW) Icon 实验性
func (w *ToolCallW) Icon(ic *icon.Icon) *ToolCallWIcon replaces the tool icon.
func (*ToolCallW) Lang 实验性
func (w *ToolCallW) Lang(args, result string) *ToolCallWLang sets the code languages of the arguments and the result (default "json" and none).
func (*ToolCallW) Layout 实验性
func (w *ToolCallW) Layout(opts ...layout.Option) *ToolCallWLayout applies layout options to the card.
func (*ToolCallW) Open 实验性
func (w *ToolCallW) Open() boolOpen reports whether the body is shown.
func (*ToolCallW) Result 实验性
func (w *ToolCallW) Result(s string) *ToolCallWResult sets the output shown in the body.
func (*ToolCallW) Started 实验性
func (w *ToolCallW) Started(t time.Time) *ToolCallWStarted shows the live elapsed time while the call is running.
func (*ToolCallW) Status 实验性
func (w *ToolCallW) Status(s ChainStatus) *ToolCallWStatus sets the call's state (default ChainPending).
func (*ToolCallW) Summary 实验性
func (w *ToolCallW) Summary(s string) *ToolCallWSummary shows a short description after the name (a path, a query).
func (*ToolCallW) Toggled 实验性
func (w *ToolCallW) Toggled() boolToggled reports a click on the header this frame.
TooltipW
type TooltipW struct {
*Box
// contains filtered or unexported fields
}TooltipW is a tooltip wrapped around trigger content. It embeds the anchor *Box, so code that used the box Tooltip returned keeps working. Options apply when the build finishes (or at IsOpen).
ConfigProvider.Defaults("Tooltip", ...) keys: "placement", "trigger", "color", "effect" (string), "arrow" (bool), "mouseEnterDelay", "mouseLeaveDelay" (time.Duration).
func Tooltip
func Tooltip(c *Context, tip string, fn func()) *TooltipWTooltip wraps fn's content and shows tip above it while hovered (or while keyboard focus is inside). The hover delays default to the theme (antd 0.1 s / 0.1 s, Element 0 / 0.2 s, shadcn 0 / 0).
func (*TooltipW) Arrow
func (t *TooltipW) Arrow(on bool) *TooltipWArrow shows or hides the arrow (default on).
func (*TooltipW) Color
func (t *TooltipW) Color(s string) *TooltipWColor sets the bubble color: a status ("success", "error" ...), an Ant preset name ("blue", "magenta" ...) or "#rrggbb".
func (*TooltipW) Content
func (t *TooltipW) Content(fn func()) *TooltipWContent replaces the text with rich content built by fn (the tip text still describes the trigger to screen readers).
func (*TooltipW) Disabled
func (t *TooltipW) Disabled(on bool) *TooltipWDisabled stops the tooltip from showing (Element disabled).
func (*TooltipW) Effect
func (t *TooltipW) Effect(s string) *TooltipWEffect "light" draws a light bubble with a border (Element effect); "dark" is the default.
func (*TooltipW) IsOpen
func (t *TooltipW) IsOpen() boolIsOpen reports whether the tooltip is shown this frame.
func (*TooltipW) MouseEnterDelay
func (t *TooltipW) MouseEnterDelay(d time.Duration) *TooltipWMouseEnterDelay waits d before showing on hover (Element show-after; default: the theme's TooltipToken.MouseEnterDelay).
func (*TooltipW) MouseLeaveDelay
func (t *TooltipW) MouseLeaveDelay(d time.Duration) *TooltipWMouseLeaveDelay keeps the tooltip for d after the pointer left (Element hide-after; default: TooltipToken.MouseLeaveDelay).
func (*TooltipW) Open
func (t *TooltipW) Open(v *bool) *TooltipWOpen binds the open state (antd open / onOpenChange): *v decides whether the tooltip shows, and the trigger writes its wish (hover, focus, click) into *v when it changes. OpenChanged reports such a write.
func (*TooltipW) OpenChanged
func (t *TooltipW) OpenChanged() boolOpenChanged reports that the trigger changed the Open state this frame.
func (*TooltipW) Placement
func (t *TooltipW) Placement(s string) *TooltipWPlacement: top (default), topLeft, topRight, bottom, bottomLeft, bottomRight, left, leftTop, leftBottom, right, rightTop, rightBottom. Left and right are logical (start / end): mirrored in RTL.
func (*TooltipW) Trigger
func (t *TooltipW) Trigger(s string) *TooltipWTrigger: "hover" (default; keyboard focus shows it too), "click" or "focus".
TopNavHeaderW 实验性
type TopNavHeaderW struct {
// contains filtered or unexported fields
}TopNavHeaderW exposes ProLayout's horizontal header as a reusable entry. The desktop top menu is always expanded; overflow is handled by Menu, not by an additional sidebar collapse button (matching Pro v3).
func TopNavHeader 实验性
func TopNavHeader(c *Context, menu []MenuItem, selected *string) *TopNavHeaderWTopNavHeader starts a top navigation header; chain options, then Show. ConfigProvider.Defaults("TopNavHeader", ...): "title", "contentWidth", "userName" (string). Navigation selection is owned by selected.
func (*TopNavHeaderW) Actions 实验性
func (w *TopNavHeaderW) Actions(fn func()) *TopNavHeaderWActions builds the trailing actions before the avatar.
func (*TopNavHeaderW) ContentWidth 实验性
func (w *TopNavHeaderW) ContentWidth(s string) *TopNavHeaderWContentWidth selects Fluid or Fixed (1152px, centred).
func (*TopNavHeaderW) Logo 实验性
func (w *TopNavHeaderW) Logo(ic *icon.Icon) *TopNavHeaderWLogo replaces the default logo mark.
func (*TopNavHeaderW) OnMenuHeaderClick 实验性
func (w *TopNavHeaderW) OnMenuHeaderClick(fn func()) *TopNavHeaderWOnMenuHeaderClick makes the logo/title area a keyboard-accessible button.
func (*TopNavHeaderW) Show 实验性
func (w *TopNavHeaderW) Show() *TopNavHeaderWShow builds the header using ProLayout's existing header implementation.
func (*TopNavHeaderW) Title 实验性
func (w *TopNavHeaderW) Title(s string) *TopNavHeaderWTitle sets the logo area's title.
func (*TopNavHeaderW) UserName 实验性
func (w *TopNavHeaderW) UserName(s string) *TopNavHeaderWUserName adds the user avatar and name in the trailing action area.
TourActions 实验性
type TourActions struct {
Current int // 0-based index of the shown step
Total int
// contains filtered or unexported fields
}TourActions is what an ActionsRender function gets: the step position and the operations of the default buttons.
func (*TourActions) Close 实验性
func (a *TourActions) Close()Close dismisses the tour (Closed reports it).
func (*TourActions) Default 实验性
func (a *TourActions) Default()Default builds the default buttons (previous, next / finish) in place.
func (*TourActions) GoTo 实验性
func (a *TourActions) GoTo(i int)GoTo moves to step i (clamped).
func (*TourActions) Next 实验性
func (a *TourActions) Next()Next moves to the next step, or finishes the tour on the last one.
func (*TourActions) Prev 实验性
func (a *TourActions) Prev()Prev moves to the previous step.
TourLocale 实验性
type TourLocale struct {
Close, Prev, Next, Finish string
// contains filtered or unexported fields
}TourLocale holds the Tour buttons.
TourMask 实验性
type TourMask uint8TourMask overrides the tour's mask for one step.
const (
TourMaskInherit TourMask = iota // the tour's setting (NoMask)
TourMaskOn // dim the page around the target
TourMaskOff // no mask on this step
)实验性
TourStep 实验性
type TourStep struct {
Target ID // widget to highlight (0: centred panel, no hole)
Title string
Description string
Cover func() // optional picture above the title
Placement string // as Popover.Placement; default "bottom"
// Per-step overrides of the tour's options.
Mask TourMask // TourMaskOn / TourMaskOff; zero: the tour's setting
Type TourType // TourTypeDefault / TourTypePrimary; "": the tour's setting
PrevText string // label of the previous button ("": Locale)
NextText string // label of the next / finish button ("": Locale)
HidePrev bool // no previous button on this step
HideNext bool // no next / finish button on this step
// HideArrow hides the panel arrow on this step (antd steps[].arrow
// false).
HideArrow bool
}TourStep is one step of a Tour.
TourType 实验性
type TourType stringTourType is the panel style of a tour step.
const (
TourTypeDefault TourType = "default" // the container-colored panel
TourTypePrimary TourType = "primary" // the brand-colored panel
)实验性
TourW 实验性
type TourW struct {
// contains filtered or unexported fields
}TourW is a guided tour: a mask with a hole around the current target and a panel with step indicators and prev/next buttons.
func Tour 实验性
func Tour(c *Context, open *bool, current *int, steps []TourStep) *TourWTour starts a tour bound to *open and *current; call Show.
func (*TourW) ActionsRender 实验性
func (t *TourW) ActionsRender(fn func(a *TourActions)) *TourWActionsRender replaces the previous / next buttons with the content fn builds (Ant actionsRender); a.Default() builds the default buttons and a.Prev / Next / GoTo / Close drive the tour.
func (*TourW) Changed 实验性
func (t *TourW) Changed() boolChanged reports a step change.
func (*TourW) Closable 实验性
func (t *TourW) Closable(on bool) *TourWClosable shows or hides the close button; without it Escape does not close the tour either (antd closable null; default shown).
func (*TourW) Closed 实验性
func (t *TourW) Closed() boolClosed reports the tour was dismissed (close button or Escape).
func (*TourW) DisabledInteraction 实验性
func (t *TourW) DisabledInteraction(on bool) *TourWDisabledInteraction keeps the highlighted target from being clicked (antd disabledInteraction; by default the target stays interactive, Element target-area-clickable).
func (*TourW) Finished 实验性
func (t *TourW) Finished() boolFinished reports a click on the last step's finish button.
func (*TourW) Gap 实验性
func (t *TourW) Gap(px float32) *TourWGap sets the hole padding around the target (antd / Element gap.offset, default 6).
func (*TourW) GapRadius 实验性
func (t *TourW) GapRadius(px float32) *TourWGapRadius sets the corner radius of the hole around the target (antd / Element gap.radius, default 2).
func (*TourW) IndicatorsRender 实验性
func (t *TourW) IndicatorsRender(fn func(current, total int)) *TourWIndicatorsRender replaces the step indicators (dots; Element: "1 / 3") with the content fn builds (Ant indicatorsRender). current is 0-based.
func (*TourW) Keyboard 实验性
func (t *TourW) Keyboard(on bool) *TourWKeyboard sets whether Escape closes the tour and ←/→ move between steps (default true; antd keyboard, Element close-on-press-escape).
func (*TourW) MaskColor 实验性
func (t *TourW) MaskColor(col theme.Color) *TourWMaskColor sets the mask color (antd mask.color; default the theme's). A transparent color keeps the mask's pointer blocking without dimming.
func (*TourW) NoArrow 实验性
func (t *TourW) NoArrow() *TourWNoArrow hides the panel arrow.
func (*TourW) NoMask 实验性
func (t *TourW) NoMask() *TourWNoMask hides the dimming mask.
func (*TourW) Placement 实验性
func (t *TourW) Placement(s string) *TourWPlacement sets the default panel placement of the steps, as Popover.Placement (default "bottom"); TourStep.Placement overrides it.
func (*TourW) Primary 实验性
func (t *TourW) Primary() *TourWPrimary uses the brand-coloured panel.
func (*TourW) ScrollIntoView 实验性
func (t *TourW) ScrollIntoView(on bool) *TourWScrollIntoView sets whether each step scrolls its target into the view of the scroll container holding it when the step is shown (default on, Ant scrollIntoViewOptions).
func (*TourW) Show 实验性
func (t *TourW) Show() *TourWShow builds the tour layers when open.
TransferItem 实验性
type TransferItem struct {
Key, Title string
Disabled bool
// contains filtered or unexported fields
}TransferItem is an entry of a Transfer.
TransferLocale 实验性
type TransferLocale struct {
Source, Target, SearchPlaceholder string
// contains filtered or unexported fields
}TransferLocale holds the Transfer defaults.
TransferW 实验性
type TransferW struct {
// contains filtered or unexported fields
}TransferW is a two-list shuttle: items move between the source (left) and the target (right) list.
func Transfer 实验性
func Transfer(c *Context, items []TransferItem, target *[]string) *TransferWTransfer adds a transfer bound to the keys of the right-hand list.
func (*TransferW) Actions 实验性
func (w *TransferW) Actions(toRight, toLeft string) *TransferWActions labels the move buttons (Ant 6 actions, Element button-texts; default: icons only).
func (*TransferW) Changed 实验性
func (w *TransferW) Changed() boolChanged reports items moved this frame.
func (*TransferW) Checked 实验性
func (w *TransferW) Checked(side int) []stringChecked returns the checked keys of a side (0 left, 1 right).
func (*TransferW) DefaultChecked 实验性
func (w *TransferW) DefaultChecked(keys ...string) *TransferWDefaultChecked checks keys when the widget is first shown.
func (*TransferW) Disabled 实验性
func (w *TransferW) Disabled(on bool) *TransferWDisabled disables the whole transfer.
func (*TransferW) ListSize 实验性
func (w *TransferW) ListSize(wd, ht float32) *TransferWListSize sets the size of each list box.
func (*TransferW) OneWay 实验性
func (w *TransferW) OneWay() *TransferWOneWay makes the transfer one-directional (Ant oneWay): only the move to the right remains, and right-hand items have a remove button.
func (*TransferW) Operations 实验性
func (w *TransferW) Operations(toRight, toLeft string) *TransferWOperations labels the move buttons.
Deprecated: use Actions (Ant 6 renamed operations to actions).
func (*TransferW) Pagination 实验性
func (w *TransferW) Pagination(pageSize int) *TransferWPagination shows pageSize items per page with a pager under each list (Ant pagination).
func (*TransferW) Render 实验性
func (w *TransferW) Render(fn func(o Option)) *TransferWRender builds each row's content with fn instead of the title (the row background and checkbox stay). The option carries the item's Title as Label, Key as Value and Disabled.
ui.Transfer(c, items, &keys).Render(func(o ui.Option) {
ui.Row(c, func() { ui.Icon(c, icon.User); ui.Text(c, o.Label) }, layout.Gap(6))
})
func (*TransferW) Searchable 实验性
func (w *TransferW) Searchable() *TransferWSearchable adds a filter input to each list.
func (*TransferW) ShowSelectAll 实验性
func (w *TransferW) ShowSelectAll(on bool) *TransferWShowSelectAll shows or hides the select-all checkbox in the list headers (Ant showSelectAll, default true).
func (*TransferW) Status 实验性
func (w *TransferW) Status(s string) *TransferWStatus sets the validation status ("error", "warning").
func (*TransferW) TargetOrder 实验性
func (w *TransferW) TargetOrder(s string) *TransferWTargetOrder sets where moved keys go in the bound target slice and the order of the right list (Element target-order): "unshift" (default, as Ant: new keys first, the list follows the slice), "push" (new keys last, the list follows the slice) or "original" (the slice and the list follow the item order). ConfigProvider.Defaults("Transfer", "targetOrder") sets it for a subtree.
func (*TransferW) Titles 实验性
func (w *TransferW) Titles(left, right string) *TransferWTitles sets the list titles.
func (*TransferW) TreeSource 实验性
func (w *TransferW) TreeSource(nodes []TreeNode) *TransferWTreeSource shows nodes as a checkable tree on the left (Ant tree transfer). Leaves are the transferable items (their Key / Title); leaves already on the right are shown checked and disabled. The items passed to Transfer are ignored.
func (*TransferW) Virtual 实验性
func (w *TransferW) Virtual(on bool) *TransferWVirtual forces virtual lists on or off (default: more than 100 items on a page).
TreeNode
type TreeNode struct {
Key string
Title string
Children []TreeNode
IsLeaf bool // never expandable (relevant with LoadData)
Disabled bool
DisableCheckbox bool
Icon *icon.Icon // shown with ShowIcon; nil uses folder/file
}TreeNode is one node of a Tree. Keys must be unique in the whole tree.
func TreeMove 实验性
func TreeMove(nodes []TreeNode, drag, drop string, pos int) []TreeNodeTreeMove returns a copy of nodes with the node drag moved before, inside (as first child) or after the node drop. Moving a node into its own subtree is ignored.
TreeSelectNode 实验性
type TreeSelectNode struct {
Label, Value string
Disabled bool
Children []TreeSelectNode
IsLeaf bool // never expandable (relevant with LoadData)
}TreeSelectNode is a node of a TreeSelect tree. Values must be unique. With LoadData, a node without Children that is not IsLeaf loads its children when expanded.
TreeSelectW 实验性
type TreeSelectW struct {
// contains filtered or unexported fields
}TreeSelectW is a select whose options form a tree.
func TreeSelect 实验性
func TreeSelect(c *Context, val *string, nodes []TreeSelectNode) *TreeSelectWTreeSelect adds a tree select bound to *val (single selection). Use Multiple / Checkable for multiple values.
func (*TreeSelectW) A11yLabel 实验性
func (w *TreeSelectW) A11yLabel(s string) *TreeSelectWA11yLabel sets the accessible name (inside a FormItem the item label is used; the placeholder is the last resort).
func (*TreeSelectW) AllowClear 实验性
func (w *TreeSelectW) AllowClear() *TreeSelectWfunc (*TreeSelectW) Changed 实验性
func (w *TreeSelectW) Changed() boolChanged reports a selection change this frame.
func (*TreeSelectW) CheckStrictly 实验性
func (w *TreeSelectW) CheckStrictly() *TreeSelectWCheckStrictly unlinks parents and children in Checkable mode (Ant treeCheckStrictly, Element check-strictly; implies Checkable): every node, parent or leaf, is checked on its own, the value holds exactly the checked nodes and each one is a tag. ShowCheckedStrategy and StrategyValue do not apply.
func (*TreeSelectW) Checkable 实验性
func (w *TreeSelectW) Checkable() *TreeSelectWCheckable shows checkboxes with parent/child linkage (implies Multiple; the value holds the checked leaves).
func (*TreeSelectW) Checked 实验性
func (w *TreeSelectW) Checked() []stringChecked returns the selected values; in Checkable mode they follow the checked strategy (the values shown as tags).
func (*TreeSelectW) DefaultExpandAll 实验性
func (w *TreeSelectW) DefaultExpandAll() *TreeSelectWfunc (*TreeSelectW) Disabled 实验性
func (w *TreeSelectW) Disabled(on bool) *TreeSelectWDisabled disables the control.
func (*TreeSelectW) ExpandChanged 实验性
func (w *TreeSelectW) ExpandChanged() boolExpandChanged reports that the bound ExpandedKeys changed this frame.
func (*TreeSelectW) ExpandedKeys 实验性
func (w *TreeSelectW) ExpandedKeys(keys *[]string) *TreeSelectWExpandedKeys binds the expanded nodes of the dropdown to *keys (controlled treeExpandedKeys): the tree shows exactly these nodes open, and expanding or collapsing (pointer, keyboard, opening on the current value, search) writes the new list back in tree order. DefaultExpandAll only seeds an empty list at the first frame.
func (*TreeSelectW) FilterTreeNode 实验性
func (w *TreeSelectW) FilterTreeNode(fn func(query string, node TreeSelectNode) bool) *TreeSelectWFilterTreeNode replaces the search match (by default the label containing the typed text, case-insensitively) with fn, which receives the typed text and a node (Ant filterTreeNode, Element filter-node-method). Matching nodes are shown with their ancestors; the typed text is still highlighted where it appears in a label. Implies Searchable.
func (*TreeSelectW) IsOpen 实验性
func (w *TreeSelectW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*TreeSelectW) Layout 实验性
func (w *TreeSelectW) Layout(o ...layout.Option) *TreeSelectWfunc (*TreeSelectW) ListHeight 实验性
func (w *TreeSelectW) ListHeight(px float32) *TreeSelectWListHeight sets the maximum dropdown height with or without virtual scrolling (Ant listHeight, 256).
func (*TreeSelectW) LoadData 实验性
func (w *TreeSelectW) LoadData(fn func(value string) bool) *TreeSelectWLoadData enables lazy loading with Tree's contract: expanding a node that has no Children and is not IsLeaf calls fn(value) every frame until it returns false (true = still loading); the application appends the children to its node slice meanwhile. A spinner replaces the switcher.
func (*TreeSelectW) MaxTagCount 实验性
func (w *TreeSelectW) MaxTagCount(n int) *TreeSelectWfunc (*TreeSelectW) MaxTagPlaceholder 实验性
func (w *TreeSelectW) MaxTagPlaceholder(fn func(omitted []string) string) *TreeSelectWMaxTagPlaceholder builds the text of the collapsed tag from the hidden labels (Ant maxTagPlaceholder; default "+ N ...").
func (*TreeSelectW) Multiple 实验性
func (w *TreeSelectW) Multiple(vals *[]string) *TreeSelectWMultiple binds the selection to *vals instead (each click toggles a node).
func (*TreeSelectW) NotFoundContent 实验性
func (w *TreeSelectW) NotFoundContent(s string) *TreeSelectWNotFoundContent sets the text of an empty dropdown (Ant notFoundContent, Element no-data-text).
func (*TreeSelectW) Open 实验性
func (w *TreeSelectW) Open() *TreeSelectWOpen forces the dropdown open (screenshots, tests).
func (*TreeSelectW) Placeholder 实验性
func (w *TreeSelectW) Placeholder(s string) *TreeSelectWfunc (*TreeSelectW) Placement 实验性
func (w *TreeSelectW) Placement(p Placement) *TreeSelectWPlacement sets where the dropdown opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Ant placement, Element placement); it flips when there is no room. ConfigProvider.Defaults("TreeSelect", "placement") takes the Ant names.
func (*TreeSelectW) Searchable 实验性
func (w *TreeSelectW) Searchable() *TreeSelectWfunc (*TreeSelectW) ShowCheckedStrategy 实验性
func (w *TreeSelectW) ShowCheckedStrategy(s CheckedStrategy) *TreeSelectWShowCheckedStrategy chooses the tags of Checkable mode (default ShowChild: checked leaves; ShowParent: a fully checked parent replaces its children; ShowAll: every checked node). By default the bound value holds the checked leaves and Checked returns the strategy's values; with StrategyValue(true) the bound value itself follows the strategy (Ant).
func (*TreeSelectW) Size 实验性
func (w *TreeSelectW) Size(s ControlSize) *TreeSelectWfunc (*TreeSelectW) Status 实验性
func (w *TreeSelectW) Status(s string) *TreeSelectWfunc (*TreeSelectW) StrategyValue 实验性
func (w *TreeSelectW) StrategyValue(on bool) *TreeSelectWStrategyValue makes the bound value of Checkable mode follow the checked strategy, as Ant's value does: with ShowParent a fully checked parent is stored instead of its leaves, with ShowAll parents and leaves are both stored. Values written by the application are read the same way (a parent value checks its whole subtree). Default false: the value holds the checked leaves whatever the strategy (lossless with lazy loading and disabled nodes, and what earlier versions stored).
func (*TreeSelectW) Variant 实验性
func (w *TreeSelectW) Variant(v FieldVariant) *TreeSelectWVariant sets the frame look (FieldOutlined by default).
func (*TreeSelectW) Virtual 实验性
func (w *TreeSelectW) Virtual(on bool) *TreeSelectWVirtual forces the virtual dropdown on or off (default: more than 100 visible rows).
func (*TreeSelectW) Width 实验性
func (w *TreeSelectW) Width(px float32) *TreeSelectWTreeW
type TreeW struct {
// contains filtered or unexported fields
}TreeW is a hierarchical list with expand, select, check, drag and search.
func Tree
func Tree(c *Context, nodes []TreeNode) *TreeWTree starts a tree over nodes; configure with modifiers and call Show.
The tree is one Tab stop. Keyboard: Up/Down move the focused row, Home/End jump to the first/last row, Right expands (or enters the first child), Left collapses (or returns to the parent), Enter selects, Space checks when Checkable and selects otherwise.
func (*TreeW) A11yLabel
func (w *TreeW) A11yLabel(s string) *TreeWA11yLabel sets the tree's accessible name (inside a FormItem the item label is used).
func (*TreeW) Accordion
func (w *TreeW) Accordion() *TreeWAccordion keeps one node expanded per level: expanding a node collapses its expanded siblings (Element accordion).
func (*TreeW) AllowDrag
func (w *TreeW) AllowDrag(fn func(key string) bool) *TreeWAllowDrag decides which nodes can be dragged (antd draggable.nodeDraggable, Element allow-drag).
func (*TreeW) AllowDrop
func (w *TreeW) AllowDrop(fn func(drag, drop string, pos int) bool) *TreeWAllowDrop decides where a dragged node may land (antd allowDrop, Element allow-drop); pos is TreeDropBefore / Inside / After.
func (*TreeW) BlockNode
func (w *TreeW) BlockNode() *TreeWBlockNode stretches titles to the full row width.
func (*TreeW) Built
func (w *TreeW) Built() intBuilt returns how many rows the last Show built. With virtual scrolling it counts the viewport rows and overscan.
func (*TreeW) CheckChanged
func (w *TreeW) CheckChanged() boolfunc (*TreeW) CheckOnClick
func (w *TreeW) CheckOnClick(on bool) *TreeWCheckOnClick toggles the checkbox when a checkable node's title is clicked (Element check-on-click-node).
func (*TreeW) CheckOnClickLeaf
func (w *TreeW) CheckOnClickLeaf(on bool) *TreeWCheckOnClickLeaf toggles the checkbox when a checkable leaf's title is clicked (Element check-on-click-leaf, on by default there; antd selects instead, so it is off by default here: turn it on per tree or with Defaults("Tree", Props{"checkOnClickLeaf": true})).
func (*TreeW) CheckStrictly
func (w *TreeW) CheckStrictly() *TreeWCheckStrictly disables parent/child check cascading.
func (*TreeW) Checkable
func (w *TreeW) Checkable(checked *[]string) *TreeWCheckable shows checkboxes bound to checked keys.
func (*TreeW) DataVersion
func (w *TreeW) DataVersion(v int) *TreeWDataVersion turns on the cache for a virtual scrolling tree and tells it that its nodes were modified in place. The tree keeps the parent map, Filter visibility, flattened visible rows and check states between frames while the top-level nodes slice (identity and length), v, the expanded keys, the search keyword and the checked keys stay the same, so a frame costs O(rows in view) instead of O(nodes). Titles and the other node fields are read live; a structural change made in place (children added, removed or replaced, keys changed, a title edit that changes a Filter match) shows only after v changes (or with a new slice). The check states, parents' checked and half-checked marks included, are cached too: a child's Disabled or DisableCheckbox changed in place (which changes how checks cascade) also needs a change of v. Without DataVersion the tree rebuilds all of this every frame, as before.
func (*TreeW) DefaultExpandAll
func (w *TreeW) DefaultExpandAll() *TreeWDefaultExpandAll expands every parent node the first time the tree is shown (antd defaultExpandAll, Element default-expand-all).
func (*TreeW) Disabled
func (w *TreeW) Disabled(on bool) *TreeWDisabled disables the whole tree (antd disabled): no selection, expansion, checking, dragging or keyboard focus.
func (*TreeW) Draggable
func (w *TreeW) Draggable() *TreeWDraggable enables drag-to-reorder; read the result with Dropped.
func (*TreeW) Dropped
func (w *TreeW) Dropped() (drag, drop string, pos int, ok bool)Dropped reports a completed drag in the last Show: the dragged key, the key it was dropped on and the position (TreeDropBefore/Inside/After).
func (*TreeW) EmptyText
func (w *TreeW) EmptyText(s string) *TreeWEmptyText shows s when the tree has no rows to show (Element empty-text; antd shows nothing). The Element theme shows Locale.NoData by default (TreeToken.ShowEmptyText).
func (*TreeW) ExpandChanged
func (w *TreeW) ExpandChanged() boolfunc (*TreeW) ExpandOnClick
func (w *TreeW) ExpandOnClick(on bool) *TreeWExpandOnClick toggles expansion when the title is clicked (Element's expand-on-click-node, on by default with the Element theme).
func (*TreeW) Expanded
func (w *TreeW) Expanded(keys *[]string) *TreeWExpanded binds the expanded keys to the app.
func (*TreeW) Filter
func (w *TreeW) Filter() *TreeWFilter hides nodes that neither match the search keyword nor contain a match (Element's filter-node-method).
func (*TreeW) FilterMethod
func (w *TreeW) FilterMethod(fn func(keyword string, n *TreeNode) bool) *TreeWFilterMethod replaces the title-contains match used by Search and Filter (antd filterTreeNode, Element filter-node-method).
func (*TreeW) HalfChecked
func (w *TreeW) HalfChecked() []stringHalfChecked returns the keys drawn half-checked after the last Show.
func (*TreeW) Height
func (w *TreeW) Height(px float32) *TreeWHeight turns the tree into a scrolling viewport of px. By default it builds only the rows in view (Ant height / virtual) and expands or collapses without a height animation. Set virtual: false in ConfigProvider.Defaults("Tree", ...) to build every expanded branch inside the scroll area. The virtual tree walks and flattens the nodes each frame unless DataVersion is set, which caches that work. VirtualTree also supports custom row renderers and Range.
func (*TreeW) Layout
func (w *TreeW) Layout(o ...layout.Option) *TreeWLayout applies layout options to the tree (after Show).
func (*TreeW) LoadData
func (w *TreeW) LoadData(fn func(key string) bool) *TreeWLoadData enables lazy loading: expanding a non-leaf node without children calls fn(key) every frame until it returns false (still loading = true); a spinner replaces the switcher meanwhile.
func (*TreeW) Multiple
func (w *TreeW) Multiple() *TreeWMultiple allows selecting several nodes.
func (*TreeW) Search
func (w *TreeW) Search(keyword string) *TreeWSearch highlights titles containing keyword and, when the keyword changes, expands the parents of every match.
func (*TreeW) SelectChanged
func (w *TreeW) SelectChanged() boolSelectChanged / CheckChanged / ExpandChanged report changes in the last Show.
func (*TreeW) Selectable
func (w *TreeW) Selectable(on bool) *TreeWSelectable turns selection on or off (antd selectable, default true). An unselectable tree still expands, checks and drags.
func (*TreeW) Selected
func (w *TreeW) Selected(keys *[]string) *TreeWSelected binds the selected keys to the app.
func (*TreeW) Show
func (w *TreeW) Show() *TreeWShow builds the tree.
func (*TreeW) ShowIcon
func (w *TreeW) ShowIcon() *TreeWShowIcon draws node icons before titles.
func (*TreeW) ShowLine
func (w *TreeW) ShowLine() *TreeWShowLine draws connecting lines (Ant).
func (*TreeW) SwitcherIcon
func (w *TreeW) SwitcherIcon(ic *icon.Icon) *TreeWSwitcherIcon replaces the expand switcher (antd switcherIcon, Element icon). Draw it pointing down: it turns -90° while collapsed.
Trigger
type Trigger uint8Trigger selects how a popup opens.
Append-only: never reorder or insert; the zero value stays TriggerHover.
const (
TriggerHover Trigger = iota // pointer rests on the trigger (default)
TriggerClick // click toggles
TriggerContextMenu // secondary click / long press, opens at the pointer
)UIPoster 实验性
type UIPoster interface{ PostUI(fn func()) }UIPoster is implemented by hosts whose UI thread is the main thread. PostUI runs fn on that thread later, never inline; any goroutine may call it. Runner.Post uses it when no thread is bound. Experimental.
UploadFile 实验性
type UploadFile struct {
Name string
Size int64
Status string
Percent float64
Thumb image.Image
// Set for files the Upload added itself (Picker, dropped files):
Path string // local path of the file
UID int64 // identifies the file while it uploads (0 = none)
Err string // why the upload failed
Response []byte // body of the server's reply to Action
}UploadFile is an entry of an Upload list. Status is "uploading", "done" or "error"; Percent (0..100) is shown while uploading. Files the Upload adds without Action / CustomRequest are "done" (accepted locally, see CustomRequest).
UploadListType 实验性
type UploadListType stringUploadListType selects how an Upload lists its files (Ant listType).
const (
// UploadListText lists file names under a button (the default).
UploadListText UploadListType = "text"
// UploadListPicture lists bordered rows with a thumbnail, the name
// and the upload progress under a button.
UploadListPicture UploadListType = "picture"
// UploadListPictureCard shows thumbnail cards with a "+" card
// trigger (PictureCard).
UploadListPictureCard UploadListType = "picture-card"
)实验性
UploadLocale 实验性
type UploadLocale struct {
Trigger string // picture-card add tile ("上传")
Uploading string // progress text of a file ("文件上传中")
Remove string // remove action of a file
Preview string // preview action of a file
Button string // select button / Element dragger link ("点击上传")
DragTitle string // Ant dragger title
DropPrefix string // Element dragger text before the link ("将文件拖到此处,或")
// Announcements and rejection messages of dropped / picked files.
DoneFmt string // upload finished, arg: file name ("%s 上传成功")
FailedFmt string // upload failed, arg: file name ("%s 上传失败")
TooManyFmt string // list full, arg: file name
BadTypeFmt string // type not accepted, arg: file name
TooLargeFmt string // over the size limit, args: file name, limit ("%s 超过 %s")
IsDirFmt string // a folder was dropped, arg: folder name
// contains filtered or unexported fields
}UploadLocale holds the Upload texts. The dragger has no default hint line; set one with DragText.
UploadW 实验性
type UploadW struct {
// contains filtered or unexported fields
}UploadW shows an upload trigger and the file list. The UI layer never opens a file dialog itself: OnPick (or Picked) tells the host to show one (e.g. with the dialog package) and append the chosen files to the list.
func Upload 实验性
func Upload(c *Context, files *[]UploadFile) *UploadWUpload adds an upload area bound to *files.
func (*UploadW) Accept 实验性
func (w *UploadW) Accept(s string) *UploadWAccept limits the files Picker offers and the files accepted from the picker or a drop: comma-separated extensions and MIME types (".png,.jpg,image/*", like the HTML accept attribute). Other files are rejected with a message.
func (*UploadW) Action 实验性
func (w *UploadW) Action(url string) *UploadWAction uploads every added file to url (multipart/form-data POST, field "file"), showing its progress; Headers, Data, FieldName, Method, Retries and Client tune the request. A reply with status >= 400 or a network error marks the file "error" with a retry button.
func (*UploadW) Added 实验性
func (w *UploadW) Added() []UploadFileAdded returns the files the Upload added this frame (picked or dropped, after the checks).
func (*UploadW) AutoUpload 实验性
func (w *UploadW) AutoUpload(on bool) *UploadWAutoUpload(false) holds the files added with Action or CustomRequest in the list with Status "ready" instead of uploading them at once (Element auto-upload=false, Ant beforeUpload returning false); Submit uploads them. Without Action / CustomRequest files are accepted locally either way.
func (*UploadW) BeforeUpload 实验性
func (w *UploadW) BeforeUpload(fn func(f UploadFile) error) *UploadWBeforeUpload runs for every file about to be added (after Accept and MaxSize); a non-nil error rejects it and is shown as the message.
func (*UploadW) ButtonText 实验性
func (w *UploadW) ButtonText(s string) *UploadWButtonText sets the text of the default button trigger.
func (*UploadW) Changed 实验性
func (w *UploadW) Changed() boolChanged reports a removal this frame.
func (*UploadW) Client 实验性
func (w *UploadW) Client(cl *http.Client) *UploadWClient sets the HTTP client of Action (default http.DefaultClient).
func (*UploadW) CustomRequest 实验性
func (w *UploadW) CustomRequest(fn func(ctx context.Context, f UploadFile, progress func(pct float64)) ([]byte, error)) *UploadWCustomRequest uploads every added file with fn instead of the built-in HTTP request (Ant customRequest): fn runs on its own goroutine, reports progress (0..100) and returns the reply body or an error. The file shows "uploading", then "done" or "error" with a retry button, like Action; Retries also applies. ctx is cancelled when the file is removed.
Without Action and CustomRequest the Upload only collects files: they are added with Status "done" (meaning accepted locally) and handed to the application through Added; an application that uploads them itself sets Status / Percent / Err on the bound list.
func (*UploadW) Data 实验性
func (w *UploadW) Data(d map[string]string) *UploadWData adds form fields to the Action request.
func (*UploadW) Directory 实验性
func (w *UploadW) Directory() *UploadWDirectory picks (and accepts dropped) folders and adds every file in them, named by their path inside the folder (Ant directory). The picker must support choosing folders (uihost.FilePicker does).
func (*UploadW) Disabled 实验性
func (w *UploadW) Disabled(on bool) *UploadWDisabled disables picking and removing.
func (*UploadW) DragOver 实验性
func (w *UploadW) DragOver(on bool) *UploadWDragOver highlights the dragger while the host reports a file drag over the window.
func (*UploadW) DragText 实验性
func (w *UploadW) DragText(title, hint string) *UploadWDragText sets the main text and hint of the dragger.
func (*UploadW) Dragger 实验性
func (w *UploadW) Dragger() *UploadWDragger shows a large dashed drop area as the trigger.
func (*UploadW) FieldName 实验性
func (w *UploadW) FieldName(s string) *UploadWFieldName sets the form field of the file (default "file").
func (*UploadW) Headers 实验性
func (w *UploadW) Headers(h map[string]string) *UploadWHeaders sets request headers of Action.
func (*UploadW) ListType 实验性
func (w *UploadW) ListType(t UploadListType) *UploadWListType selects the file list: UploadListText (default), UploadListPicture (PictureList) or UploadListPictureCard (PictureCard).
func (*UploadW) MaxCount 实验性
func (w *UploadW) MaxCount(n int) *UploadWMaxCount limits the number of files; the trigger is disabled (cards: hidden) once reached and further files are rejected (see Rejections; Element limit / on-exceed). MaxCount(1) replaces the current file with the new one instead, like antd maxCount={1}: the trigger stays enabled.
func (*UploadW) MaxSize 实验性
func (w *UploadW) MaxSize(n int64) *UploadWMaxSize rejects files larger than n bytes with a message (0 = no limit).
func (*UploadW) Method 实验性
func (w *UploadW) Method(m string) *UploadWMethod sets the request method (default POST).
func (*UploadW) Multiple 实验性
func (w *UploadW) Multiple() *UploadWMultiple lets the picker choose several files.
func (*UploadW) OnPick 实验性
func (w *UploadW) OnPick(fn func()) *UploadWOnPick sets the callback run when the user activates the trigger.
func (*UploadW) Picked 实验性
func (w *UploadW) Picked() boolPicked reports that the trigger was activated this frame.
func (*UploadW) Picker 实验性
func (w *UploadW) Picker(fn func(accept string, multiple, dir bool) ([]string, error)) *UploadWPicker sets the file chooser the trigger opens (uihost.FilePicker for the native dialog). It runs on its own goroutine and returns the chosen paths (nil, nil when cancelled); accept is Accept, multiple is Multiple, dir is Directory. The files are then checked and added to the list (and uploaded with Action). OnPick still runs, for hosts that add files themselves.
func (*UploadW) PictureCard 实验性
func (w *UploadW) PictureCard() *UploadWPictureCard shows files as thumbnail cards with a "+" card trigger.
func (*UploadW) PictureList 实验性
func (w *UploadW) PictureList() *UploadWPictureList lists the files as bordered rows with a thumbnail (the file's Thumb, else a picture glyph), the name and the progress bar, under the button trigger (Ant listType="picture", Element list-type="picture"). Clicking a thumbnail reports it through Previewed.
func (*UploadW) Previewed 实验性
func (w *UploadW) Previewed() intPreviewed returns the index of the card whose preview icon was clicked, or -1.
func (*UploadW) Rejections 实验性
func (w *UploadW) Rejections() []stringRejections returns the messages about files that were not added (wrong type, too large, BeforeUpload errors), shown under the trigger until the next pick or drop.
func (*UploadW) Removed 实验性
func (w *UploadW) Removed() intRemoved returns the index of the file removed this frame, or -1.
func (*UploadW) Retries 实验性
func (w *UploadW) Retries(n int) *UploadWRetries retries a failed request up to n more times before showing the error.
func (*UploadW) ShowUploadList 实验性
func (w *UploadW) ShowUploadList(on bool) *UploadWShowUploadList shows (true, the default) or hides the file list (antd showUploadList, Element show-file-list); the trigger, tip and rejections stay.
func (*UploadW) Submit 实验性
func (w *UploadW) Submit() intSubmit uploads every "ready" file of the list (see AutoUpload) with Action or CustomRequest, e.g. when a separate "upload" button is clicked. It returns how many uploads it started.
func (*UploadW) Tip 实验性
func (w *UploadW) Tip(s string) *UploadWTip shows a help line under the trigger.
func (*UploadW) Width 实验性
func (w *UploadW) Width(px float32) *UploadWWidth fixes the width (text list and dragger).
ValueCopier 实验性
type ValueCopier interface {
CopyValue(n *ValueNode) string
}ValueCopier is implemented by sources whose nodes show a shortened value: CopyValue returns the full value for "copy value".
ValueKind 实验性
type ValueKind uint8ValueKind is the type of a value tree node.
const (
ValueNull ValueKind = iota
ValueBool
ValueNumber
ValueString
ValueObject
ValueArray
ValueOther
)The value kinds. ValueOther is anything else a source wants to show with a summary (a function, a channel, a debugger's opaque value).
实验性
ValueNode 实验性
type ValueNode struct {
// Name is the object key or variable name; for array elements the
// index (with Index set). The single root of a JSON document has
// none.
Name string
Index bool
Kind ValueKind
// Value is the display text: scalars as written (strings without
// quotes, possibly shortened), a summary for ValueOther; empty for
// objects and arrays (the view shows their size).
Value string
// Type is an optional type label shown after the value (debuggers).
Type string
// Count is the number of children of an object or array; -1 when
// unknown until they are loaded. A node with Count 0 has no children.
Count int
// Ref is the source's own handle of the node, passed back to
// Children.
Ref any
}ValueNode is one node of a value tree.
ValueSource 实验性
type ValueSource interface {
// Roots returns the top-level nodes.
Roots() []ValueNode
// Children returns the children [from, to) of parent (to = -1: all).
Children(parent *ValueNode, from, to int) (kids []ValueNode, ok bool)
}ValueSource supplies a value tree lazily: JSONView asks for children only when a node is expanded, and only for the expanded range of a large array or object (groups of 100). Sources may load asynchronously: Children returns ok=false while loading and the view asks again (call Context.Invalidator's function when the data arrives to repaint at once).
func GoValueSource 实验性
func GoValueSource(v any) ValueSourceGoValueSource returns a ValueSource over a Go value: structs (exported fields, named by their json tag when present), maps (sorted keys), slices, arrays, pointers and interfaces are expanded; values with a String or Error method that are not containers show that text.
func JSONSource 实验性
func JSONSource(data []byte) (ValueSource, error)JSONSource returns a ValueSource over a JSON document, or an error when it is not valid JSON. The document is scanned lazily: expanding a node reads only that container, so multi-megabyte documents open at once. data must not change while the source is in use.
VirtualListW 实验性
type VirtualListW struct {
// contains filtered or unexported fields
}VirtualListW is a vertically scrolling list of n fixed-height rows that only builds the rows inside the viewport (plus a small overscan), so it stays cheap for hundreds of thousands of items.
func VirtualList 实验性
func VirtualList(c *Context, n int, itemHeight float32, fn func(i int), opts ...layout.Option) *VirtualListWVirtualList adds a virtual list of n rows of itemHeight px; fn(i) builds row i (it runs inside a fixed-height row and its own identity scope, so row widgets keep their state while scrolling).
ui.VirtualList(c, len(rows), 32, func(i int) { ui.Text(c, rows[i]) }).Height(400)
func (*VirtualListW) A11yLabel 实验性
func (w *VirtualListW) A11yLabel(s string) *VirtualListWA11yLabel sets the accessible name of the list.
func (*VirtualListW) Height 实验性
func (w *VirtualListW) Height(px float32) *VirtualListWHeight fixes the viewport height.
func (*VirtualListW) ID 实验性
func (w *VirtualListW) ID() IDID returns the scroll container's ID.
func (*VirtualListW) Layout 实验性
func (w *VirtualListW) Layout(opts ...layout.Option) *VirtualListWLayout applies layout options to the viewport.
func (*VirtualListW) Offset 实验性
func (w *VirtualListW) Offset() float64Offset returns the vertical scroll offset.
func (*VirtualListW) Overscan 实验性
func (w *VirtualListW) Overscan(rows int) *VirtualListWOverscan sets how many extra rows are built above and below the viewport (default 3).
func (*VirtualListW) Range 实验性
func (w *VirtualListW) Range() (first, end int)Range returns the half-open range [first, end) of rows built this frame.
func (*VirtualListW) ScrollIntoView 实验性
func (w *VirtualListW) ScrollIntoView(i int) *VirtualListWScrollIntoView scrolls the minimum amount that makes row i fully visible.
func (*VirtualListW) ScrollToIndex 实验性
func (w *VirtualListW) ScrollToIndex(i int) *VirtualListWScrollToIndex scrolls so row i is at the top (clamped to the list).
VirtualOptionGroup 实验性
type VirtualOptionGroup struct {
Label string
Options []Option
}VirtualOptionGroup is a titled group of options (Element's grouped options, Ant's OptGroup).
VirtualOptionState 实验性
type VirtualOptionState struct {
Active bool // keyboard / hover highlight
Selected bool
Disabled bool // disabled option, or the selection limit is reached
Created bool // the "create new entry" row of AllowCreate
}VirtualOptionState tells a custom option renderer how the row is shown.
VirtualSelectW 实验性
type VirtualSelectW struct {
// contains filtered or unexported fields
}VirtualSelectW is a single or multiple select with a virtualized dropdown. Build it with VirtualSelect and chain modifiers; the dropdown and value handling run when a query method is called or at the end of the build.
func VirtualSelect 实验性
func VirtualSelect(c *Context, val *string, opts []Option) *VirtualSelectWVirtualSelect adds a select bound to *val over opts whose dropdown only builds the visible rows (100k options stay smooth). Call Multiple to bind a list of values instead.
ui.VirtualSelect(c, &city, cities).Filterable().AllowClear()
ui.VirtualSelect(c, nil, opts).Multiple(&tags).MaxCount(3)
func (*VirtualSelectW) AllowClear 实验性
func (w *VirtualSelectW) AllowClear() *VirtualSelectWAllowClear shows a clear button on hover.
func (*VirtualSelectW) AllowCreate 实验性
func (w *VirtualSelectW) AllowCreate() *VirtualSelectWAllowCreate offers the typed text as a new option when no label matches it exactly (Element allow-create, Ant mode="tags"); read it with Created.
func (*VirtualSelectW) Changed 实验性
func (w *VirtualSelectW) Changed() boolChanged reports a selection change this frame.
func (*VirtualSelectW) Created 实验性
func (w *VirtualSelectW) Created() (string, bool)Created returns the value of an entry created with AllowCreate this frame.
func (*VirtualSelectW) DataVersion 实验性
func (w *VirtualSelectW) DataVersion(v int) *VirtualSelectWDataVersion tells the select that the option slices were modified in place (caches are keyed by slice identity and this number).
func (*VirtualSelectW) Debounce 实验性
func (w *VirtualSelectW) Debounce(d time.Duration) *VirtualSelectWDebounce sets the delay of Remote calls.
func (*VirtualSelectW) Disabled 实验性
func (w *VirtualSelectW) Disabled(on bool) *VirtualSelectWDisabled turns the control off.
func (*VirtualSelectW) FilterMethod 实验性
func (w *VirtualSelectW) FilterMethod(fn func(query string, o Option) bool) *VirtualSelectWFilterMethod replaces the label match used by Filterable.
func (*VirtualSelectW) Filterable 实验性
func (w *VirtualSelectW) Filterable() *VirtualSelectWFilterable lets the user type to filter options by label (case-insensitive).
func (*VirtualSelectW) Groups 实验性
func (w *VirtualSelectW) Groups(groups []VirtualOptionGroup) *VirtualSelectWGroups replaces the options with titled groups (group titles are not selectable and are skipped by the keyboard).
func (*VirtualSelectW) ID 实验性
func (w *VirtualSelectW) ID() IDID returns the control's ID.
func (*VirtualSelectW) IsOpen 实验性
func (w *VirtualSelectW) IsOpen() boolIsOpen reports whether the dropdown is shown.
func (*VirtualSelectW) ItemHeight 实验性
func (w *VirtualSelectW) ItemHeight(px float32) *VirtualSelectWItemHeight sets the option row height (Element 34, Ant 32).
func (*VirtualSelectW) Layout 实验性
func (w *VirtualSelectW) Layout(o ...layout.Option) *VirtualSelectWLayout applies layout options to the control.
func (*VirtualSelectW) ListHeight 实验性
func (w *VirtualSelectW) ListHeight(px float32) *VirtualSelectWListHeight sets the maximum dropdown height (Element 274, Ant 256).
func (*VirtualSelectW) Loading 实验性
func (w *VirtualSelectW) Loading(on bool) *VirtualSelectWLoading shows the loading text instead of the options and a spinner in place of the arrow (Ant loading).
func (*VirtualSelectW) MaxCount 实验性
func (w *VirtualSelectW) MaxCount(n int) *VirtualSelectWMaxCount limits how many values a multiple select may hold (Element multiple-limit, Ant maxCount); other options turn disabled at the limit.
func (*VirtualSelectW) MaxTagCount 实验性
func (w *VirtualSelectW) MaxTagCount(n int) *VirtualSelectWMaxTagCount collapses tags after n into "+ N ...".
func (*VirtualSelectW) Multiple 实验性
func (w *VirtualSelectW) Multiple(vals *[]string) *VirtualSelectWMultiple switches to multiple selection bound to *vals (selected values shown as closable tags).
func (*VirtualSelectW) NotFoundContent 实验性
func (w *VirtualSelectW) NotFoundContent(s string) *VirtualSelectWNotFoundContent replaces the text of an empty dropdown (Element no-data-text / no-match-text, Ant notFoundContent).
func (*VirtualSelectW) Open 实验性
func (w *VirtualSelectW) Open() *VirtualSelectWOpen forces the dropdown open (screenshots, tests).
func (*VirtualSelectW) OptionRender 实验性
func (w *VirtualSelectW) OptionRender(fn func(o Option, s VirtualOptionState)) *VirtualSelectWOptionRender builds each option row's content with fn instead of the plain label (the row background, highlight and check mark stay).
func (*VirtualSelectW) Placeholder 实验性
func (w *VirtualSelectW) Placeholder(s string) *VirtualSelectWPlaceholder sets the text shown without a value.
func (*VirtualSelectW) Placement 实验性
func (w *VirtualSelectW) Placement(p Placement) *VirtualSelectWPlacement sets where the dropdown opens: BottomStart (default), BottomEnd, TopStart or TopEnd (Element placement, Ant placement); it flips when there is no room.
func (*VirtualSelectW) Query 实验性
func (w *VirtualSelectW) Query() stringQuery returns the current search text.
func (*VirtualSelectW) Remote 实验性
func (w *VirtualSelectW) Remote(fn func(query string)) *VirtualSelectWRemote turns on server-side search: fn receives the typed query after Debounce (default 300ms) and should replace the options; local filtering is off. Show progress with Loading.
func (*VirtualSelectW) Size 实验性
func (w *VirtualSelectW) Size(s ControlSize) *VirtualSelectWSize sets the control size.
func (*VirtualSelectW) Status 实验性
func (w *VirtualSelectW) Status(s string) *VirtualSelectWStatus sets the validation status ("error", "warning").
func (*VirtualSelectW) Width 实验性
func (w *VirtualSelectW) Width(px float32) *VirtualSelectWWidth fixes the control width.
VirtualTreeW 实验性
type VirtualTreeW struct {
// contains filtered or unexported fields
}VirtualTreeW is a virtualized tree. Configure it with modifiers and call Show.
func VirtualTree 实验性
func VirtualTree(c *Context, nodes []TreeNode) *VirtualTreeWVirtualTree starts a virtualized tree over nodes (keys unique in the whole tree); configure with modifiers and call Show.
Keyboard (the tree is one Tab stop): Up/Down/PageUp/PageDown/Home/End move the cursor row, Right expands or enters the first child, Left collapses or returns to the parent, Enter makes the row current, Space checks it when Checkable.
ui.VirtualTree(c, nodes).Checkable(&checked).Height(400).Show()
func (*VirtualTreeW) Accordion 实验性
func (w *VirtualTreeW) Accordion() *VirtualTreeWAccordion keeps one node expanded per level: expanding a node collapses its expanded siblings (Element accordion).
func (*VirtualTreeW) CheckChanged 实验性
func (w *VirtualTreeW) CheckChanged() boolCheckChanged / ExpandChanged / CurrentChanged report changes in Show.
func (*VirtualTreeW) CheckOnClick 实验性
func (w *VirtualTreeW) CheckOnClick() *VirtualTreeWCheckOnClick toggles the check box when a row is clicked.
func (*VirtualTreeW) CheckOnClickLeaf 实验性
func (w *VirtualTreeW) CheckOnClickLeaf(on bool) *VirtualTreeWCheckOnClickLeaf toggles the check box when a leaf row is clicked (Element check-on-click-leaf; off by default, as antd selects instead).
func (*VirtualTreeW) CheckStrictly 实验性
func (w *VirtualTreeW) CheckStrictly() *VirtualTreeWCheckStrictly makes parent and child check states independent.
func (*VirtualTreeW) Checkable 实验性
func (w *VirtualTreeW) Checkable(checked *[]string) *VirtualTreeWCheckable shows check boxes bound to checked keys (fully checked keys, parents included; nil keeps them inside the tree).
func (*VirtualTreeW) Current 实验性
func (w *VirtualTreeW) Current(key *string) *VirtualTreeWCurrent binds the current (highlighted) node key.
func (*VirtualTreeW) CurrentChanged 实验性
func (w *VirtualTreeW) CurrentChanged() boolfunc (*VirtualTreeW) DataVersion 实验性
func (w *VirtualTreeW) DataVersion(v int) *VirtualTreeWDataVersion tells the tree that nodes were modified in place (the index is keyed by the slice identity and this number).
func (*VirtualTreeW) EmptyText 实验性
func (w *VirtualTreeW) EmptyText(s string) *VirtualTreeWEmptyText shows s instead of the empty illustration when no row is shown (Element empty-text); the Element theme shows Locale.NoData (TreeToken.ShowEmptyText).
func (*VirtualTreeW) ExpandChanged 实验性
func (w *VirtualTreeW) ExpandChanged() boolfunc (*VirtualTreeW) ExpandOnClick 实验性
func (w *VirtualTreeW) ExpandOnClick(on bool) *VirtualTreeWExpandOnClick toggles expansion when a row is clicked (Element's expand-on-click-node; on by default with the Element theme).
func (*VirtualTreeW) Expanded 实验性
func (w *VirtualTreeW) Expanded(keys *[]string) *VirtualTreeWExpanded binds the expanded keys to the app.
func (*VirtualTreeW) Filter 实验性
func (w *VirtualTreeW) Filter(query string) *VirtualTreeWFilter shows only nodes matching query (case-insensitive title match) and their ancestors, expanding the ancestors when the query changes.
func (*VirtualTreeW) FilterMethod 实验性
func (w *VirtualTreeW) FilterMethod(fn func(query string, n *TreeNode) bool) *VirtualTreeWFilterMethod replaces the title match used by Filter.
func (*VirtualTreeW) HalfChecked 实验性
func (w *VirtualTreeW) HalfChecked() []stringHalfChecked returns the half-checked keys (after Show).
func (*VirtualTreeW) Height 实验性
func (w *VirtualTreeW) Height(px float32) *VirtualTreeWHeight sets the viewport height (default 200, Element's default).
func (*VirtualTreeW) ID 实验性
func (w *VirtualTreeW) ID() IDID returns the scroll viewport's ID (after Show).
func (*VirtualTreeW) LoadData 实验性
func (w *VirtualTreeW) LoadData(fn func(key string) bool) *VirtualTreeWLoadData enables lazy loading: expanding a non-leaf node without children calls fn(key) every frame until it returns false (still loading = true). Add the children to the node meanwhile; the tree re-indexes when loading finishes.
func (*VirtualTreeW) NodeClicked 实验性
func (w *VirtualTreeW) NodeClicked() (string, bool)NodeClicked returns the key of the row clicked in Show.
func (*VirtualTreeW) NodeRender 实验性
func (w *VirtualTreeW) NodeRender(fn func(n *TreeNode, depth int)) *VirtualTreeWNodeRender builds each row's content with fn instead of the title.
func (*VirtualTreeW) Range 实验性
func (w *VirtualTreeW) Range() (first, end int)Range returns the rows [first, end) built by Show.
func (*VirtualTreeW) ScrollToKey 实验性
func (w *VirtualTreeW) ScrollToKey(key string) *VirtualTreeWScrollToKey expands the ancestors of key and scrolls its row into view.
func (*VirtualTreeW) Show 实验性
func (w *VirtualTreeW) Show() *VirtualTreeWShow builds the tree.
func (*VirtualTreeW) VisibleCount 实验性
func (w *VirtualTreeW) VisibleCount() intVisibleCount returns the number of rows (expanded and not filtered out).
WatermarkW 实验性
type WatermarkW struct {
// contains filtered or unexported fields
}WatermarkW tiles rotated text (or an image) over its content. The marks are painted above the children but never take pointer input.
The tiling follows Ant Design 6.7 (es/watermark/useClips.js): each mark is rotated about its centre, the rotated bounding box plus the gap makes a cell, and every other column is shifted down by half a cell.
func Watermark 实验性
func Watermark(c *Context, lines ...string) *WatermarkWWatermark starts a watermark container; each argument is one text line. Defaults follow Ant Design / Element Plus: -22°, gap 100×100, 16px, rgba(0,0,0,.15) (theme-aware), every other column shifted by half a cell.
func (*WatermarkW) Body 实验性
func (w *WatermarkW) Body(fn func()) *WatermarkWBody builds the watermarked content.
func (*WatermarkW) Color 实验性
func (w *WatermarkW) Color(col theme.Color) *WatermarkWColor sets the mark color (use a translucent color).
func (*WatermarkW) FontSize 实验性
func (w *WatermarkW) FontSize(px float32) *WatermarkWFontSize sets the text size.
func (*WatermarkW) FontStyle 实验性
func (w *WatermarkW) FontStyle(s string) *WatermarkWFontStyle sets "normal" (default) or "italic" ("oblique" draws italic; Ant font.fontStyle).
func (*WatermarkW) Gap 实验性
func (w *WatermarkW) Gap(x, y float32) *WatermarkWGap sets the spacing between marks.
func (*WatermarkW) Grid 实验性
func (w *WatermarkW) Grid() *WatermarkWGrid disables the shifted columns (marks on a plain grid).
func (*WatermarkW) Image 实验性
func (w *WatermarkW) Image(img image.Image, wpx, hpx float32) *WatermarkWImage uses img (drawn at w×h and rotated like text) instead of text.
func (*WatermarkW) ImageOpacity 实验性
func (w *WatermarkW) ImageOpacity(a float32) *WatermarkWImageOpacity sets the opacity of image marks (default 1: Ant draws the image as it is, so use a faint image or a lower opacity).
func (*WatermarkW) Layout 实验性
func (w *WatermarkW) Layout(o ...layout.Option) *WatermarkWLayout applies layout options to the container.
func (*WatermarkW) MarkSize 实验性
func (w *WatermarkW) MarkSize(wpx, hpx float32) *WatermarkWMarkSize sets the size of one mark before rotation (Ant width / height; default: the text's size, or 120×64 for an image without a size).
func (*WatermarkW) Offset 实验性
func (w *WatermarkW) Offset(x, y float32) *WatermarkWOffset sets where the first mark's box starts, measured to the middle of its gap (Ant offset; default gap/2, the box at the top-left corner).
func (*WatermarkW) Rotate 实验性
func (w *WatermarkW) Rotate(deg float64) *WatermarkWRotate sets the rotation in degrees (negative = counter-clockwise).
func (*WatermarkW) Weight 实验性
func (w *WatermarkW) Weight(wt text.Weight) *WatermarkWWeight sets the text weight.
Window
type Window interface {
// Size is the drawable content size in host logical pixels (before UI scaling).
Size() geom.Size
// Scale is the device-pixel ratio (2 on Retina).
Scale() float32
// Invalidate requests that the host call Runner.Frame soon (ideally on
// the next vsync). Calls coalesce.
Invalidate()
// InvalidateAt requests a frame no later than t (timers, animations
// paused between steps, caret blink). A later call with an earlier time
// wins.
InvalidateAt(t time.Time)
// SetCursor changes the pointer shape over the content area.
SetCursor(c input.Cursor)
// ReadClipboard / WriteClipboard access the plain-text clipboard.
ReadClipboard() string
WriteClipboard(s string)
// SetTextInput turns the platform text-input client (IME) on or off and
// reports the caret rectangle, in logical pixels, used to position the
// candidate window. While enabled the host delivers input.TextInput and
// input.Composition events instead of raw characters.
SetTextInput(enabled bool, caret geom.Rect)
// Present shows a finished CPU frame. img has Size()*Scale() pixels,
// is premultiplied RGBA (image.RGBA semantics) and is owned by the
// runner: copy it or upload it before returning. Hosts using a GPU
// renderer (RunnerOptions.Renderer) receive a nil image.
Present(img *image.RGBA) error
}Window is what the UI runtime needs from a platform window. A platform backend (macOS NSView, Win32 HWND, GTK widget, mobile view) implements it; so does the headless Driver used by tests.
Threading: every method except Invalidate is called on the UI thread (the thread that calls Runner.Frame / Runner.HandleEvent). Invalidate may be called from any goroutine and must only schedule a frame.
WindowAction 实验性
type WindowAction stringWindowAction is a window button the user activated. Open set.
const (
WindowActionMinimize WindowAction = "minimize"
WindowActionMaximize WindowAction = "maximize"
WindowActionRestore WindowAction = "restore" // back from maximized or full screen
WindowActionFullscreen WindowAction = "fullscreen"
WindowActionClose WindowAction = "close"
)实验性
WindowControlsStyle 实验性
type WindowControlsStyle uint8WindowControlsStyle is how WindowControls draws the window buttons.
Append-only: never reorder or insert; the zero value stays WindowControlsAuto.
const (
// WindowControlsAuto follows the platform: on macOS traffic lights at
// the start (only room for them when the system draws its own),
// elsewhere caption buttons at the end; nothing when the window keeps
// its system title bar.
WindowControlsAuto WindowControlsStyle = iota
// WindowControlsCaption draws Windows / Linux caption buttons
// (minimize, maximize / restore, close) at the end.
WindowControlsCaption
// WindowControlsTraffic draws macOS traffic lights (close, minimize,
// full screen) at the start.
WindowControlsTraffic
// WindowControlsNone draws no buttons.
WindowControlsNone
)实验性
WindowControlsW 实验性
type WindowControlsW struct {
// contains filtered or unexported fields
}WindowControlsW is the window button group WindowControls returns.
func WindowControls 实验性
func WindowControls(c *Context) *WindowControlsWWindowControls adds the minimize / maximize / close buttons of a frameless window. By default they act on the window the page draws into (Context.Window, when it implements WindowFrame) and follow the platform (WindowControlsAuto). TitleBar includes them; use WindowControls alone in a custom title area.
func (*WindowControlsW) Action 实验性
func (w *WindowControlsW) Action() WindowActionAction reports the button activated this frame ("" for none). Unless Manual, the window has already been asked to perform it.
func (*WindowControlsW) Frame 实验性
func (w *WindowControlsW) Frame(f WindowFrame) *WindowControlsWFrame sets the window the buttons act on, in place of Context.Window.
func (*WindowControlsW) Height 实验性
func (w *WindowControlsW) Height(px float32) *WindowControlsWHeight sets the height of caption buttons (the TitleBar token's Height by default).
func (*WindowControlsW) ID 实验性
func (w *WindowControlsW) ID() IDID returns the group's ID.
func (*WindowControlsW) Manual 实验性
func (w *WindowControlsW) Manual() *WindowControlsWManual only reports the activated button (Action) and leaves the window alone, for apps that confirm before closing or route the actions elsewhere.
func (*WindowControlsW) Style 实验性
func (w *WindowControlsW) Style(s WindowControlsStyle) *WindowControlsWStyle picks the button style (WindowControlsAuto by default).
WindowFrame 实验性
type WindowFrame interface {
// FrameInfo describes the window's current state and buttons.
FrameInfo() WindowFrameInfo
// SetWindowState minimizes, maximizes, makes full screen or restores
// the window.
SetWindowState(s WindowState)
// CloseWindow asks the window to close, as its system close button
// would (close handlers may still veto it).
CloseWindow()
// StartWindowMove hands the primary-button press that is in progress
// to the window manager, which moves the window until the button is
// released. Call it while handling the press.
StartWindowMove()
}WindowFrame is implemented by windows whose frame the page can drive: a frameless window with a self-drawn TitleBar asks it to move, to change state and to close. uihost windows implement it; TitleBar and WindowControls find it on Context.Window, or take one explicitly (TitleBarW.Frame) for other hosts and for tests.
All methods run on the UI thread.
WindowFrameInfo 实验性
type WindowFrameInfo struct {
State WindowState
// SystemButtons is true when the platform draws the window buttons
// over the page itself (macOS traffic lights over a hidden title bar):
// a title bar leaves room for them and draws none.
SystemButtons bool
// SystemTitleBar is true when the window keeps its system title bar
// (and buttons): a TitleBar in the page draws no window buttons.
SystemTitleBar bool
// NoMinimize, NoMaximize and NoClose disable those buttons (the
// window's appearance forbids the action).
NoMinimize, NoMaximize, NoClose bool
// contains filtered or unexported fields
}WindowFrameInfo is what a WindowFrame reports about its window.
WindowOptions 实验性
type WindowOptions struct {
Title string
Width, Height float32 // logical
MinWidth, MinHeight float32
Resizable bool
BackgroundTransparent bool
// contains filtered or unexported fields
}WindowOptions describe a window to open.
WindowState 实验性
type WindowState uint8WindowState is the state of a window.
Append-only: never reorder or insert; the zero value stays WindowNormal.
const (
WindowNormal WindowState = iota
WindowMinimized
WindowMaximized
WindowFullscreen
)实验性