PlutoUI slider value is forced to zero when it is printed in the same MD string with slider

I want to embed a widget and its value in a same markdown string. When the slider position is changed, the value jumps ahead but it is replaced with zero immediately. Is there a better way to accomplish this? It seems that plain HTML (without PlutoUI) works fine.

This is with

  [c3e4b0f8] Pluto v0.12.16
  [7f904dfe] PlutoUI v0.6.10

Here’s a MWE:

using Markdown
using InteractiveUtils

# This Pluto notebook uses @bind for interactivity. When running this notebook outside of Pluto, the following 'mock version' of @bind gives bound variables a default value (instead of an error).
macro bind(def, element)
    quote
        local el = $(esc(element))
        global $(esc(def)) = Core.applicable(Base.get, el) ? Base.get(el) : missing
        el
    end
end

# ╔═╡ a93f8c70-364c-11eb-3b5a-07c9bcc8210d
using Pluto, PlutoUI

# ╔═╡ bda1cf52-364c-11eb-01c0-331194e02a5b
s = @bind a Slider(0.0:0.1:10.0);

# ╔═╡ d8e10c92-364c-11eb-2480-cbf8d763d77b
md"$a $s"

# ╔═╡ Cell order:
# ╠═a93f8c70-364c-11eb-3b5a-07c9bcc8210d
# ╠═bda1cf52-364c-11eb-01c0-331194e02a5b
# ╠═d8e10c92-364c-11eb-2480-cbf8d763d77b

Will this work for your situation?

md"""
$(@bind a Slider(0:10,show_value=true))
"""

image

The show_value keyword argument will display the value right next to the widget.

2 Likes

Well, sort of, yes. It’s matter of aesthetics :slight_smile:. The root question is that why showing the value of the slider in the same md" " zeroes the value?