Convert Figma logo to code with AI

barvian logonumber-flow

An animated number component for React, Vue, and Svelte.

5,026
79
5,026
5

Top Related Projects

A set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️

Vue drag-and-drop component based on Sortable.js

29,843

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.

A set of higher-order components to turn any list into an animated, accessible and touch-friendly sortable list✌️

Beautiful and accessible drag and drop for lists with React

Quick Overview

Number Flow is a JavaScript library for creating interactive number input fields with smooth animations and formatting. It provides a user-friendly way to input and display numerical values, supporting various formats and customization options.

Pros

  • Smooth animations for a polished user experience
  • Customizable formatting options for different number types (e.g., currency, percentages)
  • Easy integration with existing form inputs
  • Lightweight and dependency-free

Cons

  • Limited browser support (modern browsers only)
  • Requires JavaScript to function, which may not be ideal for all use cases
  • Documentation could be more comprehensive
  • No built-in localization support for different number formats

Code Examples

Creating a basic number input with formatting:

import NumberFlow from 'number-flow';

const input = document.querySelector('input');
const numberFlow = new NumberFlow(input, {
  format: '0,0.00'
});

Setting up a currency input with a prefix:

const currencyInput = new NumberFlow(document.getElementById('price'), {
  format: '$0,0.00',
  prefix: '$'
});

Creating a percentage input with custom step:

const percentInput = new NumberFlow(document.getElementById('percent'), {
  format: '0.00%',
  suffix: '%',
  step: 0.01
});

Getting Started

  1. Install the library using npm:
npm install number-flow
  1. Import and initialize NumberFlow in your JavaScript file:
import NumberFlow from 'number-flow';

const input = document.querySelector('input[type="number"]');
const numberFlow = new NumberFlow(input, {
  format: '0,0.00',
  min: 0,
  max: 1000,
  step: 0.01
});
  1. Ensure your HTML includes the input element:
<input type="number" id="myInput" />

That's it! Your number input is now enhanced with Number Flow's features.

Competitor Comparisons

A set of vue mixins to turn any list into an animated, touch-friendly, sortable list ✌️

Pros of vue-slicksort

  • Specifically designed for Vue.js, offering seamless integration with Vue components
  • Provides a more comprehensive set of features for sorting and reordering elements
  • Offers better documentation and examples for implementation

Cons of vue-slicksort

  • More complex setup and configuration compared to the simpler number-flow
  • Larger file size and potentially higher performance overhead
  • May be overkill for basic number sorting tasks

Code Comparison

number-flow:

import NumberFlow from 'number-flow'

const flow = new NumberFlow()
flow.add(5)
flow.add(3)
console.log(flow.getNumbers()) // [3, 5]

vue-slicksort:

<template>
  <SlickList v-model="items" :axis="'y'" @input="onSort">
    <SlickItem v-for="item in items" :key="item.id">
      {{ item.text }}
    </SlickItem>
  </SlickList>
</template>

The code comparison shows that number-flow is more focused on simple number sorting, while vue-slicksort provides a more comprehensive solution for sorting and reordering various types of elements within a Vue.js application.

Vue drag-and-drop component based on Sortable.js

Pros of Vue.Draggable

  • More comprehensive drag-and-drop functionality, supporting complex list operations
  • Extensive documentation and community support
  • Integration with Vue.js ecosystem

Cons of Vue.Draggable

  • Larger bundle size due to more features
  • Steeper learning curve for basic implementations
  • May be overkill for simple number input scenarios

Code Comparison

Vue.Draggable:

<template>
  <draggable v-model="myArray" group="people" @start="drag=true" @end="drag=false">
    <div v-for="element in myArray" :key="element.id">{{ element.name }}</div>
  </draggable>
</template>

number-flow:

<template>
  <number-flow v-model="myNumber" :min="0" :max="100" :step="1" />
</template>

Vue.Draggable offers more flexibility for complex drag-and-drop scenarios, while number-flow provides a simpler, more focused solution for number input. Vue.Draggable is better suited for applications requiring extensive list manipulation, whereas number-flow excels in scenarios where a streamlined number input with visual feedback is needed. The code comparison highlights the difference in complexity and use cases between the two libraries.

