Number Showcase

revisit perhaps after conditions/function part

Component Documentation

Component Name

Number

Builder Function Name

create_number_manager

Description

Displays and formats a numeric value with options for rounding, shorthand notation, separators, dynamic coloring based on value, and an optional progress bar.

Use like example

Config

PropertyTypeDefaultDescription
valnumber or null

Initial numeric value to display. If null, displays as empty or default.

roundstring

Determines the rounding method applied to the value.

round_bynumber

Value to round to when `round` is 'nearest', 'floor', or 'ceil'.

precisionnumber

Number of significant digits when `round` is 'precision'.

shorthandstring

Applies shorthand notation to the number, adding suffixes like K, M, B, etc.

separatorsstring

Formats the number with thousands and decimal separators based on locale.

is_percentageboolean

false

If true, appends a '%' sign to the displayed number.

is_dynamic_colorboolean

false

If true, changes the color of the number based on its value relative to start and end values.

start_valuenumber

Starting value for dynamic color calculations.

end_valuenumber

Ending value for dynamic color calculations.

start_colorobject

Starting color in Hue-Chroma format for dynamic color calculations (e.g., { h: 10, c: 10 }).

end_colorobject

Ending color in Hue-Chroma format for dynamic color calculations (e.g., { h: 350, c: 10 }).

base_colorobject

Base color used when dynamic color is not enabled (e.g., { h: 10, c: 10 }).

is_progress_barboolean

false

If true, displays the number as part of a progress bar.

is_hide_numberboolean

false

If true, hides the numeric text display.

Methods

MethodDescriptionParametersReturns
init

Initializes the number formatting based on configuration, including rounding, shorthand, separators, dynamic color, and progress bar calculations.

No Params

round_value

Rounds the numeric value based on the specified method and parameters.

No Params

apply_shorthand

Applies shorthand notation to the number, converting large numbers into K, M, B, etc.

No Params

format_separators

Formats the number with thousands and decimal separators based on the specified locale.

No Params

set_val

Sets a new value for the number and updates its formatting accordingly.

No Params

set_loading_i

Sets the thumb index to display a loading state.

No Params

set_hovered_i

Sets the thumb index that is currently hovered.

No Params

set_error_i

Sets the thumb index that has an error.

No Params

set_min

Updates the slider's minimum bound.

No Params

set_max

Updates the slider's maximum bound.

No Params

set_step

Updates the slider's step increment value.

No Params

set_thumbs

Updates the positions of the thumbs based on the current values.

No Params

Returned Properties

PropertyTypeDescription
valobject

Formatted value with properties including val, val_text, suffix, font_weight, font_color, hue, chroma, and percentage_fill.

icon
Sponsored byContibase