AttRibutes
Input Counter
What is this page about?

Attributes, by Finsweet, offers a free series of Solutions that provide essential features to improve your Webflow websites.

Input Counter

Increment and decrement (+ and -) counter in a Webflow Form.

Input Counter • Flash Card

Copy Script

For advanced users familiar with this solution. Includes all attributes from this page. Click on attributes and values to copy them.

Required attributes

Input

The form input the user can increment and decrement the value of.

fs-inputcounter-element
=
"
input
"

Increment

The increment (or plus) button.

fs-inputcounter-element
=
"
increment
"

Decrement

The decrement (or minus) button.

fs-inputcounter-element
=
"
decrement
"

Optional attributes

Clear

Clear counter to initial vlaue.

fs-inputcounter-element
=
"
clear
"

Initial Value

Set an initial value for the input. Add to the element with fs-inputcounter-element = "input"

fs-inputcounter-initial
=
"
VALUE
"

Arrows

Show the native number arrows. Add to the element with fs-inputcounter-element = "input"

fs-inputcounter-showarrows
=
"
true
"

min

The minimum value that can be entered to the input. Add to the element with fs-inputcounter-element = "input"

min
=
"
VALUE
"

max

The maximum value that can be entered to the input. Add to the element with fs-inputcounter-element = "input"

max
=
"
VALUE
"

step

The "step" between each increment and decrement click. Add to the element with fs-inputcounter-element = "input"

step
=
"
VALUE
"
1

Add this <script> inside the <head> tag of your page or project

This script is the universal Attribute script: you only need to include it once, even if you have multiple Attribute solutions on the page. Learn more .

<script async type="module"
src="https://cdn.jsdelivr.net/npm/@finsweet/attributes@2/attributes.js"
fs-inputcounter
></script>

Copy Script
2

Add these required attributes to the elements

Input

This is the element that hold the current value
fs-inputcounter-element
=
"
input
"

The form input the user can increment and decrement the value of.

Use the "Number" input type. If "Number" is not set in the input settings, Attributes will be automatically convert the input to type="number".

By default, the native browser input arrows are hidden using custom CSS. These are the small "up" and "down" arrows inside the number input.

Add this attribute:
Name
fs-inputcounter-element
Copy
Value
input
Copy
Elements allowed:
Input
WHERE TO ADD IT

Increment

Defines the increment (+) trigger
fs-inputcounter-element
=
"
increment
"

The increment (or plus) button.

Clicking this button will add (1) to the current input value.

Add this attribute:
Name
fs-inputcounter-element
Copy
Value
increment
Copy
Elements allowed:
Div Block
WHERE TO ADD IT

Decrement

Defines the decrement (-) trigger
fs-inputcounter-element
=
"
decrement
"

The decrement (or minus) button.

Clicking this button will subtract (1) from the current input value.

Add this attribute:
Name
fs-inputcounter-element
Copy
Value
decrement
Copy
Elements allowed:
Div Block
3

Publish your project! Done, easy right?

Check more elements and settings below
Optional

Add options

Clear

Trigger to clear the value in the input
fs-inputcounter-element
=
"
clear
"

Optionally add a clear button that will "clear" the current value of the input.

The value will be set to the initial value.

Add this attribute:
Name
fs-inputcounter-element
Copy
Value
clear
Copy
Elements allowed:
div block icon
Div Block

Initial

Set an initial value for the input
fs-inputcounter-initial
=
"
0
"

Optionally set an initial value for the input.

For example, setting a value of "100" will set the initial value of the input to "100". Setting a value of "0" will set the initial value to "0".

The default functionality is no initial value. By not adding this attribute on the input, the input will have no value.

Add this attribute:
Name
fs-inputcounter-initial
Copy
Value
0
Copy
Add it to the element with
fs-inputcounter-element = "input"

Show Arrows

Shows the browser up/down arrows inside the number input
fs-inputcounter-showarrows
=
"
true
"

By default, Attributes hides the native arrows inside the number input. This is to avoid two UI options for incrementing and decrementing the value.

To show the native number arrows, apply this attribute to the input.

Add this attribute:
Name
fs-inputcounter-showarrows
Copy
Value
true
Copy
Add it to the element with
fs-inputcounter-element = "input"
Check more elements and settings below
Optional

Apply native HTML number attributes

min

Minimun value of the input
min
=
"
VALUE
"

The minimum value that can be entered to the input.

Add this attribute:
Name
min
Copy
Value
VALUE
Copy
Add it to the element with
fs-inputcounter-element = "input"

max

Maximum value of the input
max
=
"
VALUE
"

The maximum value that can be entered to the input.

Add this attribute:
Name
max
Copy
Value
VALUE
Copy
Add it to the element with
fs-inputcounter-element = "input"

step

The amount of numbers counted per increment or decrement
step
=
"
VALUE
"

The "step" between each increment and decrement click.

For example, if step is set to 2, and the input is at 0, the first increment click will increase the input to 2. The second click will increase the value to 4. The third click will increase the value to 6.

Add this attribute:
Name
step
Copy
Value
VALUE
Copy
Add it to the element with
fs-inputcounter-element = "input"
Optional

Add more

Instances

Define an instance on a common parent wrapper

fs-inputcounter-instance
=
"
IDENTIFIER
"

If you wish to create multiple instances of this solution on the same page, please follow the steps below:

  1. Select a wrapper parent that contains all the elements of an instance.
  2. Add an -instance attribute to it, with a unique value.
  3. Repeat for every instance.
Add this attribute:
Name
fs-inputcounter-instance
Copy
Value
IDENTIFIER
Copy
Examples:
fs-inputcounter-instance = "1"
fs-inputcounter-instance = "2"
fs-inputcounter-instance = "days"
fs-inputcounter-instance = "rooms"
Learn more ways to set up multiple instances and how it works