Socket
Socket
Sign inDemoInstall

@commercetools-uikit/checkbox-input

Package Overview
Dependencies
113
Maintainers
3
Versions
860
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @commercetools-uikit/checkbox-input

An input component that works as checkbox input.


Version published
Weekly downloads
5.1K
increased by32.73%
Maintainers
3
Created
Weekly downloads
 

Readme

Source

CheckboxInput

Description

An input component that works as checkbox input.

Installation

yarn add @commercetools-uikit/checkbox-input
npm --save install @commercetools-uikit/checkbox-input

Additionally install the peer dependencies (if not present)

yarn add react
npm --save install react

Usage

import CheckboxInput from '@commercetools-uikit/checkbox-input';

const Example = () => (
  <div>
    <CheckboxInput
      value="foo-radio-value"
      onChange={(event) => alert(event.target.value)}
      isChecked={true}
    >
      A pre-checked option
    </CheckboxInput>
    <CheckboxInput
      value="bar-radio-value"
      onChange={(event) => alert(event.target.value)}
      isDisabled={true}
    >
      A disabled option
    </CheckboxInput>
    <CheckboxInput
      value="unknown-radio-value"
      onChange={(event) => alert(event.target.value)}
      aria-label={'An Option Without a Visible Label'}
    />
  </div>
);

export default Example;

Properties

PropsTypeRequiredDefaultDescription
idstringUsed as HTML id attribute. An id is auto-generated when it is not specified.
namestringUsed as HTML name attribute of the input component
valuestringValue of the input component.
isCheckedbooleanfalseThe checked property sets the checked state of the checkbox.
isIndeterminatebooleanIf true, this state is shown as a dash in the checkbox, and indicates that its state is neither checked nor unchecked. This is most often used when the checkbox is tied to a collection of items in mixed states (E.g nested checkboxes). This takes precedence visually in case isChecked is marked as true
onChangeChangeEventHandlerWill be triggered whenever an CheckboxInput is clicked. Called with event
isHoveredbooleanForces CheckboxInput to be rendered in a hovered state. Needed for cases when hovered appearance should be triggered by the parent component and not the CheckboxInput itself. CheckboxInput is capable of handling it's own hovering without the need to pass this prop.
isDisabledbooleanfalseDisables the CheckboxInput
isReadOnlybooleanMakes the CheckboxInput readonly
hasErrorbooleanfalseIndicates that the checkbox has an error
childrenReactNodeThe descriptive text of the CheckboxInput, used as its label.

data-* and aria-* props

The component further forwards all data- and aria- attributes to the underlying component. In order to keep the component more accessible to screen-readers, please make sure that if no children prop is present (for displaying a checkbox without any text), a corresponding aria-label property is provided instead.

Keywords

FAQs

Last updated on 17 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc