{{-- Tabs after the WAI-ARIA tabs pattern, because TallStackUI's ties its panels to ids that do not exist and has no arrow keys. Only the selected tab is in the tab order; arrow keys, Home and End move between the tabs and select them. Panels are children with the same id. $tabs: ['key' => 'title', ...] in display order. --}} @props([ 'id', 'label', 'tabs', 'selected' => null, ]) @php $selected ??= array_key_first($tabs); @endphp
class('space-y-3') }} x-data="{ selected: @js($selected), select(key) { this.selected = key; this.$nextTick(() => document.getElementById(@js($id) + '-tab-' + key)?.focus()); }, move(event) { const keys = @js(array_keys($tabs)); const index = keys.indexOf(this.selected); const next = { ArrowRight: index + 1, ArrowLeft: index - 1, Home: 0, End: keys.length - 1 }[event.key]; if (next === undefined) { return; } event.preventDefault(); this.select(keys[(next + keys.length) % keys.length]); }, }" >
@foreach ($tabs as $key => $title) @endforeach
{{ $slot }}