29,843

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.

Pros of Sortable

  • More comprehensive and feature-rich library for drag-and-drop sorting
  • Supports multiple frameworks and environments (vanilla JS, React, Angular, Vue)
  • Extensive documentation and active community support

Cons of Sortable

  • Larger file size and potentially more complex implementation
  • May include unnecessary features for simpler sorting tasks

Code Comparison

Number-flow:

import NumberFlow from 'number-flow';

const numberFlow = new NumberFlow(document.querySelector('.number-flow'));
numberFlow.init();

Sortable:

import Sortable from 'sortablejs';

const el = document.getElementById('items');
const sortable = Sortable.create(el, {
  animation: 150,
  ghostClass: 'blue-background-class'
});

Key Differences

  • Number-flow is specifically designed for number-based sorting, while Sortable is a more general-purpose sorting library
  • Sortable offers more customization options and advanced features
  • Number-flow has a simpler API and may be easier to implement for basic number sorting tasks

Use Cases

  • Choose Number-flow for straightforward number sorting with minimal setup
  • Opt for Sortable when you need advanced sorting capabilities, cross-framework support, or extensive customization options

A set of higher-order components to turn any list into an animated, accessible and touch-friendly sortable list✌️

Pros of react-sortable-hoc

  • More comprehensive and feature-rich library for sortable components
  • Supports both horizontal and vertical sorting
  • Offers better performance for large lists due to virtualization

Cons of react-sortable-hoc

  • Steeper learning curve due to more complex API
  • Requires more setup and configuration for basic use cases
  • Larger bundle size compared to simpler alternatives

Code Comparison

number-flow:

import NumberFlow from 'number-flow';

<NumberFlow
  numbers={[1, 2, 3, 4, 5]}
  onChange={handleChange}
/>

react-sortable-hoc:

import { SortableContainer, SortableElement } from 'react-sortable-hoc';

const SortableItem = SortableElement(({value}) => <li>{value}</li>);
const SortableList = SortableContainer(({items}) => {
  return (
    <ul>
      {items.map((value, index) => (
        <SortableItem key={`item-${index}`} index={index} value={value} />
      ))}
    </ul>
  );
});

Summary

react-sortable-hoc is a more powerful and flexible solution for creating sortable components in React applications. It offers advanced features and better performance for complex use cases. However, it comes with a steeper learning curve and requires more setup compared to simpler libraries like number-flow. The choice between the two depends on the specific requirements of your project and the level of customization needed.

Beautiful and accessible drag and drop for lists with React

Pros of react-beautiful-dnd

  • More comprehensive and feature-rich drag-and-drop solution
  • Extensive documentation and community support
  • Optimized for performance with large lists and complex interactions

Cons of react-beautiful-dnd

  • Larger bundle size and potential overhead for simpler use cases
  • Steeper learning curve due to more complex API
  • Less suitable for specific number-based sorting scenarios

Code Comparison

number-flow:

import NumberFlow from 'number-flow';

<NumberFlow
  numbers={[1, 2, 3, 4, 5]}
  onChange={handleChange}
/>

react-beautiful-dnd:

import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';

<DragDropContext onDragEnd={handleDragEnd}>
  <Droppable droppableId="list">
    {(provided) => (
      <ul {...provided.droppableProps} ref={provided.innerRef}>
        {items.map((item, index) => (
          <Draggable key={item.id} draggableId={item.id} index={index}>
            {(provided) => (
              <li ref={provided.innerRef} {...provided.draggableProps} {...provided.dragHandleProps}>
                {item.content}
              </li>
            )}
          </Draggable>
        ))}
        {provided.placeholder}
      </ul>
    )}
  </Droppable>
</DragDropContext>

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

https://github.com/user-attachments/assets/5b99dbe6-e0eb-44e8-9c0d-ed4f00aff48d

NumberFlow

An animated number component for React, Vue, and Svelte.

NPM Version Follow @mbarvian

Documentation

For full documentation, visit number-flow.barvian.me.

Sponsors

Frigade logo

NumberFlow is proudly sponsored by Frigade, a developer tool for building better product onboarding: guided tours, getting started checklists, announcements, and more.

NPM DownloadsLast 30 Days