Skip to main content
NpsField ← Back to Table of Contents

Summary

Single-select survey scale for Net Promoter Score (0–10), CSAT, satisfaction ratings, and textual Likert scales. Three visual variants share one API: pills (sliding segment control), segments (full-width bordered bar), and emojis (icon or image rings with labels). Works with all standard Filament field APIs: required(), disabled(), hidden(), live(), afterStateUpdated(), validation rules, etc.

Variants at a glance


Basic usage

Standard NPS (0–10)

Filament resource form

Color-coded NPS (Detractor / Passive / Promoter)


State & validation

Stored value

State is the option key from options() — not the display label.

Default: empty initial state

The field defaults to null. Nothing is selected until the user picks an option. All variants support this.
Pre-fill when editing:

Validation rules (built-in)

Optional fields — deselect on second click

When the field is not required(), clicking the already selected option clears the value back to null. Required fields always keep one selection.

Custom scales

5-point CSAT (1–5)

3-point quick rating

Textual Likert scale (string keys)

Dynamic options with a closure


Variant: Pills (default)

Sliding pill indicator on a gray track — same visual language as SegmentControl. Best for numeric scales and compact layouts.

Sizes

See Control size (sm, md, lg).

Rounding

Per-field rounding() overrides the global default from config/filament-flex-fields.php (ui.field_rounding).

Variant: Segments

Full-width bordered bar with vertical dividers between options. Ideal for 0–10 NPS and multi-option Likert rows.

Segments with sizes and rounding


Variant: Emojis

Circular rings with a visual inside each option and a text label below. Three ways to supply visuals (priority order):
  1. icons() — Filament icon strings (Heroicon, Gravity, Blade Icons, …)
  2. emojiImages() — custom image URLs
  3. Bundled webp — for numeric keys 0–4 when neither of the above is set

Bundled emoji images (5-point mood scale)

Bundled assets ship in the package (resources/dist/assets/nps-field/emojis/0.webp … 4.webp) and are published to public/filament-flex-fields-assets/ via php artisan filament:assets.

Custom Gravity / Heroicon icons

Heroicon example:
When icons() is set for a key, it overrides bundled webp for that key.

Custom image URLs

Emoji sizes


Color coding & custom colors

Built-in NPS color coding

Custom per-option background colors

Map Filament semantic names, hex, or rgb to option keys:
With hex:

Custom selected text colors

When colorCoded() is enabled, built-in detractor/passive/promoter colors apply unless you override with colors() / textColors().

Disabled options

Disable individual keys without disabling the whole field:
Dynamic:
Combine with field-level disabled():

Edge labels

Show helper text under the left and right ends of the scale:
Only the extremes are labeled — option labels come from options() values.

Complete configuration API

All methods accept Closure unless noted.

Public helper methods


Real-world examples

Post-purchase survey (CreateRecord)

Wizard step — optional NPS

Live reactive form

Infolist / table display (manual)

NpsField is a form component. Display stored values in tables with TextColumn or a custom column:

Database & Eloquent

Migration

Model


Assets & deployment

Fields resolve bundled emoji URLs via FlexFieldAssets::assetUrl() with automatic ?v=filemtime cache busting. On upgrade, run php artisan filament:assets (or use a Composer post-autoload-dump hook). See the main README Upgrading section.

Accessibility

  • Root element uses role="radiogroup" with aria-label from the field label.
  • Each option is a <label role="radio"> with aria-checked and keyboard support (Enter / Space).
  • Hidden native <input type="radio"> elements preserve form semantics.
  • Focus visible outline on keyboard navigation.
  • Disabled options expose aria-disabled="true".

Performance

Stylesheet dependency graph: nps-field → segment-control (pills variant only).

Playground

/admin/flex-fields-playground/nps-field See Playground for setup.

CSS classes (reference)

Pills variant reuses fff-segment-control, fff-segment-track, fff-segment-indicator, and fff-segment-item from SegmentControl.