Skip to content

Commit bae8fd2

Browse files
Fix default value in docstring and added example (#159)
1 parent 6a5b041 commit bae8fd2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/optioninput.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ radiobuttons(T::WidgetTheme, vals; kwargs...) =
231231
"""
232232
```
233233
checkboxes(options::AbstractDict;
234-
value = first(values(options)))
234+
value = valtype(options)[]
235235
```
236236
237237
A list of checkboxes whose item labels are the keys of options.
238-
Tthe observable will hold an array containing the values
238+
The observable will hold an array containing the values
239239
of all selected items,
240240
e.g. `checkboxes(OrderedDict("good"=>1, "better"=>2, "amazing"=>9001))`
241241
@@ -264,6 +264,17 @@ Note that the `options` can be modified from the widget directly:
264264
```julia
265265
wdg[:options][] = ["c", "d", "e"]
266266
```
267+
268+
To create checkboxes that are already checked off when shown, one can use the `value` keyword:
269+
270+
```julia
271+
options = ["a", "b", "c"]
272+
value = ["a", "c"]
273+
checkboxes(options, value = value)
274+
```
275+
276+
The boxes "a" and "c" will be checked off when the checkboxes widget is shown.
277+
Both `options` and `value` can be Observables.
267278
"""
268279
checkboxes(T::WidgetTheme, options; kwargs...) =
269280
Widget{:checkboxes}(multiselect(T, options; typ="checkbox", kwargs...))

0 commit comments

Comments
 (0)