NoRedInk/noredink-ui/23.0.1

NOTE: the latest version is 35.9.3

Nri.Ui.Switch.V2

Patch Changes:

- Fix cursor styles when hovering over the transparent checkbox

Changes from V1:

- Fixes invalid ARIA use, [conformance requirements](https://www.w3.org/TR/html-aria/#docconformance)
- labels should only support strings (this is the only way they're actually used in practice)
- extends API to be more consistent with other form/control components
- Use Colors values instead of hardcoded hex strings
- Move the status (selected or not selected) to the list api
- REQUIRE label and id always
- Move custom attributes to the container
- change disabled to take a bool (which I think is the slighty more common pattern)
- Adds `role="switch"`
{ label : String
, id : String
}
-> List (Attribute msg)
-> Html msg

Render a switch. The boolean here indicates whether the switch is on or not.

Attributes

type Attribute msg
selected : Bool -> Attribute msg

What is the status of the Switch, selected or not?

containerCss : List Style -> Attribute msg

Adds CSS to the Switch container.

labelCss : List Style -> Attribute msg

Adds CSS to the element containing the label text.

Note that these styles don't apply to the literal HTML label element, since it contains the icon SVG as well.

custom : List (Attribute Never) -> Attribute msg

Pass custom attributes through to be attached to the underlying input.

Do NOT use this helper to add css styles, as they may not be applied the way you want/expect if underlying styles change. Instead, please use containerCss or labelCss.

nriDescription : String -> Attribute msg
testId : String -> Attribute msg
onSwitch : (Bool -> msg) -> Attribute msg

Specify what happens when the switch is toggled.

disabled : Bool -> Attribute msg

Explicitly specify that you want this switch to be disabled. If you don't specify onSwitch, this is the default, but it's provided so you don't have to resort to filterMap or similar to build a clean list of attributes.

Modules