@carbon/react
Version:
React components for the Carbon Design System
35 lines (33 loc) • 1.12 kB
JavaScript
/**
* Copyright IBM Corp. 2016, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { usePrefix } from "../../internal/usePrefix.js";
import "react";
import PropTypes from "prop-types";
import { jsx } from "react/jsx-runtime";
//#region src/components/ListBox/ListBoxField.tsx
/**
* `ListBoxField` is responsible for creating the containing node for valid
* elements inside of a field. It also provides a11y-related attributes like
* `role` to make sure a user can focus the given field.
*/
function ListBoxField({ children, disabled, tabIndex, ...rest }) {
return /* @__PURE__ */ jsx("div", {
className: `${usePrefix()}--list-box__field`,
tabIndex: !disabled && tabIndex || -1,
...rest,
children
});
}
ListBoxField.propTypes = {
"aria-haspopup": PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
children: PropTypes.node,
disabled: PropTypes.bool,
role: PropTypes.string,
tabIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
};
//#endregion
export { ListBoxField as default };