Inherit style variants using different strategies
masterWhen a component inherits from a parent that has StyleVariants defined, you can choose how the child's style block interacts with the parent's variants using the strategy: option in the variants method:
override(default): The child's variants completely replace the parent's variants.merge: Performs a deep merge. All parent variant keys are preserved unless explicitly overwritten by the child.extend: Performs a shallow merge. All parent variants are kept, but if a key matches, the entire variant object for that key is replaced by the child's version.
# Using merge strategy
class Child::Component < Parent::Component
style do
variants(strategy: :merge) do
size { lg { "text-larger" } }
end
end
end