View Source Unleash.Variant (Unleash v3.0.0)
Defines types and functions for representing and working with strategy and feature variants.
Variants extend feature flags beyond simple on/off states, enabling multiple return values for more granular feature control.
Feature flags are designed to let you decide which users have access to a feature. Variants are designed to let you decide which version of the feature are user gets access to.
## Overview
While a basic feature flag exists in either on or off states, variants allow for multiple possible states within an enabled feature. Variants can be defined:
- Within strategies (recommended approach)
- Directly on the feature flag (deprecated)
Variants have a weight which determines the likelihood of users receiving a specific variant.
## Common Use Case
A typical pattern involves:
- Using a feature flag to control access to an entire feature
- Applying strategies to target specific user segments
- Using variants to customise the feature experience for different segments
For example, you might use strategies to determine which user segments can access a new UI component, then use variants to show different button colors to different segments within that group for A/B testing.
## Documentation