About
The apps an assistant can reach: connect one, set each tool to allow, ask or deny, and reconnect one whose access expired.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Connectors to your project and fits it to your theme.
Code
How Connectors is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client"
import * as React from "react"
import { Connector, ConnectorRow, ConnectorTool } from "@/components/ui/connectors"
const reducedMotion = () => window.matchMedia("(prefers-reduced-motion: reduce)").matches
type Patch = Partial<Connector> & { open?: boolean }
const HUDDLE_TOOLS: ConnectorTool[] = [
{ name: "search_messages", label: "Search messages", kind: "read", permission: "allow" },
{ name: "send_message", label: "Send messages", kind: "write", permission: "ask" },
]
/** The tour: connect Huddle, open its tools, keep sending to Deny, close, then reconnect Folio. */
const BEATS: { ms: number; huddle?: Patch; folio?: Patch }[] = [
{ ms: 1200 },
{ ms: 1100, huddle: { status: "connecting" } },
{
ms: 700,
huddle: { status: "connected", account: "Connected as priya@tidewater.dev", tools: HUDDLE_TOOLS },
},
{ ms: 1300, huddle: { open: true } },
{
ms: 1500,
huddle: { tools: HUDDLE_TOOLS.map((t) => (t.name === "send_message" ? { ...t, permission: "deny" } : t)) },
},
{ ms: 800, huddle: { open: false } },
{ ms: 1100, folio: { status: "connecting", account: undefined } },
{ ms: 3200, folio: { status: "connected", account: "Connected as priya@tidewater.dev" } },
]
/** The state after the first `n` beats. */
function stateAt(n: number) {
let huddle: Patch = {}
let folio: Patch = {}
for (const beat of BEATS.slice(0, n + 1)) {
huddle = { ...huddle, ...beat.huddle }
folio = { ...folio, ...beat.folio }
}
return { huddle, folio }
}
/** Fictional apps, so no real provider is named. Marks fall back to the first letter. */
const START: Connector[] = [
{
id: "folio",
name: "Folio",
description: "Search specs and meeting notes.",
status: "needs-reauth",
account: "Access expired Oct 18",
tools: [{ name: "search_docs", label: "Search docs", kind: "read", permission: "allow" }],
},
{
id: "huddle",
name: "Huddle",
description: "Search channels and draft messages for you to send.",
status: "available",
},
{
id: "tracklane",
name: "Tracklane",
description: "Find, create and update issues.",
status: "available",
},
]
const FIT_CSS = "html,body{overflow:hidden}[data-fit-small] [data-fit-hide]{display:none!important}"
/**
* 21st shows a demo in a small frame: about 674 by 421 on a component page, 358 by 224 on a
* phone and 245 by 139 on a profile card. A demo taller than its frame gets scrollbars, which
* render white on dark pages. FitFrame fills the frame exactly instead.
*
* - "scale": the content shrinks until it fits, centered. For visuals such as orbs.
* - "crop": the content stays at full size from the top and fades out at the bottom. For text
* that streams in, where a changing scale would make the page breathe.
*
* `minWidth` lays out a wide demo (a table, a two column panel) at that width and scales it down
* to the frame, instead of letting it collapse to a narrow layout. The frame centers it, so it
* shrinks evenly on both sides.
*
* Anything marked `data-fit-hide` (state buttons, the chatcn.dev line) drops out in frames
* shorter than `hideBelow`, so a profile card shows the visual alone.
*/
function FitFrame({
children,
mode = "scale",
hideBelow = 360,
minWidth,
}: {
children: React.ReactNode
mode?: "scale" | "crop"
hideBelow?: number
minWidth?: string
}) {
const content = React.useRef<HTMLDivElement>(null)
const [cropped, setCropped] = React.useState(false)
React.useLayoutEffect(() => {
const el = content.current
if (!el) return
const measure = () => {
const vw = window.innerWidth
const vh = window.innerHeight
el.toggleAttribute("data-fit-small", vh < hideBelow)
// Layout sizes ignore the transform, so measuring never feeds back.
const w = Math.max(el.offsetWidth, el.scrollWidth)
const h = Math.max(el.offsetHeight, el.scrollHeight)
const scale = mode === "scale" ? Math.min(1, vw / w, vh / h) : 1
el.style.transform = scale < 1 ? `scale(${scale})` : ""
setCropped(mode === "crop" && h > vh + 1)
}
measure()
const observer = new ResizeObserver(measure)
observer.observe(el)
// Content that changes inside a fixed width box (a headline that cycles words) never resizes
// the box itself, so changes below it measure again on the next frame.
let frame = 0
const mutations = new MutationObserver(() => {
cancelAnimationFrame(frame)
frame = requestAnimationFrame(measure)
})
mutations.observe(el, { subtree: true, childList: true, characterData: true })
window.addEventListener("resize", measure)
return () => {
observer.disconnect()
mutations.disconnect()
cancelAnimationFrame(frame)
window.removeEventListener("resize", measure)
}
}, [mode, hideBelow])
const fade = "linear-gradient(to bottom, #000 calc(100% - 40px), transparent)"
return (
<div
className="flex w-full justify-center overflow-hidden"
style={{
height: "100dvh",
alignItems: mode === "crop" ? "flex-start" : "center",
maskImage: cropped ? fade : undefined,
WebkitMaskImage: cropped ? fade : undefined,
}}
>
<style>{FIT_CSS}</style>
<div
ref={content}
className="w-full shrink-0"
style={{ transformOrigin: mode === "crop" ? "top center" : "center", minWidth }}
>
{children}
</div>
</div>
)
}
/** The line under each 21st demo that points back to the kit. */
function MoreOn({ slug, children }: { slug: string; children: React.ReactNode }) {
return (
<p data-fit-hide className="text-[0.75rem]/[1rem] text-(color:--chatcn-fg-faint) text-center text-balance">
{children}{" "}
<a
href={`https://chatcn.dev/docs/components/${slug}`}
target="_blank"
rel="noopener"
className="text-(color:--chatcn-fg-subtle) hover:text-(color:--chatcn-fg) underline underline-offset-2"
>
chatcn.dev
</a>
</p>
)
}
/**
* The apps an assistant can reach: connect one, set what each of its tools may do (allow, ask
* first or deny), and reconnect one whose access expired. Plays on its own and loops; clicking a
* row hands it over to you.
*/
export default function ConnectorsPreview() {
const [beat, setBeat] = React.useState(0)
const [manual, setManual] = React.useState<Connector[] | null>(null)
const [openId, setOpenId] = React.useState<string>()
React.useEffect(() => {
if (reducedMotion() || manual) return
const id = window.setTimeout(() => setBeat((b) => (b + 1) % BEATS.length), BEATS[beat]!.ms)
return () => window.clearTimeout(id)
}, [beat, manual])
const { huddle, folio } = stateAt(beat)
const scripted = START.map((c) => {
const p = c.id === "huddle" ? huddle : c.id === "folio" ? folio : {}
const { open: _open, ...rest } = p
return { ...c, ...rest }
})
const connectors = manual ?? scripted
const open = manual ? openId : huddle.open ? "huddle" : undefined
/** Any click takes over: the tour stops and the rows keep the state they show. */
const takeOver = () => {
if (!manual) {
setManual(connectors)
setOpenId(open)
}
}
const patch = (id: string, change: Partial<Connector>) =>
setManual((prev) => (prev ?? connectors).map((c) => (c.id === id ? { ...c, ...change } : c)))
const connect = (id: string) => {
takeOver()
patch(id, { status: "connecting" })
window.setTimeout(
() =>
patch(id, {
status: "connected",
account: "Connected as priya@tidewater.dev",
tools: connectors.find((c) => c.id === id)?.tools ?? HUDDLE_TOOLS,
}),
1200,
)
}
return (
<FitFrame minWidth="34rem">
<div className="flex w-full flex-col items-center justify-center gap-4 p-6">
<div className="rounded-(--chatcn-radius-lg) bg-(color:--chatcn-card) shadow-(--chatcn-shadow-sm) flex w-full max-w-xl flex-col gap-2 p-4">
<div className="px-1 pb-1">
<p className="text-[0.875rem]/[1.25rem] tracking-[-0.003em] text-(color:--chatcn-fg) font-medium">Connectors</p>
<p className="text-[0.75rem]/[1rem] text-(color:--chatcn-fg-subtle)">Apps the assistant can use, and what it may do in each.</p>
</div>
{/* Fixed height, so opening a tools panel never rescales the frame. */}
<div className="flex h-[22.25rem] flex-col overflow-hidden [mask-image:linear-gradient(to_top,transparent,black_1rem)]">
{connectors.map((c) => (
<ConnectorRow
key={c.id}
connector={c}
open={open === c.id}
onOpenChange={(next) => {
takeOver()
setOpenId(next ? c.id : undefined)
}}
onConnect={() => connect(c.id)}
onReconnect={() => connect(c.id)}
onDisconnect={() => {
takeOver()
patch(c.id, { status: "available", account: undefined })
}}
onPermissionChange={(tool, permission) => {
takeOver()
patch(c.id, { tools: c.tools?.map((t) => (t.name === tool ? { ...t, permission } : t)) })
}}
onPermissionChangeAll={(permission) => {
takeOver()
patch(c.id, { tools: c.tools?.map((t) => ({ ...t, permission })) })
}}
/>
))}
</div>
</div>
<MoreOn slug="connectors">Apps an assistant can reach, with a permission per tool. On</MoreOn>
</div>
</FitFrame>
)
}
















