DocsBlog
  • 0.25.3

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Styling
Theming

Concepts

OverviewCompositionTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

Feature Flags

Feature Flags display or hide content in the UI.

  • npm
  • source
import { FeatureFlags, FeatureFlag } from '@cerberus/react'

When to use

When you need render a component based on if it should be enabled or not.

Usage

This is a visible feature
Copy
nav.tsx
'use client'
import { FeatureFlags, FeatureFlag } from '@cerberus/react'
import { useMemo } from 'react'
function FeatureFlagsPreview() {
const flags = useMemo(
() => ({
featureOne: true,
featureTwo: false,
}),
[],
)
return (
<FeatureFlags flags={flags}>
<FeatureFlag flag="featureOne">This is a visible feature</FeatureFlag>
<FeatureFlag flag="featureTwo">This is a hidden feature</FeatureFlag>
</FeatureFlags>
)
}

API

export interface FeatureFlagsProviderValue {
flags: Record<string, boolean>
}
export interface FeatureFlagProps {
// A unique key of the flags data passed into the provider.
flag: string
}
define function FeatureFlag(props: PropsWithChildren<FeatureFlagProps>): JSX.Element

Props

The FeatureFlag component accepts the following props:

NameDefaultDescription
flagnullA unique key of the flags data passed into the provider.

On this page

  • Edit this page on Github
Cerberus Design System | Docs