Socket
Socket
Sign inDemoInstall

@chakra-ui/form-control

Package Overview
Dependencies
Maintainers
3
Versions
473
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chakra-ui/form-control

React component to provide validation states to form fields


Version published
Maintainers
3
Created

What is @chakra-ui/form-control?

@chakra-ui/form-control is a package from the Chakra UI library that provides a set of components and hooks to build accessible and customizable form controls in React applications. It helps in managing form state, validation, and accessibility with ease.

What are @chakra-ui/form-control's main functionalities?

FormControl

The FormControl component is used to group form elements and manage their state and validation. It provides a way to display error messages and ensure accessibility.

import { FormControl, FormLabel, Input, FormErrorMessage } from '@chakra-ui/react';

function Example() {
  const [input, setInput] = React.useState('');
  const isError = input === '';

  return (
    <FormControl isInvalid={isError}>
      <FormLabel htmlFor='email'>Email</FormLabel>
      <Input id='email' type='email' value={input} onChange={(e) => setInput(e.target.value)} />
      {isError && <FormErrorMessage>Email is required.</FormErrorMessage>}
    </FormControl>
  );
}

FormLabel

The FormLabel component is used to label form inputs. It ensures that the label is properly associated with the input for accessibility purposes.

import { FormLabel } from '@chakra-ui/react';

function Example() {
  return (
    <FormLabel htmlFor='name'>Name</FormLabel>
  );
}

FormErrorMessage

The FormErrorMessage component is used to display error messages when form validation fails. It is typically used within a FormControl component.

import { FormControl, FormLabel, Input, FormErrorMessage } from '@chakra-ui/react';

function Example() {
  const [input, setInput] = React.useState('');
  const isError = input === '';

  return (
    <FormControl isInvalid={isError}>
      <FormLabel htmlFor='email'>Email</FormLabel>
      <Input id='email' type='email' value={input} onChange={(e) => setInput(e.target.value)} />
      {isError && <FormErrorMessage>Email is required.</FormErrorMessage>}
    </FormControl>
  );
}

Other packages similar to @chakra-ui/form-control

Keywords

FAQs

Package last updated on 20 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc