@molecule/app-feature-flag-row-svelte

Feature · feature-flag-row · App (browser) · v1.1.3 · Apache-2.0

Feature-flag list row: name + status + rollout% + environment toggles

npm install @molecule/app-feature-flag-row-svelte

npm · Source on GitHub

How it works

@molecule/app-feature-flag-row-svelte is a ready-made feature-flag-row feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { FeatureFlagRow } from '@molecule/app-feature-flag-row-svelte'

  const flag = {
    key: 'new-checkout',
    name: 'New Checkout Flow',
    description: 'Redesigned multi-step checkout experience.',
    type: 'percentage' as const,
    environments: [
      { id: 'staging', label: 'Staging', enabled: true, rolloutPct: 100 },
      { id: 'production', label: 'Production', enabled: true, rolloutPct: 20 },
    ],
  }
</script>

<FeatureFlagRow {flag} onToggle={(key, envId, next) => updateFlag(key, envId, next)} />

Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte feature-flag list row — flag name + type badge + key + description on the left, one labelled <Switch> per environment (with a rollout-% readout for percentage flags) on the right. Stack rows inside a list or table to build a flags dashboard.

Exports FeatureFlagRow and the FeatureFlag, FeatureFlagEnvironment, and FlagType types. It is the Svelte counterpart of @molecule/app-feature-flag-row-react: the same props (React names) and the same DOM for the same input.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { FeatureFlagRow } from '@molecule/app-feature-flag-row-svelte'

  const flag = {
    key: 'new-checkout',
    name: 'New Checkout Flow',
    description: 'Redesigned multi-step checkout experience.',
    type: 'percentage' as const,
    environments: [
      { id: 'staging', label: 'Staging', enabled: true, rolloutPct: 100 },
      { id: 'production', label: 'Production', enabled: true, rolloutPct: 20 },
    ],
  }
</script>

<FeatureFlagRow {flag} onToggle={(key, envId, next) => updateFlag(key, envId, next)} />

Type

feature

Installation

npm install @molecule/app-feature-flag-row-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

FeatureFlagEnvironment

Per-environment state for a feature flag, including enabled status and optional rollout percentage.

interface FeatureFlagEnvironment {
  /** Environment id (e.g. "production", "staging"). */
  id: string
  /** Display label — a snippet or a plain string. */
  label: Snippet | string
  /** Enabled in this env. */
  enabled: boolean
  /** Rollout percentage 0-100. Optional — render when `type='percentage'`. */
  rolloutPct?: number
}

FeatureFlag

Complete definition of a feature flag including its key, display name, type, and per-environment configuration.

interface FeatureFlag {
  /** Stable machine key (also the switch's `aria-label` prefix). */
  key: string
  /** Display name — a snippet or a plain string. */
  name: Snippet | string
  /** Optional tagline — a snippet or a plain string. */
  description?: Snippet | string
  /** The kind of flag. */
  type: FlagType
  /** One entry per environment. */
  environments: FeatureFlagEnvironment[]
}

FeatureFlagRowProps

Props accepted by FeatureFlagRow (the components.ts export).

interface FeatureFlagRowProps {
  /** The flag to render. */
  flag: FeatureFlag
  /** Called when an environment toggles. */
  onToggle: (flagKey: string, envId: string, next: boolean) => void
  /** Extra classes. */
  className?: string
}

Types

FlagType

Discriminant for the kind of feature flag (boolean, multivariate, percentage rollout, or string variant).

type FlagType = 'boolean' | 'multivariate' | 'percentage' | 'string'

Constants

FeatureFlagRow

const FeatureFlagRow: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.1.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte

The environment toggle is the <Switch> from the @molecule/app-ui-svelte peer dependency — that package must be installed and its ClassMap bond wired for the row to render styled.

rolloutPct is displayed only when flag.type === 'percentage'; on other flag types the field is ignored. The row is presentation-only: onToggle receives (flagKey, envId, next) and the caller persists the change and re-renders with updated flag data.

The type badge translates via one literal t('flagType.<type>') call per flag type (a runtime-built key would be invisible to molecule's i18n gate), with a capitalized English label (Boolean, Multivariate, Percentage, String) as the fallback. The environment toggle's aria-label translates via featureFlagRow.aria.flagInEnvironment. All keys ship in the @molecule/app-locales-feature-flag-row companion bond (79 languages).

Translations

Translation strings are provided by @molecule/app-locales-feature-flag-row.