Next: (hygguile components select), Previous: (hygguile components rating), Up: API
Render a segmented control: a radio group drawn as one bar of choices.
The control is a ‘<fieldset>‘ named by its ‘<legend>‘, holding one radio per choice. It therefore behaves exactly like every other choice in a form – one tab stop, arrow keys to move, the chosen row announced as checked – and it submits its value with scripting off. Nothing about the bar is a script: the highlight follows the checked radio in the stylesheet.
Keep the set small. A segmented control says "one of these few, and you can see them all"; a list of more than about five choices reads better as a ‘select’ or as radios stacked down the page.
The name of the group, rendered as a ‘<legend>‘.
The form field name.
An explicit identifier for the group; defaults to name.
A list of strings or (value . label) pairs.
The value that starts chosen; the first choice when nothing is given.
Whether a choice has to be made.
Whether the whole control is disabled.
Optional helper copy, linked with aria-describedby.
Optional validation message, announced with role="alert".
#t to mark the control as answered, or a string to say so in
words.
Stretch the bar across its container and share the width between choices.
Classes for the field wrapper.
Classes for the legend.
Classes for the helper copy.
Classes for the error message.
Classes for the success message.
(segmented-control #:label "Range"
#:name "range"
#:options '((day . "Day") (week . "Week") (month . "Month"))
#:selected "week")
Render one choice of a segmented control.
A page normally asks for the whole control with segmented-control
and never writes an item itself; this is exported for the case where a
page has to lay the choices out around something else (a divider, a
disabled group).
The item is a ‘<label>‘ holding its own radio, so the label and the control are one target, and the stylesheet can style the checked state with a sibling selector rather than a script.
The value submitted when this choice is chosen.
The text shown on the choice.
The shared form field name identifying the group.
An explicit identifier; defaults to one derived from value.
Whether this choice starts chosen.
Whether this choice cannot be chosen.
Classes for the label.
(segmented-item #:value "day" #:label "Day" #:name "range" #:checked #t)
Next: (hygguile components select), Previous: (hygguile components rating), Up: API