";display:inline-block}.typography-module--codeHeading--Yg3Xq .typography-module--videoLink--GsnE\+,.typography-module--h5--H6M7\+ .typography-module--videoLink--GsnE\+{background:none;border:1px solid var(--color-secondary);color:#fff;font-family:Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:14px;margin-bottom:-5px;margin-left:15px;padding:5px 10px;text-decoration:none;text-transform:uppercase}.typography-module--h1--qjW1z{border-bottom:2px solid var(--color-secondary);display:inline-block;font-size:24px;font-weight:400;margin:40px auto;padding-bottom:5px}.typography-module--h5--H6M7\+{border-bottom:1px solid var(--color-light-blue);font-size:18px;font-weight:500;margin:50px 0 10px;padding-bottom:15px;text-align:left}.typography-module--h5--H6M7\+>code{font-size:18px!important}.typography-module--typeText--q5Z2M{color:var(--color-light-pink)!important;font-family:monospace;font-size:14px;font-weight:400}.typography-module--note--cVmyF{color:var(--color-light-pink)}.typography-module--codeBlock--PR5gR{display:block;padding:10px}.typography-module--error--56gAb{color:var(--color-light-pink);font-size:12px}@media (min-width:768px){.typography-module--h1--qjW1z{font-size:36px;font-weight:700}.typography-module--heading--AdW8T,.typography-module--headingWithTopMargin--u9yDD{font-size:55px!important;margin:80px auto 10px}.typography-module--subHeading--mpfqn{font-size:18px;margin-bottom:20px;margin-top:5px;max-width:575px}.typography-module--title--BXcb5{font-size:1.3rem;line-height:1.5;margin-top:20px}h2.typography-module--title--BXcb5{margin-top:40px}.typography-module--headingWithTopMargin--u9yDD{margin-top:70px}.typography-module--questionTitle--mEgBJ{border-left:5px solid var(--color-light-pink);line-height:1;padding-left:10px}}@media (min-width:1024px){.typography-module--h1--qjW1z{border-bottom:3px solid var(--color-secondary);font-size:50px;line-height:1.3;margin-top:60px}.typography-module--homeParagraph--fc-KW{font-size:20px;line-height:1.5}.typography-module--heading--AdW8T,.typography-module--headingWithTopMargin--u9yDD{margin-top:20px}.typography-module--headingWithTopMargin--u9yDD{margin-top:70px}}.SideMenu-module--menu--VmHHT{display:none;position:relative}.SideMenu-module--arrow--N6ler{color:var(--color-light-pink);position:relative}.SideMenu-module--arrowLast--2JNi7:before{border-left:1px solid #ec5990;content:"";height:43%;left:0;position:absolute;top:0}.SideMenu-module--size--49S36{color:currentColor;font-size:10px;margin-left:5px}@media (min-width:768px){.SideMenu-module--menu--VmHHT{display:block}.SideMenu-module--menu--VmHHT>div{margin-top:-10px;position:fixed}.SideMenu-module--menu--VmHHT>div>ul{height:calc(100vh - 236px);margin-top:0;max-width:230px;overflow-y:auto;padding:0}.SideMenu-module--menu--VmHHT>div>ul>li{display:flex;font-size:15px;line-height:22px;padding-bottom:8px}.SideMenu-module--menu--VmHHT>div>ul>li>a{line-height:20px;padding-left:6px;text-decoration:none}.SideMenu-module--menu--VmHHT>div>ul>li>a,.SideMenu-module--menu--VmHHT>div>ul>li>button{background:none;border:none;border-bottom:1px solid transparent;color:currentColor;cursor:pointer;margin:0 7px;padding:0;text-align:left;transition:all .3s}.SideMenu-module--menu--VmHHT>div>ul>li>a:hover,.SideMenu-module--menu--VmHHT>div>ul>li>button:hover{border-bottom:1px solid var(--color-light-pink)}.SideMenu-module--lightMenu--CeYeb>div>ul>li>a,.SideMenu-module--lightMenu--CeYeb>div>ul>li>button{background:none;border:none;border-bottom:1px solid transparent;color:var(--color-black);cursor:pointer;text-align:left;transition:all .3s}.SideMenu-module--lightMenu--CeYeb>div>ul>li>a:hover,.SideMenu-module--lightMenu--CeYeb>div>ul>li>button:hover{background:none;border-bottom:1px solid var(--color-light-pink)!important}}@media (min-height:920px){.SideMenu-module--menu--VmHHT>div>ul>li{padding-bottom:12px}}.SideMenu-module--titleList--TbSVu{width:200px}.SideMenu-module--code--KS-7W{color:var(--color-light-pink);display:inline-table;font-size:12px;position:relative;top:2px}@media (min-width:1024px){.SideMenu-module--menu--VmHHT{margin-top:-75px}.SideMenu-module--menu--VmHHT>div>ul{margin-top:0;max-width:260px}.SideMenu-module--menu--VmHHT>ul{height:calc(100vh - 200px);max-width:250px}.SideMenu-module--titleList--TbSVu{margin-bottom:20px;width:250px}.SideMenu-module--titleList--TbSVu>h2{padding:0}}@media (min-width:1280px){.SideMenu-module--menu--VmHHT>ul{max-width:270px}}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs{display:block}.SideMenu-module--menuItem--7nGPs code{position:relative;top:-1px}.SideMenu-module--menuItem--7nGPs li{padding:3px 0}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul{padding-left:10px}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul>li{border-left:1px solid var(--color-light-pink);padding-left:20px;position:relative}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul>li:last-child{border-left:none;position:relative}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul>li:last-child:after{border-left:1px solid var(--color-light-pink);bottom:0;content:"";height:58%;left:0;position:absolute;top:0}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul>li:before{border-bottom:1px solid var(--color-light-pink);bottom:12px;content:"";left:0;position:absolute;width:10px}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul a{border-bottom:1px solid transparent;color:currentColor;text-decoration:none}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul a:hover{border-bottom:1px solid var(--color-light-pink)}.SideMenu-module--menu--VmHHT li.SideMenu-module--menuItem--7nGPs>ul>li{list-style:none}.SideMenu-module--menu--VmHHT ul li a.SideMenu-module--isActive--btyl-{border-bottom:1px solid var(--color-secondary)}.button-module--codeAsLink--cyiiu,.button-module--links--0uKag{color:var(--color-link)}.button-module--codeAsLink--cyiiu{-webkit-appearance:none;appearance:none;background:none;border:none;color:var(--color-link)!important;cursor:pointer;padding:0;text-decoration:underline}.button-module--buttonsGroup--\+tPIa{grid-column-gap:20px;display:grid;grid-template-columns:repeat(2,1fr);margin:0 auto}.button-module--button--KCsdZ,.button-module--darkButton--gqVhH,.button-module--pinkButton--J3bsf,.button-module--primaryButton--veRGX{-webkit-appearance:none;border-radius:4px;color:#fff;cursor:pointer;display:inline-block;font-size:16px;font-weight:400;line-height:1;margin:20px 0;padding:16px 10px;transition:all .3s}.button-module--primaryButton--veRGX{background:var(--color-primary);border:1px solid var(--color-light-blue);box-sizing:border-box}a.button-module--primaryButton--veRGX{text-decoration:none}a.button-module--primaryButton--veRGX:hover{color:#fff}.button-module--darkButton--gqVhH,.button-module--pinkButton--J3bsf{background:var(--color-light-pink);border:1px solid var(--color-light-pink);letter-spacing:.5rem;text-transform:uppercase;width:100%}.button-module--pinkButton--J3bsf:hover{background:var(--color-secondary)}.button-module--darkButton--gqVhH{background:#000;border:1px solid var(--color-light-pink);color:#fff}.button-module--darkButton--gqVhH:hover{background:var(--color-primary);border:1px solid var(--color-secondary)}.button-module--darkButton--gqVhH:active{background:#000}@-webkit-keyframes button-module--moving--3Cfwn{0%{-webkit-transform:translateX(0);transform:translateX(0)}to{-webkit-transform:translateX(5px);transform:translateX(5px)}}@keyframes button-module--moving--3Cfwn{0%{-webkit-transform:translateX(0);transform:translateX(0)}to{-webkit-transform:translateX(5px);transform:translateX(5px)}}.button-module--primaryButton--veRGX:hover>span{-webkit-animation:button-module--moving--3Cfwn .4s linear infinite;animation:button-module--moving--3Cfwn .4s linear infinite;-webkit-animation-direction:alternate;animation-direction:alternate;display:inline-block}.button-module--primaryButton--veRGX:active{background:#000}.button-module--primaryButton--veRGX:hover{border:1px solid var(--color-secondary);box-shadow:0 0 5px #000}@media (min-width:768px){.button-module--primaryButton--veRGX{font-size:18px;font-weight:400;margin:40px 0;padding:15px 30px}.button-module--buttonsGroup--\+tPIa{grid-column-gap:30px}}.SortableContainer-module--list--F-fra{background:var(--color-primary);border:1px solid var(--color-light-blue);border-radius:4px;color:#fff;cursor:move;list-style:none;margin-bottom:10px;padding:14px 14px 14px 50px;position:relative}.SortableContainer-module--list--F-fra>svg{fill:#fff;display:inline-block;left:15px;position:absolute;top:17px;width:20px}.SortableContainer-module--editPanel--flPzp{float:right}.SortableContainer-module--editPanel--flPzp>button{background:var(--color-light-blue);border:1px solid transparent;color:#fff;cursor:pointer;font-size:14px;letter-spacing:1px;padding:1px 8px;position:relative;text-transform:uppercase;top:-2px}.SortableContainer-module--editPanel--flPzp>button:hover{background:var(--color-primary);border:1px solid var(--color-secondary)}.SortableContainer-module--editPanel--flPzp>button:first-child{margin-right:14px}.SortableContainer-module--sortableWrapper--AwJyZ{margin-top:30px}.SortableContainer-module--sortableWrapper--AwJyZ>ul{margin-left:0;padding-left:0}.CodeArea-module--buttonWrapper--Vjxzn{display:flex;position:absolute;right:5px;top:10px}.CodeArea-module--button--AWZ2D{align-items:center;border:none;border-radius:0;color:#fff;cursor:pointer;display:none;font-size:13px;height:34px;margin:0 3px;padding:0 10px;right:20px;text-transform:uppercase;top:10px;z-index:1}.CodeArea-module--codeLink--2VOvA{background:var(--color-light-blue);border:1px solid transparent}.CodeArea-module--button--AWZ2D:hover{background:var(--color-secondary);color:#fff}@media (min-width:768px){.CodeArea-module--button--AWZ2D{display:flex}}.CodeArea-module--copyButton--hlR5e{background:none;border:1px solid transparent;color:currentColor}.CodeArea-module--active--SL5FI,.CodeArea-module--copyButton--hlR5e:hover{background:none;border:1px solid var(--color-secondary);color:#fff}.CodeArea-module--active--SL5FI,.CodeArea-module--copyButton--hlR5e:hover span{background:var(--color-primary)}.CodeArea-module--linkToSandBox--GUUyV{color:inherit;line-height:2;right:115px;text-decoration:none}.CodeArea-module--linkToSandBox--GUUyV>svg{display:inline-block;height:18px;margin-right:8px;position:relative}.CodeArea-module--wrapper--N6VkZ pre{line-height:1.5!important}.CodeArea-module--wrapper--N6VkZ pre code{display:none}.CodeArea-module--wrapper--N6VkZ pre code.CodeArea-module--showCode--e4jec{display:block}.GetStarted-module--installCode--yAeCR{background:var(--color-button-blue)!important;border-radius:4px;display:block;margin-top:20px;padding:13px 20px}.GetStarted-module--lightInstallCode--hw6Rj{background:#fff!important;border:1px solid var(--color-black)}.GetStarted-module--copyButton--AxXYW{background:var(--color-light-blue);border:1px solid transparent;color:#fff;cursor:pointer;display:none;float:right;font-size:13px;margin-top:-2px;text-transform:uppercase}.GetStarted-module--copyButton--AxXYW:hover{background:none;border:1px solid var(--color-secondary);color:#fff}.GetStarted-module--copyButton--AxXYW:hover span{background:var(--color-primary)}@media (min-width:768px){.GetStarted-module--copyButton--AxXYW{display:inline-block}}.table-module--table--r0Usy{border-collapse:collapse;margin-top:15px}.table-module--table--r0Usy td{line-height:1.4;padding:6px 15px 6px 0}.table-module--table--r0Usy td>h5:first-child,.table-module--table--r0Usy td>p:first-child,.table-module--table--r0Usy td>ul li:first-child>p,.table-module--table--r0Usy td>ul:first-child{margin-top:0!important}.table-module--table--r0Usy td>p:last-child{margin-bottom:0}.table-module--table--r0Usy td:last-child{padding-right:0}.table-module--table--r0Usy td>pre{margin:0}.table-module--tableWrapper--P79uZ{-webkit-overflow-scrolling:touch;overflow-x:auto;overflow-y:hidden}@media (min-width:768px){.table-module--mobileTypeText--ZtDL6{display:inline;margin-top:0}.table-module--tableWrapper--P79uZ::-webkit-scrollbar{height:8px}.table-module--tableWrapper--P79uZ::-webkit-scrollbar-track{background:var(--color-button-blue);border-radius:10px}.table-module--tableWrapper--P79uZ::-webkit-scrollbar-thumb{background:var(--color-medium-blue);border-radius:10px}.table-module--tableWrapper--P79uZ::-webkit-scrollbar-thumb:hover{background:var(--color-light-pink)}}.ApiRefTable-module--fieldset--1YTVx{border:1px solid var(--color-light-blue);border-radius:4px;padding:10px 15px}.ApiRefTable-module--fieldset--1YTVx>legend{padding:0 10px}.ApiRefTable-module--fieldset--1YTVx>label{cursor:pointer;display:block;padding-bottom:15px}.ApiRefTable-module--fieldset--1YTVx>label:nth-child(2){padding-top:10px}.ApiRefTable-module--fieldset--1YTVx>label>input{margin-right:10px;position:relative;top:-2px}.container-module--container--rk8Zx{padding-top:45px}.container-module--subContainer--ufvI9{margin:0 auto;max-width:768px}.container-module--centerContent--rby-J{margin:0 auto;max-width:1024px;text-align:center}.container-module--centerContent--rby-J svg{display:none}.container-module--wrapper--wVFxQ{margin:0 auto;max-width:1235px;overflow:hidden;padding:0 15px 100px 20px;position:relative}.container-module--centerContent--rby-J p{margin:0 auto;max-width:730px}.container-module--centerContent--rby-J h3{margin:0}@media (min-width:768px){.container-module--container--rk8Zx{padding-top:0}.container-module--centerContent--rby-J svg{display:block;margin:100px auto -30px;text-align:center;width:85px}.container-module--wrapper--wVFxQ{display:grid;grid-template-columns:250px minmax(0,1fr)}}@media (min-width:1024px){.container-module--wrapper--wVFxQ{display:grid;grid-template-columns:300px minmax(0,1fr)}.container-module--centerContent--rby-J svg{margin:100px auto -50px}}.Form-module--code--tHuaD{font-size:.7rem;line-height:1.6;padding:0 20px;white-space:pre-wrap}.Form-module--wrapper--3otFW{grid-column-gap:40px;display:grid;grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));margin:20px auto 0;max-width:1440px;min-height:700px;transition:all 1s}.Form-module--demoForm--k1037{flex:1 1}.Form-module--demoForm--k1037>input,.Form-module--demoForm--k1037>select,.Form-module--input--QrVnC{border-radius:4px;box-sizing:border-box;display:block;font-size:.9rem;margin-bottom:10px;padding:6px 10px;width:100%}.Form-module--demoForm--k1037>select:not([multiple]){height:43px}.ResourcePage-module--root--wLZ0J{margin:0 20px 40px;padding-bottom:40px}.ResourcePage-module--tagWrapper--X-fEP{display:flex;justify-content:flex-end}.ResourcePage-module--contentListLayout--otyXn .ResourcePage-module--tagWrapper--X-fEP{position:absolute;right:0;top:1rem}.ResourcePage-module--tag--6WRdq{background:#fff;border-radius:8px;color:var(--color-primary);display:block;font-size:10px;font-weight:500;margin:0;text-align:center;text-transform:uppercase;width:25px}.ResourcePage-module--contentList--z6QDD{list-style:none;padding:0;width:100%}.ResourcePage-module--contentListLayout--otyXn{display:flex;flex-direction:column;gap:0;margin:0 auto;max-width:1280px}.ResourcePage-module--searchFilter--kNkno{border-radius:25px;box-sizing:border-box;display:flex;font-size:16px;line-height:24px;margin:10px auto;max-width:500px;padding:3px 20px;width:100%}@media (min-width:768px){.ResourcePage-module--searchFilter--kNkno{padding:8px 20px}}.ResourcePage-module--searchFilter--kNkno:focus{border:1px solid var(--color-light-pink);cursor:default;outline:none}.ResourcePage-module--article--9gFP3{margin-bottom:15px}.ResourcePage-module--article--9gFP3 img{border:1px solid var(--color-light-blue);border-radius:4px;height:100px;object-fit:contain;width:100%}.ResourcePage-module--article--9gFP3>a{color:#fff;text-decoration:none}.ResourcePage-module--article--9gFP3>a:hover{color:var(--color-secondary)}.ResourcePage-module--article--9gFP3 h3{-webkit-line-clamp:2;font-size:18px;font-weight:500}.ResourcePage-module--article--9gFP3 h3,.ResourcePage-module--article--9gFP3 p{-webkit-box-orient:vertical;display:-webkit-box;margin:5px 0;overflow:hidden;text-overflow:ellipsis}.ResourcePage-module--article--9gFP3 p{-webkit-line-clamp:4}p.ResourcePage-module--author--6g95h{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden;text-overflow:ellipsis}.ResourcePage-module--name--Qg6je{font-weight:600}.ResourcePage-module--contentList--z6QDD img{display:block;margin:0 auto;width:200px}.ResourcePage-module--contentList--z6QDD img:hover{border:13px solid var(--color-light-blue);opacity:.8;transition:all .3s ease-out}.ResourcePage-module--contentList--z6QDD>li{margin-bottom:40px;overflow:hidden;position:relative}.ResourcePage-module--contentListLayout--otyXn>li{border-bottom:1px solid var(--color-light-blue);list-style:none;margin-bottom:1rem;position:relative}.ResourcePage-module--contentList--z6QDD li>svg{fill:#091129;height:100%;position:absolute;width:100%;z-index:2}.ResourcePage-module--interests--ksRJM{list-style:none;margin:0;padding:0}.ResourcePage-module--interests--ksRJM>ul{border:1px solid var(--color-light-blue);display:flex;flex-direction:row;font-size:14px;margin:0;padding:8px 0;text-align:center}.ResourcePage-module--interests--ksRJM li{border-right:1px solid var(--color-light-blue);flex:1 1;font-size:13px;list-style:none}.ResourcePage-module--interests--ksRJM li:last-child{border:none}.ResourcePage-module--twitter--OnOpd:hover>svg{fill:var(--color-secondary)}.ResourcePage-module--layoutButtons--y-uDn{align-items:center;display:flex;justify-content:center;margin-bottom:-2rem;margin-top:2rem}@media (min-width:768px){.ResourcePage-module--contentList--z6QDD{grid-gap:30px;display:grid;grid-template-columns:repeat(4,1fr);margin:0 auto;max-width:1280px}.ResourcePage-module--interests--ksRJM>ul{flex-direction:column;padding:8px 20px;text-align:left}.ResourcePage-module--interests--ksRJM>ul>li{border-right:0}.ResourcePage-module--contentList--z6QDD img{transition:all .3s ease-in;width:100%}}@media (min-width:1024px){.ResourcePage-module--interests--ksRJM>ul{flex-direction:row;padding-left:0;padding-right:0;text-align:center}.ResourcePage-module--interests--ksRJM>ul>li{border-right:1px solid var(--color-light-blue)}}.media-module--media--7roxW{display:flex;flex-direction:column;gap:2rem;grid-template-columns:1fr 1fr;margin:3rem auto;max-width:800px}.media-module--media--7roxW div{align-items:center;display:flex;flex-direction:column}.media-module--media--7roxW p{font-size:12px}.media-module--media--7roxW img{border-radius:10px;width:100%}img.media-module--logo--iMmgG{height:200px;width:200px}@media (min-width:768px){.media-module--media--7roxW{display:grid;gap:2rem;grid-template-columns:1fr 1fr;margin:3rem auto}}.TabGroup-module--buttonTabGroup--jUvjm{display:grid;grid-auto-flow:column}.TabGroup-module--buttonTabGroup--jUvjm>button{background:var(--color-primary);background:#000;border:none;border-top:1px solid var(--color-secondary);color:#fff;font-size:12px;padding:5px 8px;text-transform:uppercase;transition:all .3s}.TabGroup-module--buttonTabGroup--jUvjm>button:nth-child(n+2){margin-left:3px}.TabGroup-module--buttonTabGroup--jUvjm>button:hover{background:var(--color-secondary)}.TabGroup-module--buttonTabGroup--jUvjm>button:disabled{background:var(--color-primary);cursor:not-allowed}.TabGroup-module--lightButtonTabGroup--O4WMy>button{background:#fff;color:var(--color-black)}.TabGroup-module--lightButtonTabGroup--O4WMy>button:disabled,.TabGroup-module--lightButtonTabGroup--O4WMy>button:hover{color:#fff}@media (min-width:768px){.TabGroup-module--buttonTabGroup--jUvjm>button{padding:5px 20px}}.Header-module--logo--m3PE5{fill:#fff;background:var(--color-light-pink);border:8px solid #fff;border-radius:20px;height:80px;margin:-50px auto 0;padding:15px}.Header-module--desktopLogo--wUyS\+{background:var(--color-light-pink);border:4px solid #fff;border-radius:12px;display:none;height:60px;margin-right:5px;padding:8px;position:relative;top:10px}.Header-module--head--\+TjJE{align-items:center;display:flex;flex-direction:column;height:100vh;justify-content:center}.Header-module--videoHeading--PFYbY{border-bottom:2px solid var(--color-secondary);display:block;font-weight:400;line-height:2;margin-bottom:0;text-align:center}.Header-module--toggleGroup--ln4XL{border:1px solid var(--color-light-blue);border-radius:4px;display:none;text-align:center}.Header-module--toggleGroup--ln4XL>button{background:#000;border:1px solid transparent;color:#fff;cursor:pointer;padding:10px 25px;width:155px}.Header-module--toggleGroup--ln4XL>button:active{-webkit-transform:none;transform:none}.Header-module--toggleGroup--ln4XL.Header-module--smallToggleGroup--joRh0>button{background:#000;border:1px solid transparent;color:#fff;cursor:pointer;font-size:14px;padding:5px 15px;width:70px}.Header-module--toggleGroup--ln4XL>button:hover{background:var(--color-secondary)}.Header-module--toggleGroup--ln4XL>button:first-child{border-bottom-left-radius:4px;border-right:0;border-right:1px solid var(--color-light-blue);border-top-left-radius:4px}.Header-module--toggleGroup--ln4XL>button:disabled{background:transparent;color:currentColor;cursor:default}.Header-module--toggleGroup--ln4XL>button:last-child{border-bottom-right-radius:4px;border-left:0!important;border-top-right-radius:4px}.Header-module--video--UDY3\+{border:1px solid transparent;border-radius:10px;box-shadow:0 0 9px 0 #010817;cursor:pointer;display:block;transition:all .3s;width:100%}.Header-module--video--UDY3\+:hover{border:1px solid var(--color-secondary)}.Header-module--videoWrapperHide--a264I,.Header-module--videoWrapperShow--w4j\+3{margin-bottom:100px}@media (min-width:320px){.Header-module--logo--m3PE5{height:120px}}@media (min-width:768px){.Header-module--logo--m3PE5{display:none}.Header-module--head--\+TjJE{height:auto}.Header-module--videoHeading--PFYbY{display:none}.Header-module--desktopLogo--wUyS\+{fill:#fff;display:inline-block}.Header-module--toggleGroup--ln4XL{display:inline-block;margin:0 auto 50px}.Header-module--video--UDY3\+{height:400px;margin:0 auto 20px;width:700px}.Header-module--videoWrapperShow--w4j\+3{display:block;margin-bottom:0}.Header-module--videoWrapperHide--a264I{display:none;margin-bottom:0}.Header-module--logoHeading--h0K5X{margin-top:70px}}@media (min-width:1024px){.Header-module--video--UDY3\+{height:480px;width:800px}.Header-module--logoHeading--h0K5X{margin-top:50px}}@media (min-width:1280px){.Header-module--video--UDY3\+{height:600px;width:980px}}.Watcher-module--root--ElWyg{display:none}.Watcher-module--svgWrapper--MYM2\+{width:200px}.Watcher-module--watchGroup--yQ0cb{display:flex;height:50px}.Watcher-module--watchGroup--yQ0cb p{background:none;margin-top:5px;padding:0 0 0 50px}.Watcher-module--watchGroup--yQ0cb input[type=checkbox]{-webkit-appearance:none;appearance:none;background:var(--color-secondary);border:1px solid var(--color-secondary);border-radius:2px;height:20px;margin-left:-60px;margin-top:8px;width:20px}.Watcher-module--watchGroup--yQ0cb input[type=checkbox]:checked{background:#fff;border:1px solid #fff}.Watcher-module--svgWrapper--MYM2\+ svg{width:100%}.Watcher-module--svgWrapper--MYM2\+ svg path{stroke-dasharray:10;-webkit-animation:Watcher-module--dash--UoJtt 10s linear infinite normal;animation:Watcher-module--dash--UoJtt 10s linear infinite normal}@-webkit-keyframes Watcher-module--dash--UoJtt{0%{stroke-dashoffset:500}to{stroke-dashoffset:0}}@keyframes Watcher-module--dash--UoJtt{0%{stroke-dashoffset:500}to{stroke-dashoffset:0}}@media (min-width:768px){.Watcher-module--watcher--FuROo{display:block}.Watcher-module--root--ElWyg{display:grid;grid-template-columns:1fr 1fr 200px;margin:40px auto;max-width:800px}.Watcher-module--svgWrapper--MYM2\+{display:block;width:300px}.Watcher-module--svgWrapper--MYM2\+ svg{height:200px}}.CodeCompareSection-module--gridView--HXGS8{display:flex;flex-direction:column}.CodeCompareSection-module--gridView--HXGS8>div:first-child{order:1}.CodeCompareSection-module--gridView--HXGS8 iframe{box-shadow:0 0 20px #010817;display:none}.CodeCompareSection-module--fullScreen--Lms\+h{background:none;border-bottom-left-radius:4px;border-right:none;border-color:var(--color-secondary);border-top:none;border-top-color:var(--color-secondary);color:#fff;display:none;font-size:12px;position:absolute;right:0;z-index:1}.CodeCompareSection-module--fullScreen--Lms\+h:hover{background:var(--color-light-pink)}@media (min-width:1000px){.CodeCompareSection-module--gridView--HXGS8{grid-column-gap:40px;display:grid;grid-template-columns:repeat(auto-fit,minmax(250px,1fr));margin:0 auto;max-width:1024px}.CodeCompareSection-module--gridView--HXGS8 iframe{display:block}.CodeCompareSection-module--gridView--HXGS8>div:first-child{order:0}.CodeCompareSection-module--fullScreen--Lms\+h{display:block}.CodeCompareSection-module--display--N9eK6{display:none}}.CodePerfCompareSection-module--imgSection--XclBO{display:flex;flex-direction:column}.CodePerfCompareSection-module--imgSection--XclBO>img{border-radius:4px;box-shadow:0 0 8px #000;margin:20px 0;max-width:100%;object-fit:cover}.CodePerfCompareSection-module--imgSection--XclBO ul{list-style-type:none;margin:0 15px 0 0;min-width:250px;padding-left:0}.CodePerfCompareSection-module--imgSection--XclBO ul>li{font-size:16px;margin-left:0;padding:2px 0}.CodePerfCompareSection-module--videoWrapper--de-9z{-webkit-overflow-scrolling:touch;display:flex;height:450px;margin:20px 0 40px;overflow-x:auto;-ms-scroll-snap-type:x mandatory;scroll-snap-type:x mandatory;width:100%}.CodePerfCompareSection-module--videoWrapper--de-9z p{text-align:center}.CodePerfCompareSection-module--videoWrapper--de-9z>section:first-child{order:1}.CodePerfCompareSection-module--videoWrapper--de-9z>section{flex-shrink:0;height:100%;overflow-y:hidden;scroll-snap-align:start;width:100%}.CodePerfCompareSection-module--videoWrapper--de-9z>section>video{border-radius:10px;height:100%;width:100%}@media (min-width:768px){.CodePerfCompareSection-module--imgSection--XclBO{flex-direction:row;justify-content:center;max-width:80%}.CodePerfCompareSection-module--imgSection--XclBO ul{margin-left:250px}.CodePerfCompareSection-module--videoWrapper--de-9z>section:first-child{order:0}.CodePerfCompareSection-module--videoWrapper--de-9z{grid-column-gap:60px;display:grid;grid-template-columns:repeat(auto-fit,minmax(10rem,1fr));height:auto;margin:40px auto;max-width:768px;overflow-y:hidden}.CodePerfCompareSection-module--videoWrapper--de-9z>section>video{border-radius:10px;height:400px;margin-top:-44px}}@media (min-width:1024px){.CodePerfCompareSection-module--videoWrapper--de-9z>section>video{height:450px}}.IsolateRender-module--wrapper--EveAK{grid-gap:20px;display:grid;grid-template-columns:1fr 1fr;margin-top:20px;position:relative}.IsolateRender-module--wrapper--EveAK>div{display:none}.IsolateRender-module--wrapper--EveAK p{font-size:45px;font-weight:800;line-height:1.4;margin-top:160px}.IsolateRender-module--lightWrapper--eiVC5 p{background:#fff}.IsolateRender-module--wrapper--EveAK h2{font-size:14px}.IsolateRender-module--externalComponent--ipGtu{border:1px solid var(--color-secondary);border-radius:4px;font-size:14px;margin:20px 0;padding:10px 0}.IsolateRender-module--line--s4gzS{background:var(--color-blue);height:44%;left:50%;position:absolute;top:30%;width:1px;z-index:-1}@media (min-width:768px){.IsolateRender-module--wrapper--EveAK{grid-gap:40px;grid-template-columns:1fr 65px 1fr}.IsolateRender-module--wrapper--EveAK>div{display:block}.IsolateRender-module--wrapper--EveAK h2{font-size:24px;font-weight:400;padding-bottom:10px}}.Footer-module--footer--r9kKa{font-size:.8rem;font-weight:400;margin-bottom:60px;padding:40px 0;text-align:center}.Footer-module--footer--r9kKa a{color:#fff;text-decoration:none}.Footer-module--lightFooter--L6\+rf a{color:var(--color-black)}.Footer-module--footer--r9kKa a:hover{color:var(--color-light-pink);text-decoration:none}.Footer-module--lightFooter--L6\+rf a:hover{color:var(--color-light-pink)}.Footer-module--footer--r9kKa>p{font-size:13px}.Footer-module--links--NGNqE{border-bottom:1px solid var(--color-light-pink);display:block;margin:0 auto 20px;max-width:900px;padding:0 0 10px}.Footer-module--links--NGNqE>li{display:inline-flex}.Footer-module--links--NGNqE>li>a{color:#fff;min-height:48px;min-width:48px;padding:10px 12px;text-decoration:none}.Footer-module--lightFooter--L6\+rf .Footer-module--links--NGNqE>li>a{color:var(--color-black);font-weight:500}.Footer-module--lightFooter--L6\+rf .Footer-module--links--NGNqE>li>a:hover{color:var(--color-light-pink)}a.Footer-module--link--ixJIY{color:var(--color-primary)}.ApiGallery-module--root--BPA\+n{margin:60px auto 0;max-width:768px}@media (min-width:768px){.ApiGallery-module--root--BPA\+n{max-width:840px}}.ApiGallery-module--gallery--OhccF{grid-gap:25px;display:grid;grid-template-columns:1fr;list-style:none;margin:20px;padding:0}@media (min-width:768px){.ApiGallery-module--gallery--OhccF{grid-gap:25px;grid-template-columns:repeat(3,1fr);margin:60px auto;padding:0 20px}}@media (min-width:1024px){.ApiGallery-module--gallery--OhccF{max-width:1024px}}.ApiGallery-module--gallery--OhccF li{border:1px solid var(--color-light-blue);padding-bottom:30px;position:relative;transition:all .2s}.ApiGallery-module--gallery--OhccF li:hover{border:1px solid var(--color-secondary);box-shadow:2px 2px 0 4px #000;-webkit-transform:translate(-2px,-2px);transform:translate(-2px,-2px)}.ApiGallery-module--gallery--OhccF li a{align-items:flex-end;bottom:0;display:flex;font-size:14px;justify-content:flex-end;left:0;padding:12px 20px 12px 80px;position:absolute;right:0;top:0}.ApiGallery-module--gallery--OhccF h3{background:var(--color-button-blue);border-bottom:1px solid var(--color-light-blue);font-size:18px;font-weight:400;letter-spacing:1px;margin:0;padding:13px 20px;text-shadow:2px 2px #000}.ApiGallery-module--gallery--OhccF h3 code{letter-spacing:-1px;margin-right:5px}.ApiGallery-module--gallery--OhccF p{font-size:14px;margin:20px}.ApiGallery-module--versionControl--cFsH7{padding-right:20px;text-align:right}.ApiGallery-module--versionControl--cFsH7>div{display:inline-block}.ApiGallery-module--versionControl--cFsH7>p{color:var(--color-light-grey);display:inline-block;font-size:14px;margin-right:20px}.Popup-module--button--cvZKS,.Popup-module--icon--zE7U3,.Popup-module--iconStyle--hp7Tx{align-items:center;border:none;border-radius:50%;display:inline-flex;font-size:15px;height:18px;justify-content:center;line-height:1;margin-left:10px;width:18px}.Popup-module--icon--zE7U3{border:1px solid #fff;margin-left:0;margin-right:5px}.Popup-module--root--6U6wO{font-weight:700;position:relative}.Popup-module--root--6U6wO>span{display:inline-block;font-size:14px!important;font-weight:400;margin-left:10px;overflow:hidden;position:relative;top:5px}.Popup-module--root--6U6wO>span>span{display:inline-block;font-family:sans-serif;position:relative}.Popup-module--button--cvZKS{cursor:pointer}.Popup-module--button--cvZKS:hover{background:var(--color-light-pink);color:#fff}.VideoList-module--list--\+e5Nn{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.VideoList-module--list--\+e5Nn>span{border:1px solid #fff;margin-right:20px}.VideoList-module--list--\+e5Nn:hover>span{color:var(--color-light-pink);transition:.3s}.VideoList-module--list--\+e5Nn a{text-decoration:none}.VideoList-module--list--\+e5Nn:hover a{text-decoration:underline}.ApiPage-module--mobileTypeText--3ruJX{color:var(--color-light-pink);display:block;font-family:monospace;font-size:15px;font-weight:400;margin-top:10px}.ApiPage-module--quickSelect--B\+2Ib{margin:0 auto;max-width:320px;position:relative}.ApiPage-module--quickSelect--B\+2Ib:after{content:"▼";font-size:15px;pointer-events:none;position:absolute;right:17%;top:12px}.ApiPage-module--quickSelect--B\+2Ib>select{-webkit-appearance:none;appearance:none;background:none;border:1px solid var(--color-light-blue);border-radius:4px;color:#fff;display:block;font-size:2rem;font-weight:lighter;margin:.67em auto 20px;max-width:240px;padding:10px 30px;position:relative;text-align:center;text-align-last:center}.ApiPage-module--lightQuickSelect--XpKfE.ApiPage-module--quickSelect--B\+2Ib>select{color:#000}.ApiPage-module--versionToggle--Qtk2m{position:absolute;right:20px}@media (min-width:768px){.ApiPage-module--hiddenMenu--Qk58G>h1{display:block}.ApiPage-module--hiddenMenu--Qk58G>div{display:none}}.selectNav-module--root--Mu1jW{-webkit-appearance:none;appearance:none;background:none;border:1px solid var(--color-light-blue);border-radius:3px;color:#fff;cursor:pointer;margin-top:1rem;padding-left:15px;padding-right:15px;position:relative;width:100%}.selectNav-module--root--Mu1jW:hover{border:1px solid var(--color-secondary)}.selectNav-module--root--Mu1jW>option{color:#000}@media (min-width:768px){.selectNav-module--root--Mu1jW{display:none}}.DevToolFeaturesList-module--featuresContent--b0inc{text-align:center}.DevToolFeaturesList-module--featuresContent--b0inc h3{font-size:20px;font-weight:400;margin-top:10px}.DevToolFeaturesList-module--featuresContent--b0inc svg{fill:#fff;display:block;height:60px;margin:0 auto;width:50px}.DevToolFeaturesList-module--lightFeaturesContent--NkEhm svg{fill:var(--color-black)}.DevToolFeaturesList-module--featuresContent--b0inc>article{padding-bottom:30px}.DevToolFeaturesList-module--featuresContent--b0inc>article>div{-webkit-transform:scale(0);transform:scale(0)}.DevToolFeaturesList-module--features--jwH5j{margin-top:-60px}.DevToolFeaturesList-module--features--jwH5j>h2{margin-bottom:30px}@media (min-width:768px){.DevToolFeaturesList-module--featuresContent--b0inc h3{font-size:22px}.DevToolFeaturesList-module--features--jwH5j>h2{margin:0 auto 20px;max-width:450px}.DevToolFeaturesList-module--features--jwH5j{margin-top:60px}.DevToolFeaturesList-module--featuresContent--b0inc{grid-column-gap:40px;display:grid;grid-template-columns:repeat(3,1fr);margin:20px auto 30px;max-width:800px}}.DevTools-module--container--eBSZz{display:grid}.DevTools-module--devToolImg--toLHa{border-radius:5px;cursor:not-allowed;display:block;height:230px;margin:30px auto 80px}.DevTools-module--devTool--weQf5 ::-webkit-scrollbar-track{background:inherit}.DevTools-module--devTool--weQf5 ::-webkit-scrollbar-thumb{background:grey}.DevTools-module--devTool--weQf5 ::-webkit-scrollbar-thumb:hover{background:#000}.DevTools-module--demo--qqMkQ{grid-gap:30px;display:grid;margin:0 auto;max-width:768px}.DevTools-module--demo--qqMkQ>div:first-child{order:2}@media (min-width:768px){.DevTools-module--devToolImg--toLHa{border-radius:8px;display:block;height:auto;margin:50px auto 0;max-width:600px;min-height:420px}.DevTools-module--demo--qqMkQ{grid-gap:30px;display:grid;grid-template-columns:1fr 1fr;margin:0 auto;max-width:768px}.DevTools-module--demo--qqMkQ>div:first-child{order:0}}@media (min-width:1024px){.DevTools-module--devTool--weQf5{display:block}.DevTools-module--devToolImg--toLHa{max-width:800px}}.BuilderPage-module--root--IeFc3{-webkit-overflow-scrolling:touch;box-sizing:border-box;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:11}.BuilderPage-module--pageWrapper--RKp7Z{grid-column-gap:60px;display:grid;grid-template-columns:repeat(auto-fit,minmax(15rem,1fr));margin:0 auto 100px;max-width:2000px;overflow:hidden;padding:0 20px 100px}.BuilderPage-module--pageWrapper--RKp7Z>section:first-child{margin-top:50px;order:3}.BuilderPage-module--pageWrapper--RKp7Z>form:nth-child(2){order:1}.BuilderPage-module--pageWrapper--RKp7Z>section:nth-child(3){order:2}.BuilderPage-module--form--q1gMN input,.BuilderPage-module--form--q1gMN select{border-radius:4px;box-sizing:border-box;display:block;font-size:16px;margin-bottom:10px;padding:6px 10px;width:100%}.BuilderPage-module--form--q1gMN input:hover,.BuilderPage-module--form--q1gMN select:hover{border:1px solid var(--color-light-pink)}.BuilderPage-module--form--q1gMN select:not([multiple]){height:40px}.BuilderPage-module--form--q1gMN input.BuilderPage-module--form-error--QQItp{border:1px solid #bf1650}.BuilderPage-module--form--q1gMN input[type=checkbox]{display:inline-block;margin-right:10px;width:auto}.BuilderPage-module--form--q1gMN label{display:block;line-height:2;margin-bottom:13px;margin-top:20px;text-align:left}.BuilderPage-module--form--q1gMN fieldset{border:1px solid var(--color-light-blue);border-radius:4px}.BuilderPage-module--closeButton--qTLdM{background:var(--color-primary);border:1px solid #fff;border-radius:4px;color:#fff;cursor:pointer;display:flex;font-size:25px;height:50px;justify-content:center;position:absolute;right:30px;top:20px;width:50px;z-index:5}.BuilderPage-module--closeButton--qTLdM:hover{border:1px solid var(--color-secondary)}@media (min-width:768px){.BuilderPage-module--pageWrapper--RKp7Z>section:first-child{margin-top:0;order:1}.BuilderPage-module--pageWrapper--RKp7Z>form:nth-child(2){order:2}.BuilderPage-module--pageWrapper--RKp7Z>section:nth-child(3){order:3}.BuilderPage-module--closeButton--qTLdM{align-items:center;display:flex;justify-content:center}}.BuilderPage-module--buttonWrapper--2uM7p{display:flex;position:absolute;right:5px;top:10px}.BuilderPage-module--button--Rxpsz{align-items:center;border:none;border-radius:0;color:#fff;cursor:pointer;display:none;font-size:13px;height:34px;margin:0 3px;padding:0 10px;right:20px;text-transform:uppercase;top:10px;z-index:1}.BuilderPage-module--button--Rxpsz:hover{background:var(--color-secondary);color:#fff}@media (min-width:768px){.BuilderPage-module--button--Rxpsz{display:flex}}.BuilderPage-module--copyButton--kFnHx{background:var(--color-light-blue);border:1px solid transparent}.BuilderPage-module--active--jmtyr,.BuilderPage-module--copyButton--kFnHx:hover{background:none;border:1px solid var(--color-secondary);color:#fff}.BuilderPage-module--active--jmtyr,.BuilderPage-module--copyButton--kFnHx:hover span{background:var(--color-primary)}.BuilderPage-module--wrapper--FrPeD pre{line-height:1.5!important}.BuilderPage-module--wrapper--FrPeD pre code{display:none}.BuilderPage-module--wrapper--FrPeD pre code.BuilderPage-module--showCode--pqBnR{display:block}.FeatureList-module--featuresContent---O49K{text-align:center}.FeatureList-module--featuresContent---O49K h3{font-size:20px;font-weight:500;margin-top:10px}.FeatureList-module--featuresContent---O49K svg{display:block;height:60px;margin:0 auto;width:50px}.FeatureList-module--lightFeaturesContent--dPKsK svg{fill:var(--color-black)}.FeatureList-module--featuresContent---O49K>article{padding-bottom:30px}.FeatureList-module--featuresContent---O49K>article>div{-webkit-transform:scale(0);transform:scale(0)}.FeatureList-module--features--Lqy49{margin-top:-60px}.FeatureList-module--features--Lqy49>h2{margin-bottom:30px}@media (min-width:768px){.FeatureList-module--featuresContent---O49K h3{font-size:22px}.FeatureList-module--features--Lqy49>h2{margin:0 auto 20px;max-width:450px}.FeatureList-module--features--Lqy49{margin-bottom:60px;margin-top:60px}.FeatureList-module--featuresContent---O49K{grid-column-gap:30px;display:grid;grid-template-columns:repeat(3,1fr);margin:40px auto 30px;max-width:1024px}}@media (min-width:1280px){.FeatureList-module--featuresContent---O49K{grid-column-gap:25px;grid-template-columns:repeat(6,1fr);max-width:1480px}.FeatureList-module--featuresContent---O49K>article{padding-bottom:0}}.HomePage-module--root--Lf021{padding:0 20px 50px;position:relative}.HomePage-module--feedback--PKTra{margin-top:40px}.HomePage-module--feedback--PKTra>div{border-radius:15px;margin-bottom:20px}.HomePage-module--feedback--PKTra>div>svg{margin:0 auto;width:45px}.HomePage-module--feedback--PKTra>div>p{font-size:15px;padding:20px;text-align:left}@media (min-width:768px){.HomePage-module--feedback--PKTra{grid-gap:50px;display:grid;grid-template-columns:repeat(3,1fr)}.HomePage-module--feedback--PKTra>div{margin-bottom:0}}@media (min-width:1024px){.HomePage-module--root--Lf021{padding:0 50px}}
useController | React Hook Form - Simple React forms validation Skip to content
useController React hooks for controlled component
Select page... controller useController:(props?: UseControllerProps) => { field: object, fieldState: object, formState: object }
This custom hook powers Controller
. Additionally, it shares the same props and methods as Controller
. It's useful for creating reusable Controlled input.
Props The following table contains information about the arguments for useController
.
Name Type Required Description name
FieldPath
✓ Unique name of your input. control
Control
control
object provided by invoking useForm
. Optional when using FormProvider
.defaultValue
unknown
Important: Can not apply undefined
to defaultValue
or defaultValues
at useForm
.
You need to either set defaultValue
at the field-level or useForm
's defaultValues
. undefined
is not a valid value.
If your form will invoke reset
with default values, you will need to provide useForm
with defaultValues
.
rules
Object
Validation rules in the same format for register
, which includes:
required, min, max, minLength, maxLength, pattern, validate
rules={{ required: true }}
shouldUnregister
boolean = false
Input will be unregistered after unmount and defaultValues will be removed as well.
Note: this prop should be avoided when using with useFieldArray
as unregister
function gets called after input unmount/remount and reorder.
Return The following table contains information about properties which useController
produces.
string
React.Ref
Object Name Name Type Description field
onChange
(value: any) => void
A function which sends the input's value to the library.
field
onBlur
() => void
A function which sends the input's onBlur event to the library. It should be assigned to the input's onBlur
prop.
field
value
unknown
The current value of the controlled component.
field
name
Input's name being registered.
field
ref
A ref used to connect hook form to the input. Assign ref
to component's input ref to allow hook form to focus the error input.
fieldState
invalid
boolean
Invalid state for current input.
fieldState
isTouched
boolean
Touched state for current controlled input.
fieldState
isDirty
boolean
Dirty state for current controlled input.
fieldState
error
object
error for this specific input.
formState
isDirty
boolean
Set to true
after the user modifies any of the inputs.
Make sure to provide all inputs' defaultValues at the useForm, so hook form can have a single source of truth to compare whether the form is dirty.
Copy
const {
formState: { isDirty, dirtyFields },
setValue,
} = useForm({ defaultValues: { test: "" } });
// isDirty: true
setValue('test', 'change')
// isDirty: false because there getValues() === defaultValues
setValue('test', '')
File typed input will need to be managed at the app level due to the ability to cancel file selection and FileList object.
formState
dirtyFields
object
An object with the user-modified fields. Make sure to provide all inputs' defaultValues via useForm, so the library can compare against the defaultValues
.
Dirty fields will not represent as isDirty
formState, because dirty fields are marked field dirty at field level rather the entire form. If you want to determine the entire form state use isDirty
instead.
formState
touchedFields
object
An object containing all the inputs the user has interacted with. formState
defaultValues
object
The value which has been set at useForm 's defaultValues or updated defaultValues via reset API.
isSubmitted
boolean
Set to true
after the form is submitted. Will remain true
until the reset
method is invoked. formState
isSubmitSuccessful
boolean
Indicate the form was successfully submitted without any Promise
rejection or Error
been thrown within the handleSubmit
callback.
formState
isSubmitting
boolean
true
if the form is currently being submitted. false
otherwise.formState
submitCount
number
Number of times the form was submitted. formState
isValid
boolean
Set to true
if the form doesn't have any errors.
isValid
is affected by mode
at useForm . This state is only applicable with onChange
, onTouched
, and onBlur
mode.
setError
has no effect on isValid
formState, isValid
will always derived via the entire form validation result.
formState
isValidating
boolean
Set to true
during validation. formState
errors
object
An object with field errors. There is also an ErrorMessage component to retrieve error message easily.
Examples TextField Checkboxes
import { TextField } from "@material-ui/core";
import { useController, useForm } from "react-hook-form";
function Input({ control, name }) {
const {
field: { onChange, onBlur, name, value, ref },
fieldState: { invalid, isTouched, isDirty },
formState: { touchedFields, dirtyFields }
} = useController({
name,
control,
rules: { required: true },
defaultValue: "",
});
return (
<TextField
onChange={onChange} // send value to hook form
onBlur={onBlur} // notify when input is touched/blur
value={value} // input value
name={name} // send down the input name
inputRef={ref} // send input ref, so we can focus on input when error appear
/>
);
}
import * as React from "react";
import { useForm, useController, UseControllerProps } from "react-hook-form";
type FormValues = {
FirstName: string;
};
function Input(props: UseControllerProps<FormValues>) {
const { field, fieldState } = useController(props);
return (
<div>
<input {...field} placeholder={props.name} />
<p>{fieldState.isTouched && "Touched"}</p>
<p>{fieldState.isDirty && "Dirty"}</p>
<p>{fieldState.invalid ? "invalid" : "valid"}</p>
</div>
);
}
export default function App() {
const { handleSubmit, control } = useForm<FormValues>({
defaultValues: {
FirstName: ""
},
mode: "onChange"
});
const onSubmit = (data: FormValues) => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<Input control={control} name="FirstName" rules={{ required: true }} />
<input type="submit" />
</form>
);
}
import * as React from "react";
import { useController, useForm } from "react-hook-form";
const Checkboxes = ({ options, control, name }) => {
const { field } = useController({
control,
name
});
const [value, setValue] = React.useState(field.value || []);
return (
<>
{options.map((option, index) => (
<input
onChange={(e) => {
const valueCopy = [...value];
// update checkbox value
valueCopy[index] = e.target.checked ? e.target.value : null;
// send data to react hook form
field.onChange(valueCopy);
// update local state
setValue(valueCopy);
}}
key={option}
checked={value.includes(option)}
type="checkbox"
value={option}
/>
))}
</>
);
};
export default function App() {
const { register, handleSubmit, control } = useForm({
defaultValues: {
controlled: [],
uncontrolled: []
}
});
const onSubmit = (data) => console.log(data);
return (
<form onSubmit={handleSubmit(onSubmit)}>
<section>
<h2>uncontrolled</h2>
<input {...register("uncontrolled")} type="checkbox" value="A" />
<input {...register("uncontrolled")} type="checkbox" value="B" />
<input {...register("uncontrolled")} type="checkbox" value="C" />
</section>
<section>
<h2>controlled</h2>
<Checkboxes
options={["a", "b", "c"]}
control={control}
name="controlled"
/>
</section>
<input type="submit" />
</form>
);
}
Tips It's important to be aware of each prop's responsibility when working with external controlled components, such as MUI, AntD, Chakra UI. Its job is to spy on the input, report, and set its value.
onChange : send data back to hook form
onBlur : report input has been interacted (focus and blur)
value : set up input initial and updated value
ref : allow input to be focused with error
name : give input an unique name
It's fine to host your state and combined with useController
.
const { field } = useController();
const [value, setValue] = useState(field.value);
onChange={(event) => {
field.onChange(parseInt(event.target.value)) // data send back to hook form
setValue(event.target.value) // UI state
}}
Do not register
input again. This custom hook is designed to take care of the registration process.
Copy
const { field } = useController({ name: 'test' })
<input {...field} /> // ✅
<input {...field} {...register('test')} /> // ❌ double up the registration
It's ideal to use a single useController
per component. If you need to use more than one, make sure you rename the prop. May want to consider using Controller
instead.
Copy
const { field: input } = useController({ name: 'test' })
const { field: checkbox } = useController({ name: 'test1' })
<input {...input} />
<input {...checkbox} />
Thank you for your support If you find React Hook Form to be useful in your project, please consider to star and support it.
Star us on GitHub