ObjectUIObjectUI
Fields

Percent Field

Percentage input with automatic conversion and formatting

The Percent Field component provides a percentage input that automatically converts between stored decimal values (0-1) and displayed percentage values (0-100).

Basic Usage

Basic Percent Field

%

With Precision

With Decimal Precision

%

Required Field

Required Percent

%

Read-Only

Read Only Percent

87.50%

Field Schema

interface PercentFieldSchema {
  type: 'percent';
  name: string;                  // Field name/ID
  label?: string;                // Field label
  placeholder?: string;          // Placeholder text
  value?: number;                // Default value (0-1 decimal)
  required?: boolean;            // Is field required
  readonly?: boolean;            // Read-only mode
  disabled?: boolean;            // Disabled state
  className?: string;            // Additional CSS classes
  
  // Validation
  precision?: number;            // Decimal places (default: 2)
  min?: number;                  // Minimum value (0-1)
  max?: number;                  // Maximum value (0-1)
}

Value Conversion

The percent field handles automatic conversion:

  • Stored Value: Decimal between 0 and 1 (e.g., 0.75)
  • Display Value: Percentage between 0 and 100 (e.g., 75%)

Example:

// Stored in database: 0.85
// Displayed to user: 85%
// User enters: 90
// Stored as: 0.90

Cell Renderer

In tables/grids, values are formatted with percentage symbol:

import { PercentCellRenderer } from '@object-ui/fields';

// Renders: 85.50%

Use Cases

  • Progress Tracking: Task completion, project progress
  • Analytics: Conversion rates, success metrics
  • Financial Data: Interest rates, discount percentages
  • Statistics: Performance scores, efficiency ratings

On this page