# Custom slider for elm-ui using SVG

**URL:** <https://discourse.elm-lang.org/t/custom-slider-for-elm-ui-using-svg/8135>\
**Category:** Show and Tell\
**Created:** [February 5, 2022, 7:54am UTC](https://discourse.elm-lang.org/t/custom-slider-for-elm-ui-using-svg/8135 "2022-02-05T07:54:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![perty](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/perty/32/4459_2.png) [@perty](https://discourse.elm-lang.org/u/perty)\
**Post date:** [February 5, 2022, 7:54am UTC](https://discourse.elm-lang.org/t/custom-slider-for-elm-ui-using-svg/8135/1 "2022-02-05T07:54:27Z")

</div>

Quite seldom that I need a slider for input but when I do, I want it to look specific. 😄

Well, I had seen that elm-ui has possibilities to design both the background and the knob of a slider. So for a game where users are selecting probability, I came up with this solution.

![slider](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/2X/6/6a12eedac61bb2596e3e8881c06f2529a48a4636.png)

The user can adjust value by pressing and moving, as slider normally work.

The knob, or thumb, is invisible but that required that the focus style was set or a small blue square would appear.

Here is the Ellie: [https://ellie-app.com/gBks2hGX6Yta1](https://ellie-app.com/gBks2hGX6Yta1)

As you can see in the code, I used `elm/svg` but it is of course possible to use an external image. Mind that some of the function names in that package overlap, eg `style`, with other packages functions.

When I was looking for a linear gradient, I bumped into this site [https://cssgradient.io/](https://cssgradient.io/) where you can interactively design your gradient.

---

<div class="post-metadata">

**Author:** ![lucamug](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/lucamug/32/1764_2.png) [@lucamug](https://discourse.elm-lang.org/u/lucamug)\
**Post date:** [February 6, 2022, 11:28am UTC](https://discourse.elm-lang.org/t/custom-slider-for-elm-ui-using-svg/8135/2 "2022-02-06T11:28:47Z")

</div>

Very nice! A small thing, when I move my mouse below the slider I was expecting the needle to go flat, either to 0 or to 1, depending if I am on the left or on the right. In other words I think you should account also for the vertical position of the mouse

---

<div class="post-metadata">

**Author:** ![perty](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/perty/32/4459_2.png) [@perty](https://discourse.elm-lang.org/u/perty)\
**Post date:** [February 6, 2022, 1:11pm UTC](https://discourse.elm-lang.org/t/custom-slider-for-elm-ui-using-svg/8135/3 "2022-02-06T13:11:32Z")

</div>

Thanks. If I had made the control myself, it would make perfect sense. But now I have only slapped an illustration on top of an elm-ui control.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [February 16, 2022, 1:12pm UTC](https://discourse.elm-lang.org/t/custom-slider-for-elm-ui-using-svg/8135/4 "2022-02-16T13:12:03Z")

</div>

Closed on February 16, 2022, 1:12pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
