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

**URL:** <https://discourse.julialang.org/t/plutoui-slider-value-is-forced-to-zero-when-it-is-printed-in-the-same-md-string-with-slider/51261>\
**Category:** General Usage\
**Tags:** pluto\
**Created:** [December 4, 2020, 4:36pm UTC](https://discourse.julialang.org/t/plutoui-slider-value-is-forced-to-zero-when-it-is-printed-in-the-same-md-string-with-slider/51261 "2020-12-04T16:36:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Post date:** [December 4, 2020, 4:36pm UTC](https://discourse.julialang.org/t/plutoui-slider-value-is-forced-to-zero-when-it-is-printed-in-the-same-md-string-with-slider/51261/1 "2020-12-04T16:36:23Z")

</div>

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

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

```

Here’s a MWE:

```julia
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
```

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [December 4, 2020, 8:03pm UTC](https://discourse.julialang.org/t/plutoui-slider-value-is-forced-to-zero-when-it-is-printed-in-the-same-md-string-with-slider/51261/2 "2020-12-04T20:03:35Z")

</div>

Will this work for your situation?

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

```

![image](https://global.discourse-cdn.com/julialang/original/3X/8/b/8b1e9d5df79f5f726128cac46323ba6225c84f5d.png)

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

---

<div class="post-metadata">

**Author:** ![KajWiik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kajwiik/32/199_2.png) [@KajWiik](https://discourse.julialang.org/u/KajWiik)\
**Post date:** [December 4, 2020, 8:35pm UTC](https://discourse.julialang.org/t/plutoui-slider-value-is-forced-to-zero-when-it-is-printed-in-the-same-md-string-with-slider/51261/3 "2020-12-04T20:35:42Z")

</div>

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