Switch Group
A Switch Group collects several switches under one label and one value, for a screen of settings that are each on or off. Every row names its setting and carries its own switch, and the group reports the set that is currently on.
Rendered live, with the same build of the library you install.
SwitchGroup.tsx
import { useState } from 'react';import { NSwitchGroup } from '@nayan-ui/react';const items = [{ label: 'Release notes', value: 'releases' },{ label: 'Security alerts', value: 'security' },{ label: 'Weekly digest', value: 'digest' }];const SwitchGroup = () => {const [value, setValue] = useState<string[]>(['releases', 'security']);return (<div><div className="max-w-sm"><NSwitchGroup label="Email me about" items={items} value={value} onChange={setValue} /></div></div>);};export default SwitchGroup;
| Name | Type | Default | Details |
|---|---|---|---|
| items | NSwitchGroupItem[] | Required | The items prop. |
| value | string[] | Required | The values currently switched on. |
| onChange | (selected: string[]) => void | Required | The onChange prop. |
| orientation | 'horizontal' | 'vertical' | 'vertical' | The orientation prop. |
| label | string | Optional | The label prop. |
| showLabel | boolean | true | The showLabel prop. |
| disabled | boolean | false | The disabled prop. |
| id | string | Optional | The id prop. |
| className | string | '' | The className prop. |
| labelClassName | string | '' | The labelClassName prop. |
| itemClassName | string | '' | The itemClassName prop. |
| switchClassName | string | '' | The switchClassName prop. |
Other components solving nearby problems.