UNPKG

@nexusui/components

Version:

These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.

3 lines (2 loc) 580 B
"use client"; import{jsx as r}from"react/jsx-runtime";import{useFormContext as o,Controller as t}from"react-hook-form";import e from"@mui/material/FormControlLabel";import i from"@mui/material/Switch";const l=({name:l,label:a,rules:m,controllerProps:n,switchProps:s,...c})=>{const{control:p}=o();return r(t,{...n,name:l,control:p,rules:m,render:({field:{ref:o,...t}})=>r(e,{label:a,...c,control:r(i,{...t,"data-testid":"switch",checked:t.value,inputRef:o,...s,inputProps:{"aria-label":a,"data-testid":`NexusFormToggle-${l}-input`,...s?.inputProps}})})})};export{l as FormToggle};