diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f59e365e2..0b9582af2 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,10 @@ title: Changelog *Blake Williams*, *Cameron Dutro*, *Joel Hawksley* +* Deprecate `Base#with_variant`. + + *Cameron Dutro* + ## 2.38.0 * Add `--stimulus` flag to the component generator. Generates a Stimulus controller alongside the component. diff --git a/lib/view_component/base.rb b/lib/view_component/base.rb index 9c784e2b9..213216694 100644 --- a/lib/view_component/base.rb +++ b/lib/view_component/base.rb @@ -218,9 +218,14 @@ def format # Use the provided variant instead of the one determined by the current request. # + # @deprecated Will be removed in v3.0.0. # @param variant [Symbol] The variant to be used by the component. # @return [self] def with_variant(variant) + ActiveSupport::Deprecation.warn( + "`with_variant` is deprecated and will be removed in ViewComponent v3.0.0." + ) + @__vc_variant = variant self