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

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-vue

npm · Source on GitHub

How it works

@molecule/app-feature-flag-row-vue 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.

import { createApp, defineComponent, h } from 'vue'
import { FeatureFlagRow } from '@molecule/app-feature-flag-row-vue'

const FlagsList = defineComponent({
  setup() {
    return () =>
      h(FeatureFlagRow, {
        flag: {
          key: 'new-checkout',
          name: 'New Checkout Flow',
          description: 'Redesigned multi-step checkout experience.',
          type: 'percentage',
          environments: [
            { id: 'staging', label: 'Staging', enabled: true, rolloutPct: 100 },
            { id: 'production', label: 'Production', enabled: true, rolloutPct: 20 },
          ],
        },
        onToggle: (key, envId, next) => updateFlag(key, envId, next),
      })
  },
})

createApp(FlagsList).mount('#app')

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

Reference

Vue 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 Vue 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

import { createApp, defineComponent, h } from 'vue'
import { FeatureFlagRow } from '@molecule/app-feature-flag-row-vue'

const FlagsList = defineComponent({
  setup() {
    return () =>
      h(FeatureFlagRow, {
        flag: {
          key: 'new-checkout',
          name: 'New Checkout Flow',
          description: 'Redesigned multi-step checkout experience.',
          type: 'percentage',
          environments: [
            { id: 'staging', label: 'Staging', enabled: true, rolloutPct: 100 },
            { id: 'production', label: 'Production', enabled: true, rolloutPct: 20 },
          ],
        },
        onToggle: (key, envId, next) => updateFlag(key, envId, next),
      })
  },
})

createApp(FlagsList).mount('#app')

Type

feature

Installation

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

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 VNode, a string, or null). */
  label: VNodeChild
  /** 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 VNode, a string, or null). */
  name: VNodeChild
  /** Optional tagline (a VNode, a string, or null). */
  description?: VNodeChild
  /** The kind of flag. */
  type: FlagType
  /** One entry per environment. */
  environments: FeatureFlagEnvironment[]
}

FeatureFlagRowProps

Props accepted by FeatureFlagRow.

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

Feature-flag list row with per-environment toggle + rollout-percentage display. Use inside a grid or table to build a flags dashboard.

const FeatureFlagRow: DefineComponent<
  ExtractPropTypes<{
    flag: { type: PropType<FeatureFlag>; required: true }
    onToggle: { type: PropType<FeatureFlagRowProps['onToggle']>; required: true }
    className: StringConstructor
  }>,
  () => VNode,
  {},
  {},
  {},
  ComponentOptionsMixin,
  ComponentOptionsMixin,
  {},
  string,
  PublicProps,
  Readonly<
    ExtractPropTypes<{
      flag: { type: PropType<FeatureFlag>; required: true }
      onToggle: { type: PropType<FeatureFlagRowProps['onToggle']>; required: true }
      className: StringConstructor
    }>
  > &
    Readonly<{}>,
  {},
  {},
  {},
  {},
  string,
  ComponentProvideOptions,
  true,
  {},
  any
>
  • props — Component props (see FeatureFlagRowProps).

Returns: The feature-flag row component.

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-vue ^1.1.0
  • @molecule/app-vue ^3.13.0 || ^4.0.0
  • vue ^3.4.0

Runtime Dependencies

  • @molecule/app-ui
  • @molecule/app-ui-vue
  • @molecule/app-vue
  • vue

The environment toggle is the <Switch> from the @molecule/app-ui-vue 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.