# Feature flags

Edit explicit feature values and rollout percentages across named environments.

Access: pro. Category: Blocks. Kind: composite.

## When to use

- Use it when a page needs edit explicit feature values and rollout percentages across named environments.
- Choose it as the features region when composing a page from independently reusable TidalUI sections.

## Alternatives

- Choose empty-state instead when empty collections, search results and errors with a clear next action is the actual interface need, rather than feature flags.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Feature flags

```sh
npx shadcn@latest add @tidal-pro/feature-flag-manager
```

Stylesheets: `components/ui/tidal.css`, `components/ui/feature-flag-manager.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/feature-flag-manager.css";
import{TidalFeatureFlagManager}from"./components/ui/feature-flag-manager";
export default(p:Parameters<typeof TidalFeatureFlagManager>[0])=><div className="tidal-scope"><TidalFeatureFlagManager {...p}/></div>;
```

## Structured props

- `TidalFeatureFlagManager.environmentId: string`: Required environment id value accepted by this exported component.
- `TidalFeatureFlagManager.environments: ReadonlyArray<TidalFlagEnvironment>`: Required environments value accepted by this exported component.
- `TidalFeatureFlagManager.flags: ReadonlyArray<TidalFeatureFlag>`: Required flags value accepted by this exported component.
- `TidalFeatureFlagManager.onEnvironmentChange: (id: string) => void`: Callback invoked when the environment change interaction is proposed.
- `TidalFeatureFlagManager.onFlagChange: (id: string, value: TidalFlagValue, source: "enabled" | "rollout") => void`: Callback invoked when the flag change interaction is proposed.
- `TidalFeatureFlagManager.title: ReactNode`: Required title value accepted by this exported component.
- `TidalFeatureFlagManager.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalFeatureFlagManager.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalFeatureFlagManager.environmentRef?: Ref<HTMLSelectElement> | undefined`: Optional environment ref value accepted by this exported component.
- `TidalFeatureFlagManager.headingLevel?: "h2" | "h3" | "h4" | "h5" | undefined` (default "h2"): Optional heading level value accepted by this exported component.
- `TidalFeatureFlagManager.labels?: Partial<{ environment: string; enabled: string; rollout: string; empty: string; invalid: string; invalidRollout: string; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalFeatureFlagManager.rolloutRef?: ((flag: TidalFeatureFlag) => Ref<HTMLInputElement> | undefined) | undefined`: Optional rollout ref value accepted by this exported component.
- `TidalFeatureFlagManager.switchRef?: ((flag: TidalFeatureFlag) => Ref<HTMLInputElement> | undefined) | undefined`: Optional switch ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/feature-flag-manager.tsx) | [Manifest](https://tidalui.com/examples/feature-flag-manager.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalFeatureFlagManager, type TidalFeatureFlag } from "./components/ui/feature-flag-manager";

import "./components/ui/feature-flag-manager.css";

import "./components/ui/native-select.css";

import "./components/ui/toggle-switch.css";

import "./components/ui/number-stepper.css";



const environments = [
  { id: "development", label: "Development" },
  { id: "staging", label: "Staging" },
  { id: "production", label: "Production" },
];

export const initialFlags: TidalFeatureFlag[] = [
  {
    id: "search",
    key: "new_search",
    name: "New search",
    description: "Updated search layout and keyboard navigation.",
    values: {
      development: { enabled: true, rollout: 100 },
      staging: { enabled: true, rollout: 100 },
      production: { enabled: true, rollout: 25 },
    },
  },
  {
    id: "reports",
    key: "scheduled_reports",
    name: "Scheduled reports",
    description: "Allow workspace members to prepare recurring exports.",
    values: {
      development: { enabled: true, rollout: 100 },
      staging: { enabled: true, rollout: 50 },
      production: { enabled: false, rollout: 0 },
    },
  },
  {
    id: "workspace",
    key: "workspace_overview",
    name: "Workspace overview",
    description: "A new summary screen for active projects.",
    values: {
      development: { enabled: true, rollout: 100 },
      staging: { enabled: false, rollout: 0 },
      production: { enabled: false, rollout: 0 },
    },
  },
];

export function FeatureFlagManagerDemo() {
  const [environment, setEnvironment] = useState("production");
  const [flags, setFlags] = useState(initialFlags);
  return (
    <div style={{ width: "100%", maxWidth: 940 }}>
      <TidalFeatureFlagManager
        title="Feature flags"
        description="Review the configured values for each environment."
        environments={environments}
        environmentId={environment}
        onEnvironmentChange={setEnvironment}
        flags={flags}
        onFlagChange={(id, value) =>
          setFlags((current) =>
            current.map((flag) =>
              flag.id === id
                ? { ...flag, values: { ...flag.values, [environment]: value } }
                : flag,
            ),
          )
        }
      />
      <p style={{ fontSize: 11, textAlign: "center", color: "var(--t-muted)" }}>
        Local sample. Changing a value does not deploy it.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <FeatureFlagManagerDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned environments and flags require unique nonblank IDs and labels/keys. Every flag supplies a boolean enabled value and rollout percentage for every environment; null or finite out-of-range rollout remains editable with a visible field error. Nonfinite values or structural inconsistencies produce an explicit configuration error. Up to12 environments and200 flags. Controlled environment and flag callbacks propose local values only. Accepted Native select, Toggle switch and Number stepper compose the controls. Root and control refs, native section attributes, heading levels, disabled state, translated labels, and responsive stacking are supported. No flag evaluation, random assignment, remote change, scheduling or deployment occurs.
