Level switch
One row's access level (No · Read · Edit): native radios in a fieldset, posts without JavaScript, selected in the row's product accent.
Preview
ordNX access for an assistant Edit is shown but disabled when the connection does not allow writing.
<fieldset class="nx-level" data-nx-product="ord">
<legend class="nx-sr-only">ordNX</legend>
<span class="nx-level__track">
<label class="nx-level__opt">
<input type="radio" name="demo-level" value="none"/>
<span>No</span>
</label>
<label class="nx-level__opt">
<input type="radio" name="demo-level" value="read" checked/>
<span>Read</span>
</label>
<label class="nx-level__opt"
title="Not allowed on this connection">
<input type="radio" name="demo-level" value="write" disabled/>
<span>Edit</span>
</label>
</span>
</fieldset><NxLevelSwitch
name="product:ordnx"
label="ordNX"
product="ord"
defaultValue="read"
options={[
{ value: "none", label: "No" },
{ value: "read", label: "Read" },
{
value: "write",
label: "Edit",
disabled: true,
title: "Not allowed on this connection",
},
]}
/>API
React props (NxKit)
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
name | string | Required | Form field name. | |
label | ReactNode | Required | Group name (legend). | |
options | { value; | Required | Levels, lowest first. | |
value / defaultValue | T | Controlled or uncontrolled selection. | ||
product | NxProduct | Accent of the selected option. | ||
hideLabel | boolean | true | Visually hide the legend. |
Classes
| Class | Description |
|---|---|
.nx-level | Fieldset |
.nx-level__track | Segmented track |
.nx-level__opt | One level; checked uses accent-100 / accent-700 |
Accessibility
- fieldset + legend + native radios: arrow keys move, the group is named, disabled levels stay visible with a title.
Do / Don’t
- Do: Disable a level that is not available and say why.Don't hide it: the person must see that it exists.