.md →
Fader API#
Fader is a linear slider drawn to look like a channel fader on a mixing
console: a cap slides along a slot, with a configurable tick scale (e.g. dB
marks) alongside the track. It is vertical by default with max_value at the
top; pass orientation="horizontal" for a left-to-right fader.
Ticks are configurable — ticks=N for evenly spaced marks, a list of values, or
(value, label) pairs. Pass steps instead for a stepped fader that snaps
to discrete detents. With midi=True the fader shows a "MIDI learn" button:
click it, move a control on your hardware, and the next control-change message
binds to the fader (Web MIDI, Chromium browsers). The binding is remembered in
browser localStorage so it survives a restart.
See also: Knob for the rotary console version, and HoverSlider for a linear slider that also reports the value under the pointer.
Bases: AnyWidget
Mixing-console style fader: a cap that slides along a track.
A linear slider drawn to look like a channel fader, with a configurable
tick scale (e.g. dB marks) alongside the track. Vertical by default, with
max_value at the top; pass orientation="horizontal" for a
left-to-right fader.
Examples:
import marimo as mo
from wigglystuff import Fader
level = mo.ui.anywidget(
Fader(min_value=-60, max_value=6, value=0, ticks=[-60, -20, -6, 0, 6],
label="Level")
)
level
Create a Fader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Optional[float]
|
Initial value; defaults to |
None
|
min_value
|
float
|
Lower bound of the value range (bottom / left). |
0.0
|
max_value
|
float
|
Upper bound of the value range (top / right). |
100.0
|
step
|
float
|
Snap increment in value units (must be > 0). |
1.0
|
ticks
|
TickSpec
|
Tick/scale marks. |
None
|
steps
|
Optional[Sequence[Any]]
|
Discrete detents to snap to (a stepped fader). Same shape as
|
None
|
orientation
|
str
|
|
'vertical'
|
length
|
int
|
Track length in pixels (the long dimension). |
200
|
label
|
str
|
Optional text label shown above the fader. |
''
|
show_value
|
bool
|
Render the current value as text next to the fader. |
True
|
color
|
str
|
Optional CSS color for the filled track and cap. Empty string uses the theme default. |
''
|
midi
|
bool
|
Show a "MIDI learn" button. Click it, then move a control on
your hardware; the next control-change (CC) message binds to
this fader and drives its value. Uses the Web MIDI API (Chromium
browsers, secure context). Read the binding back via
|
False
|
midi_cc
|
int
|
Bind a control-change number (0-127) up front instead of
learning it. |
-1
|
midi_channel
|
int
|
MIDI channel (0-15) for the binding, or |
-1
|
midi_key
|
str
|
localStorage key for persisting the learned binding across
restarts. Defaults to |
''
|
midi_scope
|
Optional[str]
|
Namespace for the persisted binding, so different notebooks don't collide. Empty (default) uses the browser's URL path automatically; pass an explicit string to pin it (or to intentionally share a mapping across notebooks). |
None
|
**kwargs
|
Any
|
Forwarded to |
{}
|
Source code in wigglystuff/fader.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | |
Synced traitlets#
| Traitlet | Type | Notes |
|---|---|---|
value |
float |
Current value, mapped along the track. |
min_value |
float |
Lower bound (bottom / left). |
max_value |
float |
Upper bound (top / right). |
step |
float |
Snap increment in value units (continuous mode). |
ticks |
list[dict] |
Normalized {"value", "label"} tick marks. |
steps |
list[float] |
Discrete detents to snap to; empty means continuous. |
orientation |
str |
"vertical" (default) or "horizontal". |
length |
int |
Track length in pixels (the long dimension). |
label |
str |
Optional text label shown above the fader. |
show_value |
bool |
Render the current value as text next to the fader. |
color |
str |
CSS color for the filled track and cap. Empty follows the theme. |
midi |
bool |
Show the MIDI-learn button and listen for control-change. |
midi_cc |
int |
Bound control-change number (0-127), or -1 when unbound. |
midi_channel |
int |
Bound MIDI channel (0-15), or -1 for any. |
midi_device |
str |
Name of the bound MIDI input device. |
midi_supported |
bool |
Whether the browser exposes Web MIDI (set from JS). |
midi_learning |
bool |
Whether the fader is currently in learn mode. |
midi_key |
str |
localStorage key for the persisted binding (defaults to label). |
midi_scope |
str |
Namespace for the binding; empty uses the browser URL path. |