NumberField
A numeric editor with increment, decrement, and drag-to-scrub parts.
Loading interactive demo…
func NumberFieldExample() *ui.Element {
value, setValue := ui.CreateSignal(8.0)
numberField := ui.NewNumberField(ui.NumberFieldRootProps{Value: func() *float64 {
current := value()
return ¤t
}, Min: 0, Max: 100, Step: 1, OnValueChange: func(next *float64, valid bool, _ *native.Event) {
if valid && next != nil {
setValue(*next)
}
}})
return numberField.Root().Children(
numberField.Decrement().Child("−"),
numberField.Input(),
numberField.Increment().Child("+"),
)
}#Import
Import ui from github.com/egoist/quickgui/go/ui.
import (
"github.com/egoist/quickgui/go/native"
"github.com/egoist/quickgui/go/ui"
)#Usage
func NumberFieldExample() *ui.Element {
value, setValue := ui.CreateSignal(8.0)
numberField := ui.NewNumberField(ui.NumberFieldRootProps{Value: func() *float64 {
current := value()
return ¤t
}, Min: 0, Max: 100, Step: 1, OnValueChange: func(next *float64, valid bool, _ *native.Event) {
if valid && next != nil {
setValue(*next)
}
}})
return numberField.Root().Children(
numberField.Decrement().Child("−"),
numberField.Input(),
numberField.Increment().Child("+"),
)
}#Anatomy
numberField.RootnumberField.GroupnumberField.InputnumberField.IncrementnumberField.DecrementnumberField.ScrubAreanumberField.ScrubAreaCursor
#API reference
Expand an entry for its description and complete signature. A dash means no declaration default is documented.
NewNumberField
View sourceui.NewNumberField(props ...NumberFieldRootProps) *NumberFieldComponentNewNumberField declares a NumberField instance. Optional props provide initial settings.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Valuefunc() *float64—
The current controlled value. Update application state from the change callback to accept a new value.
func() *float64View sourceDefaultValue*float64—
Initial value for uncontrolled state. Use Value when the application should own subsequent changes.
*float64View sourceMinany—
Maxany—
Stepany—
SmallStepany—
LargeStepany—
Precisionany—
SnapOnStep*bool—
AllowWheelScrub*bool—
Allows wheel input to adjust the number field while its scrub interaction is active.
*boolView sourceReadOnlybool—
Preserves the current value while keeping the control available for focus and inspection.
boolView sourceRequiredbool—
ScrubDirectionstring—
ScrubSensitivityany—
OnValueChangefunc(*float64, bool, *native.Event)—
Reports an accepted value change. Use the callback payload to update controlled state.
func(*float64, bool, *native.Event)View sourceOnValueCommittedfunc(*float64, *native.Event)—
Callback for value committed. The signature below lists the event payload.
func(*float64, *native.Event)View sourceNumberField.Disabled
View sourcenumberField.Disabled(value any) *NumberFieldComponentPrevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
NumberField.Value
View sourcenumberField.Value(value any) *NumberFieldComponentThe current controlled value. Update application state from the change callback to accept a new value.
NumberField.DefaultValue
View sourcenumberField.DefaultValue(value float64) *NumberFieldComponentInitial value for uncontrolled state. Use Value when the application should own subsequent changes.
NumberField.Min
View sourcenumberField.Min(value any) *NumberFieldComponentLower bound of the accepted value.
NumberField.Max
View sourcenumberField.Max(value any) *NumberFieldComponentUpper bound of the accepted value.
NumberField.Step
View sourcenumberField.Step(value any) *NumberFieldComponentIncrement applied by pointer, keyboard, or step controls.
NumberField.SmallStep
View sourcenumberField.SmallStep(value any) *NumberFieldComponentSmaller increment used by fine keyboard adjustment.
NumberField.LargeStep
View sourcenumberField.LargeStep(value any) *NumberFieldComponentLarger increment used by accelerated keyboard adjustment.
NumberField.Precision
View sourcenumberField.Precision(value any) *NumberFieldComponentNumber of fractional digits used for number formatting.
NumberField.SnapOnStep
View sourcenumberField.SnapOnStep(value bool) *NumberFieldComponentSnaps the numeric value to a step boundary during adjustment.
NumberField.AllowWheelScrub
View sourcenumberField.AllowWheelScrub(value bool) *NumberFieldComponentAllows wheel input to adjust the number field while its scrub interaction is active.
NumberField.ReadOnly
View sourcenumberField.ReadOnly(value bool) *NumberFieldComponentPreserves the current value while keeping the control available for focus and inspection.
NumberField.Required
View sourcenumberField.Required(value bool) *NumberFieldComponentMarks the control as required for validation and accessibility.
NumberField.ScrubDirection
View sourcenumberField.ScrubDirection(value string) *NumberFieldComponentAxis used to translate scrub motion into value changes.
NumberField.ScrubSensitivity
View sourcenumberField.ScrubSensitivity(value any) *NumberFieldComponentAmount of pointer motion required to change the numeric value.
NumberField.OnValueChange
View sourcenumberField.OnValueChange(value func(*float64, bool, *native.Event)) *NumberFieldComponentReports an accepted value change. Use the callback payload to update controlled state.
NumberField.OnValueCommitted
View sourcenumberField.OnValueCommitted(value func(*float64, *native.Event)) *NumberFieldComponentCallback for value committed. The signature below lists the event payload.
NumberField.Root
View sourcenumberField.Root() *ElementConfigures root for this part. The declared type and source define the accepted value.
NumberField.Group
View sourcenumberField.Group(options ...PartProps) *ElementNames this element as a group for descendant interaction-state styling.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.Input
View sourcenumberField.Input(options ...NumberFieldInputProps) *ElementConfigures input for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Typestring—
Valueany—
The current controlled value. Update application state from the change callback to accept a new value.
anyView sourcePlaceholderstring—
Multilinebool—
OnInputfunc(*native.Event)—
Receives edits from the text control. Write the new text into the controlled value.
func(*native.Event)View sourceOnChangefunc(*native.Event)—
OnSubmitfunc(*native.Event)—
OnCommitfunc(CommitDetails, *native.Event)—
Reports one explicit commit boundary and its final value details.
func(CommitDetails, *native.Event)View sourceNumberField.Increment
View sourcenumberField.Increment(options ...PartProps) *ElementConfigures increment for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.Decrement
View sourcenumberField.Decrement(options ...PartProps) *ElementConfigures decrement for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.ScrubArea
View sourcenumberField.ScrubArea(options ...PartProps) *ElementConfigures scrub area for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
NumberField.ScrubAreaCursor
View sourcenumberField.ScrubAreaCursor(options ...PartProps) *ElementConfigures scrub area cursor for this part. The declared type and source define the accepted value.
Reffunc(*native.Node)—
Receives the retained native node after construction. Keep imperative work in event or lifecycle callbacks.
func(*native.Node)View sourceStyleany—
Reusable layout, typography, color, and interaction-state styles. Build with ui.Style() and compose with Merge.
anyView sourceChildrenPartChildren—
Content mounted inside the component. Compound child callbacks run after the parent context exists.
PartChildrenView sourceDisabledany—
Prevents activation and exposes the disabled state to accessibility. Compound parts inherit a disabled root.
anyView sourceRolestring—
FocusOnPointerany—
Groupany—
AriaLabelany—
Accessible name, especially for icon-only controls or controls without a visible label.
anyView sourceTabIndex*float64—
Controls sequential keyboard focus order. Omit to retain the component’s default focus behavior.
*float64View sourceOnClickfunc(*native.Event)—
Called after QuickGUI resolves an activation, including supported keyboard activation.
func(*native.Event)View sourceOnDoubleClickfunc(*native.Event)—
Callback for double click. The signature below lists the event payload.
func(*native.Event)View sourceOnContextMenufunc(*native.Event)—
Callback for context menu. The signature below lists the event payload.
func(*native.Event)View sourceOnPointerfunc(*native.Event)—
OnMouseEnterfunc(*native.Event)—
Callback for mouse enter. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseLeavefunc(*native.Event)—
Callback for mouse leave. The signature below lists the event payload.
func(*native.Event)View sourceOnMouseDownfunc(*native.Event)—
OnMouseUpfunc(*native.Event)—
OnKeyDownfunc(*native.Event)—
OnKeyUpfunc(*native.Event)—
OnFocusfunc(*native.Event)—
OnBlurfunc(*native.Event)—
Element
View sourcepart.Child(content).Style(style)Every part returns a fluent element. Strings, numbers, elements, and deferred child factories compose directly.
ChildChild(child any) *Element—
Child appends content and returns this element. Content can be an element, native node, scalar, accessor, or node-returning construction callback.
Child(child any) *ElementView sourceChildrenChildren(children ...any) *Element—
Children appends multiple children in order without replacing existing content. It also accepts []any, []*Element, and []*native.Node slices as arguments. Read the retained child nodes through element.Node.Children.
Children(children ...any) *ElementView sourceStyleStyle(style StyleBuilder) *Element—
Style merges a reusable style. Scalar accessors retain independent native bindings.
Style(style StyleBuilder) *ElementView sourceOnClickOnClick(handler func()) *Element—
OnClick handles a click without an unused event parameter.
OnClick(handler func()) *ElementView sourceRefRef(handler func(*native.Node)) *Element—
Ref exposes the native handle once at this point in the declaration chain.
Ref(handler func(*native.Node)) *ElementView source