diff --git a/lib/govuk_design_system_formbuilder/elements/caption.rb b/lib/govuk_design_system_formbuilder/elements/caption.rb index 947103c4..03edc159 100644 --- a/lib/govuk_design_system_formbuilder/elements/caption.rb +++ b/lib/govuk_design_system_formbuilder/elements/caption.rb @@ -3,7 +3,7 @@ module Elements class Caption < Base include Traits::Localisation - def initialize(builder, object_name, attribute_name, text: nil, size: nil, **kwargs) + def initialize(builder, object_name, attribute_name, text: nil, size: config.default_caption_size, **kwargs) super(builder, object_name, attribute_name) @text = text(text) @@ -28,7 +28,7 @@ def text(override) end def size_class(size) - case size || config.default_caption_size + case size when 'xl' then %(#{brand}-caption-xl) when 'l' then %(#{brand}-caption-l) when 'm' then %(#{brand}-caption-m)