@molecule/app-feature-flag-row-angular
Feature · feature-flag-row · App (browser) · v1.1.2 · Apache-2.0
Feature-flag list row: name + status + rollout% + environment toggles
npm install @molecule/app-feature-flag-row-angularHow it works
@molecule/app-feature-flag-row-angular 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 { Component } from '@angular/core'
import { FeatureFlagRow } from '@molecule/app-feature-flag-row-angular'
@Component({
selector: 'app-flags-list',
standalone: true,
imports: [FeatureFlagRow],
template: ` <div mol-feature-flag-row [flag]="flag" [onToggle]="onToggle"></div> `,
})
export class FlagsList {
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: string, envId: string, next: boolean): void => updateFlag(key, envId, next)
}Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular
Reference
Angular feature-flag list row — flag name + type badge + key + description
on the left, one labelled <mol-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 Angular
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.tsJSDoc, not this file.
Quick Start
import { Component } from '@angular/core'
import { FeatureFlagRow } from '@molecule/app-feature-flag-row-angular'
@Component({
selector: 'app-flags-list',
standalone: true,
imports: [FeatureFlagRow],
template: ` <div mol-feature-flag-row [flag]="flag" [onToggle]="onToggle"></div> `,
})
export class FlagsList {
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: string, envId: string, next: boolean): void => updateFlag(key, envId, next)
}
Type
feature
Installation
npm install @molecule/app-feature-flag-row-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
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 string, or a projected template (a `{ $nodes }` value
* inside a data prop arrives as a `TemplateRef`).
*/
label: unknown
/** 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. Node-valued fields (name,
description, environments[].label) are strings or projected templates.
interface FeatureFlag {
/** Stable machine key (also the switch's `aria-label` prefix). */
key: string
/** Display name — a string or a projected template. */
name: unknown
/** Optional tagline — a string or a projected template. */
description?: unknown
/** The kind of flag. */
type: FlagType
/** One entry per environment. */
environments: FeatureFlagEnvironment[]
}
FeatureFlagRowProps
Props accepted by FeatureFlagRow — the same props
@molecule/app-feature-flag-row-react accepts.
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'
Classes
FeatureFlagRow
FeatureFlagRow component.
Flag name + type badge + key + description on the left, one labelled
<mol-switch> per environment (with a rollout-% readout for percentage
flags) on the right. The host IS the outer <div>
(div[mol-feature-flag-row]), matching React's root exactly, so the row's
ClassMap classes are the host's.
Node-valued fields (name, description, environments[].label) are
projected templates; plain strings are used as they are.
@Component({
selector: 'div[mol-feature-flag-row]',
standalone: true,
imports: [Switch, NgTemplateOutlet],
inputs: ['flag', 'onToggle', 'className'],
host: {
'[class]': 'classes()',
},
// prettier-ignore
template: `@if (flag; as current) {<div [class]="leftClasses()"><div [class]="cm.flex({ align: 'center', gap: 'sm' })"><span [class]="cm.cn(cm.fontWeight('semibold'))">@if (isTemplate(current.name)) {<ng-container [ngTemplateOutlet]="asTemplate(current.name)"></ng-container>} @else {{{ current.name }}}</span><span [class]="cm.cn(cm.textSize('xs'), cm.fontWeight('medium'))">{{ typeLabel(current.type) }}</span></div><span [class]="cm.cn(cm.textSize('xs'))">{{ current.key }}</span>@if (current.description) {<p [class]="cm.textSize('sm')">@if (isTemplate(current.description)) {<ng-container [ngTemplateOutlet]="asTemplate(current.description)"></ng-container>} @else {{{ current.description }}}</p>}</div><div [class]="cm.flex({ align: 'center', gap: 'md' })">@for (env of current.environments; track env.id) {<div [class]="cm.cn(cm.stack(0), cm.textCenter)"><span [class]="cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'))">@if (isTemplate(env.label)) {<ng-container [ngTemplateOutlet]="asTemplate(env.label)"></ng-container>} @else {{{ env.label }}}</span><div [class]="cm.flex({ align: 'center', gap: 'xs' })"><mol-switch [checked]="env.enabled" (change)="toggle(current.key, env.id, $event)" [attr.aria-label]="ariaLabel(current.key, env.id)"></mol-switch>@if (current.type === 'percentage' && env.rolloutPct !== undefined) {<span [class]="cm.textSize('xs')">{{ env.rolloutPct }}%</span>}</div></div>}</div>}`,
})
export class FeatureFlagRow {
/** The flag to render. */
flag?: FeatureFlag
/** Called when an environment toggles. */
onToggle?: (flagKey: string, envId: string, next: boolean) => void
/** Extra classes on the outer wrapper. */
className?: string
/** The reactive i18n binding, read in the injection context. */
protected readonly i18n = useTranslation()
/** The translation function for the template. */
protected readonly t = this.i18n.t
/** The bonded ClassMap (styling tokens resolve at render time). */
protected readonly cm: UIClassMap = getClassMap()
/**
* The outer wrapper's class list (React's `cm.cn(flex, sp, className)`).
* @returns The class string.
*/
classes(): string {
return this.cm.cn(
this.cm.flex({ align: 'start', justify: 'between', gap: 'md' }),
this.cm.sp('py', 2),
this.className,
)
}
/**
* The left column's class list (`cm.cn(cm.flex1, cm.stack(0))`).
* @returns The class string.
*/
leftClasses(): string {
return this.cm.cn(this.cm.flex1, this.cm.stack(0))
}
/**
* The translated type-badge label: one literal `t('flagType.<type>')` call
* per flag type, exactly as React does (a runtime-built key such as
* `` t(`flagType.${type}`) `` is invisible to molecule's i18n gate).
* @param type - The flag type.
* @returns The badge text.
*/
typeLabel(type: FlagType): string {
switch (type) {
case 'boolean':
return this.t('flagType.boolean', {}, { defaultValue: 'Boolean' })
case 'multivariate':
return this.t('flagType.multivariate', {}, { defaultValue: 'Multivariate' })
case 'percentage':
return this.t('flagType.percentage', {}, { defaultValue: 'Percentage' })
case 'string':
return this.t('flagType.string', {}, { defaultValue: 'String' })
}
}
/**
* The switch's translated `aria-label` (React's
* `featureFlagRow.aria.flagInEnvironment` call, whose English default is
* `"<flagKey> in <envId>"`).
* @param flagKey - The flag's machine key.
* @param envId - The environment id.
* @returns The label text.
*/
ariaLabel(flagKey: string, envId: string): string {
return this.t(
'featureFlagRow.aria.flagInEnvironment',
{ flag: flagKey, environment: envId },
{ defaultValue: '{{flag}} in {{environment}}' },
)
}
/**
* Whether a value is one of the cases' projected node templates.
* @param value - The prop value.
* @returns True for a projected node template.
*/
isTemplate(value: unknown): value is TemplateRef<unknown> {
return isTemplate(value)
}
/**
* The value as a template (call under `FeatureFlagRow.isTemplate`).
* @param value - The prop value.
* @returns The template.
*/
asTemplate(value: unknown): TemplateRef<unknown> {
return value as TemplateRef<unknown>
}
/**
* An environment switch's change: the hidden checkbox's `checked` at emit
* time (React reads `e.target.checked` before its controlled restore).
* @param flagKey - The flag's machine key.
* @param envId - The environment id.
* @param event - The native change event the UI Switch re-emitted.
*/
toggle(flagKey: string, envId: string, event: Event): void {
this.onToggle?.(flagKey, envId, (event.target as HTMLInputElement | null)?.checked ?? false)
}
}
Injection Notes
Requirements
Peer dependencies:
@angular/common^22.0.0@angular/core^22.0.0@angular/platform-browser^22.0.0@molecule/app-angular^3.5.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-angular^1.1.0
Runtime Dependencies
@angular/common@angular/core@angular/platform-browser@molecule/app-angular@molecule/app-ui@molecule/app-ui-angular
The environment toggle is the <mol-switch> from the
@molecule/app-ui-angular 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.
Node-valued fields (name, description, environments[].label) are
strings or projected templates.
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.