• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
    No results for ""
    EXPAND ALL

    EDIT ON GITHUB

    Turning flags on and off

    Read time: 2 minutes
    Last edited: Feb 27, 2023

    Overview

    This topic explains how to enable and disable flags in the LaunchDarkly platform.

    One-click control of flag behavior is critical to nimble feature management. With LaunchDarkly, you can turn a flag on or off directly from the flags list.

    The flag toggle button is a kill switch for any feature

    The flag button lets you turn off a feature that's misbehaving without needing to touch any code or re-deploy your application. Wrap the entire feature in a feature flag to control or revoke its rollout seamlessly.

    Here is a screenshot of the flags list:

    The flags list with two flag toggles called out.
    The flags list with two flag toggles called out.
    Use the toggle in a flag's Targeting tab

    You can also turn a flag on or off from the flag's Targeting tab. To learn more about flag targeting, read Targeting with flags.

    Flag behavior can do a lot more than just turning features on or off. Continue reading to learn more.

    Turning flags on

    When you create a new flag, it is turned Off by default. You can turn the flag On by clicking the flag toggle button in the flags list or the flag's Targeting tab.

    To turn a flag on:

    1. Navigate to the flags list or the Targeting tab of a flag.
    2. Click the flag toggle. The toggle turns green and displays the word On. The variation the flag will serve when you save your changes appears.
    The flag toggle in the "Targeting" tab.
    The flag toggle in the "Targeting" tab.
    1. Click Review and save.

    To learn more about creating flags, read Creating a feature flag.

    Turning flags off

    When you turn a flag to Off, you disable the targeting rules for that flag. Instead of serving an active variation, you serve the off variation.

    In the Targeting tab, you can set an off variation for both boolean and multivariate flags. Boolean feature flags default to false when the feature flag is Off.

    To turn a flag Off:

    1. Navigate to the flags list or the Targeting tab in the flag detail page.
    2. Set the toggle to Off. The variation the flag will serve when you save your changes appears.
    The "Targeting" tab with the flag turned off.
    The "Targeting" tab with the flag turned off.
    1. Click Review and save.

    The Targeting tab displays this value at the bottom of the tab:

    The off default value at the bottom of the "Targeting" tab.
    The off default value at the bottom of the "Targeting" tab.

    If you don't specify an explicit default off variation, LaunchDarkly serves the fallback value for the flag. You can specify the fallback value in your code's variation calls.

    The Targeting tab displays the fallback value at the bottom of the tab:

    The fallback value at the bottom of the "Targeting" tab.
    The fallback value at the bottom of the "Targeting" tab.
    Planning feature flags for future events

    You can schedule a flag for a particular date using scheduled flag changes, or you can use targeting rules to control what it affects and when. For example, you can serve false to deprecate a feature after a date of your choosing, or you can target a specific context or segment to be removed from the flag's targeting settings. To learn more, read Targeting with flags.