🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more →
Socket
Book a DemoInstallSign in
Socket

@bento/control

Package Overview
Dependencies
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bento/control

Control component

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
3
Created
Source

Control

The @bento/control package provides foundational building blocks for form controls such as radios and checkboxes. It delivers a consistent DOM structure and shared behaviors, making it easy to create custom form controls. The package exports the ControlGroup and Control primitives.

The ControlGroup is a container for a group of controls. It is used to group controls with a shared label and description. It also provides a standardized way to display error messages.

The Control consists of a label and an visually hidden input element. The label is used to describe the control and the input element is used to capture user input.

This package is intended primarily for internal use as a foundation for building other Bento primitives, rather than for direct use outside the Bento ecosystem.

Installation

npm install --save @bento/control

Props

The @bento/control package exports the ControlGroup and Control primitives:

import { ControlGroup, Control } from '@bento/control';

<ControlGroup label="Control label">
  <Control inputRef={inputRef} inputProps={inputProps} labelProps={labelProps} label="Control 1" />
  <Control inputRef={inputRef} inputProps={inputProps} labelProps={labelProps} label="Control 2" />
</ControlGroup>;

The following properties are available to be used on the Control and ControlGroup primitives:

ControlGroup

PropTypeRequiredDescription
childrenReactNodeYesThe control elements to render within the group.
labelReactNodeNoThe label for the control group.
labelPropsDetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>NoProps to pass to the label element.
descriptionReactNodeNoAdditional description text for the control group.
descriptionPropsDetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>NoProps to pass to the description element.
errorMessageReactNodeNoError message to display below the controls.
errorMessagePropsDetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>NoProps to pass to the error message element.
contentPropsDetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>NoThe props passed to the content element.
slotstringNoA named part of a component that can be customized. This is implemented by the consuming component.
The exposed slot names of a component are available in the components documentation.
slotsRecord<string, object | Function>NoAn object that contains the customizations for the slots.
The main way you interact with the slot system as a consumer.

Control

PropTypeRequiredDescription
inputRefRef<HTMLInputElement>NoA ref for the HTML input element.
inputPropsDetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>NoProps to pass to the underlying input element.
labelReactNodeNoThe label for the control.
labelPropsDetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>NoProps to pass to the label element.
childrenReactNodeNoAdditional content for the control.
slotstringNoA named part of a component that can be customized. This is implemented by the consuming component.
The exposed slot names of a component are available in the components documentation.
slotsRecord<string, object | Function>NoAn object that contains the customizations for the slots.
The main way you interact with the slot system as a consumer.

Slot Map and Props

The slot map and props can be used to style and customize the Control and ControlGroup primitives.

Control Slot Map

Slot NameDescription
labelLabel for the control

ControlGroup Slot Map

Slot NameDescription
labelLabel for controlgroup
descriptionDescription for controlgroup
errorError message for controlgroup

Examples

Default

A simple usage of the ControlGroup primitive.

import { Control, ControlGroup } from '@bento/control';
/* v8 ignore next */
import React, { type ComponentProps } from 'react';

export function DefaultExample(props: {
  groupProps?: Partial<ComponentProps<typeof ControlGroup>>;
  controlProps?: Partial<ComponentProps<typeof Control>>;
}) {
  return (
    <ControlGroup
      label="Control label"
      description="Control description"
      errorMessage="Control error message"
      className="random-class-group"
      {...props.groupProps}
    >
      <Control label="Control 1" className="random-class-control" {...props.controlProps} />
      <Control label="Control 2" {...props.controlProps} />
    </ControlGroup>
  );
}

Input Ref

Passing a ref to the Control primitive allows you to access the underlying input element.

import { Control, ControlGroup } from '@bento/control';
/* v8 ignore next */
import React, { useRef } from 'react';

export function InputRefExample() {
  const inputRef = useRef<HTMLInputElement>(null);

  return (
    <ControlGroup label="Control label">
      <Control
        inputRef={inputRef}
        inputProps={{ id: 'dateId', type: 'date' }}
        labelProps={{ htmlFor: 'dateId' }}
        label="Control 1"
      />
      <Control
        inputRef={inputRef}
        inputProps={{ id: 'radioId', type: 'radio' }}
        labelProps={{ htmlFor: 'radioId' }}
        label="Control 2"
      />
    </ControlGroup>
  );
}

Keywords

accessibility

FAQs

Package last updated on 06 Nov 2025

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