/*!
MIT License
Copyright (c) 2026 Jaison
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {AnimatedNumber,Button} from '@bld8/ui';
export default function Metric(){const [value,setValue]=useState(2400);return <section><h3>Illustrative balance</h3><p style={{fontSize:36}}><AnimatedNumber label="Balance" value={value} format={{style:'currency',currency:'AUD',maximumFractionDigits:0}}/></p><div className="actions"><Button onClick={()=>setValue(previous=>previous+125)}>Add 125</Button><Button variant="secondary" onClick={()=>setValue(previous=>previous-250)}>Subtract 250</Button></div><p className="bui-hint">A local example value, with no account or payment connection.</p></section>;}
/*!
MIT License
Copyright (c) 2026 Jaison
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import '@bld8/ui/styles.css';
import {useState} from 'react';
import {AnimatedNumber,Button} from '@bld8/ui';
export default function FiniteRange(){const [positive,setPositive]=useState(false);return <section><h3>A finite numerical range</h3><p><AnimatedNumber label="Scientific value" value={positive?Number.MAX_VALUE:-Number.MAX_VALUE} format={{notation:'scientific',maximumFractionDigits:3}}/></p><Button onClick={()=>setPositive(value=>!value)}>Change sign</Button><p className="bui-hint">Finite endpoints can have an overflowing difference. This case settles without invalid intermediate values.</p></section>;}
In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.
API & behaviour
Visual numbers interpolate with interruptible easing. The accessible text holds the committed target and is not a live region. Invalid numbers display an em dash. Formatting supports Intl.NumberFormat; reduced motion and offscreen updates settle directly.
AnimatedNumber
AnimatedNumber public properties
Prop
Type
Default
valueRequired
number
—
className
string | undefined
—
duration
number | undefined
.45
format
Intl.NumberFormatOptions | undefined
—
label
string | undefined
—
locale
string | undefined
—
Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.
Related controls
Notes to self
Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.