Live preview

Interactive example

Loading example…

Usage

Import the component and its manager, then make it your own.

ComponentNumber
Managercreate_number_manager

svelte

<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Number, create_number_manager } from "sveltekit-ui"

  const manager = create_number_manager({
    val: 12500,
    separators: "thousands_commas_period",
  })
</script>

<p>Monthly visitors: <Number {manager} /></p>

API reference

Configure the manager, call its methods, and read its reactive state.

15 entries in configuration

PropertyTypeDefaultDescription
valnumber or null nullInitial numeric value to display. If null, displays as empty or default.
roundstring nullDetermines the rounding method applied to the value.
round_bynumber nullValue to round to when `round` is 'nearest', 'floor', or 'ceil'.
precisionnumber nullNumber of significant digits when `round` is 'precision'.
shorthandstring nullApplies shorthand notation to the number, adding suffixes like K, M, B, etc.
separatorsstring nullFormats the number with thousands and decimal separators based on locale.
is_percentageboolean falseIf true, appends a '%' sign to the displayed number.
is_dynamic_colorboolean falseIf true, changes the color of the number based on its value relative to start and end values.
start_valuenumber nullStarting value for dynamic color calculations.
end_valuenumber nullEnding value for dynamic color calculations.
start_colorobject nullStarting color in Hue-Chroma format for dynamic color calculations (e.g., { h: 10, c: 10 }).
end_colorobject nullEnding color in Hue-Chroma format for dynamic color calculations (e.g., { h: 350, c: 10 }).
base_colorobject nullBase color used when dynamic color is not enabled (e.g., { h: 10, c: 10 }).
is_progress_barboolean falseIf true, displays the number as part of a progress bar.
is_hide_numberboolean falseIf true, hides the numeric text display.