Number

Add a Number property to your component so designers can input numeric values.

Syntax

1// Prop definition
2props.Number({
3 name: string,
4 group?: string,
5 tooltip?: string,
6 defaultValue?: number,
7 min?: number,
8 max?: number,
9 decimals?: number,
10})
11
12// Prop value
13number

Prop definition

Define the Number prop in your Webflow code component with a name. Optionally, you can add a group, tooltip text, and a default value, as well as numeric constraints like min, max, and decimals.

1props.Number({
2 name: string,
3 group?: string,
4 tooltip?: string,
5 defaultValue?: number,
6 min?: number,
7 max?: number,
8 decimals?: number,
9})

Properties

  • name: The name for the property.
  • group: The group for this property. (optional)
  • tooltip: The tooltip for the property. (optional)
  • defaultValue: Default value for all component instances. (optional)
  • min: Minimum value allowed. (optional)
  • max: Maximum value allowed. (optional)
  • decimals: Maximum number of decimal places. (optional)

Example

MyComponent.webflow.tsx
1import { declareComponent } from '@webflow/react';
2import { props } from '@webflow/data-types';
3import { MyComponent } from "./MyComponent";
4
5export default declareComponent(MyComponent, {
6 name: "MyComponent",
7 description: "A component with a Number property",
8 props: {
9 count: props.Number({
10 name: "Item Count",
11 group: "Settings",
12 defaultValue: 5,
13 min: 1,
14 max: 100,
15 decimals: 0
16 })
17 }
18});

Prop value

The Number prop provides a numeric value to your React component.

PropType.Number
1number

Properties

  • n/a

Webflow properties panel

Number property in the Webflow panel

Example

MyComponent.tsx
1import React from "react";
2
3interface MyComponentProps {
4count?: number;
5}
6
7export const MyComponent = ({ count }: MyComponentProps) => {
8return (
9 <div className="counter">
10 <span>Count: {count}</span>
11 </div>
12);
13}

When to use

Use a Number prop when you want designers to:

  • Set numeric values like counts, sizes, or durations
  • Control values within specific ranges
  • Provide sensible defaults for components
  • Limit decimal precision for cleaner data

Best practices

  • Set appropriate min/max values for your use case
  • Use decimals: 0 for whole numbers, 1-2 for currency/percentages
  • Provide meaningful default values
  • Consider the range designers will need