# Liquid Tabs

A notifications card with folder-style tabs. The card body and the active tab sit under one goo filter, so the tab reads as part of the card and flows into it as it slides to another label. Rows leave toward the tab you came from and arrive from the one you went to. Click a row to select it; its avatar inverts. The chevron opens more tabs, and the one you pick replaces the third tab. Arrow keys move between tabs.

<demo-liquid-tabs>



</demo-liquid-tabs>

## Installation

```bash
npx shadcn-vue@latest add "https://nxui.geoql.in/r/liquid-tabs.json"
```

## Usage

```vue
<script setup lang="ts">
  import { computed, ref } from 'vue';
  import LiquidTabs from '~/components/ui/liquid-tabs/LiquidTabs.vue';
  import type {
    LiquidTabsItem,
    LiquidTabsTab,
  } from '~/components/ui/liquid-tabs/types';

  const colorMode = useColorMode();
  const theme = computed(() => (colorMode.value === 'dark' ? 'dark' : 'light'));
  const tab = ref('inbox');

  const tabs: LiquidTabsTab[] = [
    {
      key: 'inbox',
      label: 'Inbox',
      rows: [
        {
          id: 'i1',
          title: 'Build passed',
          subtitle: 'main · 2m 14s',
          time: '09:12',
          icon: 'lucide:circle-check',
        },
        {
          id: 'i2',
          title: 'Deploy',
          subtitle: 'Preview ready',
          time: '09:20',
          icon: 'lucide:rocket',
        },
      ],
    },
  ];

  function onSelect(item: LiquidTabsItem, key: string) {
    console.log(key, item.id);
  }
</script>

<template>
  <LiquidTabs
    v-model:tab="tab"
    :tabs="tabs"
    :rows="2"
    :corner="20"
    :theme="theme"
    @select="onSelect"
  />
</template>
```

Without `tabs` and `overflow` the card shows its built-in notification data: All and Mentions up front, and System, Archived and Requests in the menu. Setting `tab` to an overflow key makes that tab the third one.

## Props

<table>
<thead>
  <tr>
    <th>
      Prop
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        tab
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      first tab key
    </td>
    
    <td>
      <code>
        v-model
      </code>
      
      . The active tab key.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        corner
      </code>
    </td>
    
    <td>
      <code>
        number
      </code>
    </td>
    
    <td>
      <code>
        20
      </code>
    </td>
    
    <td>
      Corner radius of the card in px, clamped to 0–40.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        rows
      </code>
    </td>
    
    <td>
      <code>
        2 | 3 | 4
      </code>
    </td>
    
    <td>
      <code>
        4
      </code>
    </td>
    
    <td>
      How many rows each tab shows. The card height follows it.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        theme
      </code>
    </td>
    
    <td>
      <code>
        'light' | 'dark'
      </code>
    </td>
    
    <td>
      <code>
        'light'
      </code>
    </td>
    
    <td>
      Colour theme. Pass your site's colour mode.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        tabs
      </code>
    </td>
    
    <td>
      <code>
        LiquidTabsTab[]
      </code>
    </td>
    
    <td>
      All, Mentions
    </td>
    
    <td>
      The fixed leading tabs.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        overflow
      </code>
    </td>
    
    <td>
      <code>
        LiquidTabsTab[]
      </code>
    </td>
    
    <td>
      System, Archived…
    </td>
    
    <td>
      Tabs in the chevron menu. The picked one becomes the last tab.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        label
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        'Notifications'
      </code>
    </td>
    
    <td>
      Accessible name of the tab list.
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        class
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        ''
      </code>
    </td>
    
    <td>
      Extra classes for the root element.
    </td>
  </tr>
</tbody>
</table>

A `LiquidTabsTab` has a `key`, a `label`, `rows` and an optional `selected` row id. Each row has an `id`, `title`, `subtitle`, `time` and an `icon`: an Iconify name such as `lucide:inbox`, or one of the built-in glyphs `dome`, `shield-outline` and `shield-notch`.

## Events

<table>
<thead>
  <tr>
    <th>
      Event
    </th>
    
    <th>
      Payload
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        select
      </code>
    </td>
    
    <td>
      <code>
        (item: LiquidTabsItem, tab: string)
      </code>
    </td>
    
    <td>
      Fires when a row is selected, with its tab key.
    </td>
  </tr>
</tbody>
</table>

## Accessibility

- The tabs use `role="tablist"` and `role="tab"` with `aria-selected` and a roving `tabindex`. Left and Right arrows move between tabs and wrap.
- The rows sit in a `role="tabpanel"`. Each row is an option in a listbox with `aria-selected`.
- The chevron sets `aria-haspopup="menu"` and `aria-expanded`. The menu uses `role="menu"` and `menuitemradio` items with `aria-checked`. Opening it focuses the checked item; Up, Down, Home and End move focus; Escape closes it and returns focus to the chevron. A press outside also closes it.
- Focus rings are visible on tabs, rows, the chevron and menu items.
- With reduced motion the tab moves without a spring, rows only cross-fade and the avatar does not bounce.

Ported from [Liquid Tabs](https://pinui.xyz/components/liquid-tabs) by Pin UI, MIT licence.
