# V button 30

> Segmented view toggle with list, table, and kanban options

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/v-button-30).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/v-button-30
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/cnippet/v-button-30-light-79471e31f0b23f10.png
- Registry item: https://ui.cnippet.dev/r/v-button-30.json
- Categories: button
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ui.cnippet.dev/r/v-button-30.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/button`

## Files

### `registry/default/variants/v-button-30.tsx`

```tsx
"use client";

import { KanbanIcon, LayoutListIcon, TableIcon } from "lucide-react";
import { Fragment, useState } from "react";
import { Button } from "@/registry/default/ui/button";
import { Group, GroupSeparator } from "@/registry/default/ui/group";

type View = "list" | "table" | "board";

const views: { id: View; icon: typeof LayoutListIcon; label: string }[] = [
  { icon: LayoutListIcon, id: "list", label: "List" },
  { icon: TableIcon, id: "table", label: "Table" },
  { icon: KanbanIcon, id: "board", label: "Board" },
];

export function Pattern() {
  const [view, setView] = useState<View>("list");

  return (
    <div className="flex flex-col items-center gap-4">
      <Group aria-label="View mode">
        {views.map((v, i) => (
          <Fragment key={v.id}>
            {i > 0 && <GroupSeparator />}
            <Button
              aria-pressed={view === v.id}
              onClick={() => setView(v.id)}
              size="sm"
              variant={view === v.id ? "default" : "ghost"}
            >
              <v.icon className="size-4" />
              {v.label}
            </Button>
          </Fragment>
        ))}
      </Group>
      <p className="text-muted-foreground text-sm">
        Viewing as:{" "}
        <span className="font-medium text-foreground capitalize">{view}</span>
      </p>
    </div>
  );
}
```
