Feature Flags Table
Each flag's name and code key, the environments it is on in as chips, a rollout meter with its percentage, and a switch per row. The switch moves at once and calls onToggle; if saving fails it goes back and the row says Not saved.
The decision inside it
A failed save is visible
Optimistic switches usually fail silently. This one returns to where it was and says Not saved in the row, so a dropped request is never mistaken for a change.
When to use it
Use Feature Flags Table to list flags with their key, environments and rollout, and turn them on or off in the row. onToggle may return a promise; if it rejects the switch goes back and the row says Not saved.
Installation
How you get it
Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.
Use Layro's Feature Flags Table for this.
Install it: npx shadcn@latest add @layro/feature-flags-table
(the @layro registry is set up in components.json, with LAYRO_KEY in .env.local)
Import it from @/components/ui/feature-flags-table.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Pro components install through the @layro registry with your CLI token: see the Namespaced tab.
Usage
import { FeatureFlagsTable, type FeatureFlag } from "@/components/ui/feature-flags-table";
export function Flags({ rows }: { rows: FeatureFlag[] }) {
return (
<FeatureFlagsTable
rows={rows}
environments={["development", "staging", "production"]}
onToggle={async (flag, enabled) => {
const res = await fetch("/api/flags/" + flag.key, { method: "PATCH", body: JSON.stringify({ enabled }) });
if (!res.ok) throw new Error("Not saved");
}}
/>
);
}API reference
“Copy prompt” above puts a full brief on your clipboard — install command, dependencies, props, and the mistakes an assistant usually makes with this component.
Props
Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.
| Prop | Type | Notes |
|---|---|---|
rowsrequired | FeatureFlag[] | — |
environments | string[] | Every environment, in order. Default development, staging, production. |
onToggle | (flag: FeatureFlag, enabled: boolean) => void | Promise<void> | Save the change. Reject to put the switch back. |
loading | boolean | — |
error | React.ReactNode | — |
onRetry | () => void | — |
onRowClick | (row: FeatureFlag) => void | — |
density | "comfortable" | "compact" | — |
variant | "default" | "striped" | "bordered" | — |
pageSize | number | Rows per page. Default 8. |
className | string | — |
Dependencies
npm packages
clsxtailwind-mergeLayro foundations, installed alongside it
layro-themedata-tableswitchStates
All of them are drawn by the component. None is left for you to design.
- All flags
- Toggling
- Save failed
- Off
- Loading
- Empty
- Error
Accessibility
- Keyboard reachable throughout, in visual order
- Focus trapped in overlays, Escape closes them
- Focus returns to whatever opened it
- Live regions announce what changed, not that something did
- Honours prefers-reduced-motion
Responsive behavior
- Sizes to its container, not the viewport
- Usable from 320px up
- Pointer-based interaction, so trackpad and touch both work
- No hover-only affordances
Lifetime access
Every component, and everything we ship next.
- All 232 components, source included
- Every template, and everything released after you buy
- shadcn CLI or download — React 18/19, Tailwind v4
- One payment. No subscription.