Skip to main content
PriceRangeField ← Back to Table of Contents

Summary

Dual-handle price range slider with histogram backdrop, min/max numeric inputs, and currency prefix.
ClassBjanczak\FilamentFlexFields\Filament\Forms\Components\PriceRangeField
State type`array<min: intfloat, max: intfloat>`
Model cast'price_range' =&gt; 'array' or 'json'
FieldTypeprice_range
Example state: ['min' =&gt; 100, 'max' =&gt; 1124].

Basic usage

use Bjanczak\FilamentFlexFields\Filament\Forms\Components\PriceRangeField;

PriceRangeField::make('price_range')
    ->label('Price range')
    ->min(0)
    ->max(5000)
    ->step(1)
    ->prefix('$')
    ->histogram([30, 74, 85, 36, 98])
    ->showInputs()
    ->variant('bordered')
    ->default(['min' => 100, 'max' => 1124]);

Validation

Built-in rules via custom validator:
FailureTranslation key
Non-numeric min/maxprice_range.invalid
Values outside boundsprice_range.out_of_bounds
min > maxprice_range.min_greater_than_max

Configuration API

min(int|float|Closure $min = 0) / max(int|float|Closure $max = 1000)

Range boundaries for slider and inputs.
PriceRangeField::make('field_name')
    ->min(1)
    ->max(10);

step(int|float|Closure $step = 1)

Snap increment.
PriceRangeField::make('field_name')
    ->step(1);

integer(bool|Closure $condition = true)

Restrict to whole numbers. Default: true.
PriceRangeField::make('field_name')
    ->integer(true);

decimalPlaces(int|Closure|null $places)

Fixed decimal precision when not integer.
PriceRangeField::make('field_name')
    ->decimalPlaces(2);

prefix(string|Closure|null $prefix) / withoutPrefix()

Currency or unit prefix shown in inputs. Default config: $.
PriceRangeField::make('field_name')
    ->prefix('value')
    ->withoutPrefix();

variant(string|Closure $variant)

ValueDescription
borderedBordered track. Default.
flatFlat styling.
fadedSubtle faded track.
PriceRangeField::make('field_name')
    ->variant('primary');

showInputs(bool|Closure $condition = true)

Min/max numeric inputs below the slider. Default: true.
PriceRangeField::make('field_name')
    ->showInputs(true);

minInputLabel(string|Closure|null $label) / maxInputLabel(string|Closure|null $label)

Accessible labels for the numeric inputs.
PriceRangeField::make('field_name')
    ->minInputLabel('value')
    ->maxInputLabel('value');

histogram(array|Closure $heights)

Bar heights (8–100) for the background chart. Uses a built-in default pattern when omitted.
PriceRangeField::make('field_name')
    ->histogram(['value1', 'value2']);

size(string|ControlSize|Closure $size)

See Control size.
PriceRangeField::make('field_name')
    ->size('md');

State normalization

On hydrate and dehydrate, values are clamped to [min, max], stepped, and min is never greater than max.

FlexField schema config

Config keyMaps to
minmin()
maxmax()
stepstep()
sizesize()
variantvariant()
prefixprefix()
histogramhistogram()
integerinteger()
decimal_placesdecimalPlaces()
show_inputsshowInputs()
min_input_labelminInputLabel()
max_input_labelmaxInputLabel()

Public helper methods

MethodReturnsDescription
normalizeState(array $state)array&lt;min, max&gt;Clamps min/max to bounds, applies step rounding, ensures min ≤ max.
defaultHistogram()list&lt;float&gt;Built-in 32-bar histogram heights (8–100) used when histogram() is empty.
hasPrefix()boolWhether a currency/unit prefix is configured (not withoutPrefix()).