Menus & navigation JS behaviour

Sort pill

A quick sort pill: the chosen label rolls inside the trigger and its panel is a native popover — placing and dismissing come from the core.

Real scenarios

The component as it is used in a product — not a specimen grid.

Sorting today’s orders

The panel is a native popover — Escape and outside clicks close it, arrows walk the choices. Each pick lands in Livewire and the rows re-render in their new order.

4 orders
  • #1042 Ava Karimi 8 minutes ago 1,280,000 tomans paid
  • #1041 Soheil Nouri 2 hours ago 490,000 tomans shipping
  • #1040 Mona Fischer 6 hours ago 2,350,000 tomans queued
  • #1039 Kian Rajaee 2 days ago 760,000 tomans failed

Important props

Important props
Prop Type Default What it does
options array [] Key → a label, or an array with «label» and «icon».
value / wire:model string null The active option; also posts through a hidden input.
label / align string «مرتب‌سازی» · start The trigger label and the panel alignment (start · center · end).

Snippet

<x-nx::sort-pill label="ترتیب" :value="$state['sort'] ?? 'recent'" wire:model.live="state.sort" :options="[
    'recent' => ['label' => 'تازه‌ترین', 'icon' => 'sparkles'],
    'oldest' => 'قدیمی‌ترین',
    'amount' => ['label' => 'بیشترین مبلغ', 'icon' => 'trend-up'],
]" />