# Split-flap board

A station departure board: each character is a pair of flaps that falls to the next value, column by column. The text is the truth and changes are announced once per row. For deploy boards, queues and live status.

- Category: Records
- Docs: https://bevel-ui.vercel.app/components/split-flap
- Import from: `@/components/ui/split-flap`

## Install

```bash
npx shadcn@latest add @bevel/split-flap
```

npm dependencies (installed by the CLI): `cn`.

## Anatomy

```tsx
<SplitFlap aria-label="Deploys">
  <SplitFlapRow name="US East">
    <SplitFlapText value="US-EAST" length={8} />
    <SplitFlapText value={status} length={8} tone="amber" />
  </SplitFlapRow>
</SplitFlap>
```

## Parts

| Part | Renders | Description |
| --- | --- | --- |
| `SplitFlap` | div (group) + ul | Gathers changes and announces them together: “Updated: US East, EU West.” Give it an aria-label. |
| `SplitFlapRow` | li | name: how the row is announced when it changes. |
| `SplitFlapText` | span | value, length (padded or cut), tone white or amber. Reads as its text; the flaps are decoration. With reduced motion, characters crossfade. |

## Example: A deploy board

Each region's status flips over as its rollout moves on.

```tsx
"use client"

import * as React from "react"
import { SplitFlap, SplitFlapRow, SplitFlapText } from "@/components/ui/split-flap"

const regions = ["US-EAST", "US-WEST", "EU-WEST", "AP-SOUTH"]
const stages = ["QUEUED", "BUILDING", "TESTING", "ROLLOUT", "LIVE"]

/** A deploy board. Each region's status flips over as its rollout moves on. */
export function SplitFlapDeploys() {
  const [at, setAt] = React.useState([4, 2, 1, 0])

  React.useEffect(() => {
    const timer = setInterval(() => {
      setAt((all) => {
        if (all.every((s) => s === stages.length - 1)) return [0, 0, 0, 0]
        const open = all.map((s, i) => (s < stages.length - 1 ? i : -1)).filter((i) => i >= 0)
        const pick = open[Math.floor(Math.random() * open.length)]!
        return all.map((s, i) => (i === pick ? s + 1 : s))
      })
    }, 2200)
    return () => clearInterval(timer)
  }, [])

  return (
    <SplitFlap aria-label="Deploys">
      {regions.map((r, i) => (
        <SplitFlapRow key={r} name={r}>
          <SplitFlapText value={r} length={8} />
          <SplitFlapText value={`V2.${14 + (at[i]! > 3 ? 1 : 0)}`} length={5} />
          <SplitFlapText value={stages[at[i]!]!} length={8} tone="amber" />
        </SplitFlapRow>
      ))}
    </SplitFlap>
  )
}
```
