First attempt:
\usetikzlibrary{calc}
\def\SLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,0);
\coordinate (end) at (#1,0);
\coordinate (mark) at ($(start)!#2!(end)$);
\draw[line width=0.2cm, line cap=round, lightgray] (start) -- (end);
\shade[ball color=blue!30!cyan] (mark) circle(0.15cm);
}
}
SLIDER \SLIDER{2.5cm}{0.7}
Update: second attempt
Emboss shadow effect in the bar, more types or markers:
\usetikzlibrary{calc}
\def\CircleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, bottom color=lightgray, top color=black, middle color=lightgray] (start) rectangle (end);
\shade[draw=darkgray, rounded corners=0.2mm, ball color=blue!20!cyan] (mark) circle(.15) ;
}
}
\def\SquareSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, bottom color=lightgray, top color=black, middle color=lightgray] (start) rectangle (end);
\shade[draw=darkgray, rounded corners=0.2mm, ball color=blue!20!cyan] (mark) +(-.15,-.15) rectangle +(.15, .15) ;
}
}
\def\TriangleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, bottom color=lightgray, top color=black, middle color=lightgray] (start) rectangle (end);
\shade[draw=darkgray, rounded corners=0.2mm, ball color=blue!20!cyan] (mark) ++(-.15,-.15) -- ++(.15,-.15) -- ++(.15,.15) -- ++(0,.3) -- ++(-.3,0) -- cycle ;
}
}
\CircleSLIDER{2.5cm}{0.4}
\SquareSLIDER{2.5cm}{0.7}
\TriangleSLIDER{2.5cm}{0.3}
Update 2
Now that shadows, gradients, and reflections are considered outrée in UI design, may be you prefer this version:
\usetikzlibrary{calc}
\def\CircleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, fill=lightgray] (start) rectangle (end);
\fill[draw=gray, rounded corners=0.2mm, fill=blue!20!cyan] (mark) circle(.15) ;
}
}
\def\SquareSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray,fill=lightgray] (start) rectangle (end);
\fill[draw=gray, rounded corners=0.2mm, fill=blue!20!cyan] (mark) +(-.15,-.15) rectangle +(.15, .15) ;
}
}
\def\TriangleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, fill=lightgray] (start) rectangle (end);
\fill[draw=gray, rounded corners=0.2mm, fill=blue!20!cyan] (mark) ++(-.15,-.15) -- ++(.15,-.15) -- ++(.15,.15) -- ++(0,.3) -- ++(-.3,0) -- cycle ;
}
}
Update 3
Last one, I promise :-)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shadows,shadows.blur}
\def\IosSevenSlider#1#2{
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,0);
\coordinate (end) at (#1,0);
\coordinate (mark) at ($(start)!#2!(end)$);
\useasboundingbox (start|- 0,-.25) rectangle (end|- 0, .25);
\draw[line width=0.4mm, line cap=round, blue!50!cyan]
(start) -- (mark) edge[lightgray] (end);
\node[fill=white, draw=lightgray, very thin,
blur shadow={shadow xshift=0pt, shadow opacity=20, shadow yshift=-0.9mm,
shadow blur steps=6, shadow blur radius=0.3mm},
circle, minimum size=0.25cm, inner sep=0pt] at (mark) {};
}
}
\begin{document}
\setlength{\fboxsep}{0pt}
\fbox{\IosSevenSlider{2.5cm}{0.7}}
\end{document}