@wordpress/components
Version:
UI components for WordPress.
44 lines (40 loc) • 1.25 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import { createElement } from "@wordpress/element";
/**
* Internal dependencies
*/
import { contextConnect } from '../context';
import { View } from '../../view';
import { useControlLabel } from './hook';
/**
* @param {import('../context').WordPressComponentProps<import('./types').Props, 'label', false>} props
* @param {import('react').ForwardedRef<any>} forwardedRef
*/
function ControlLabel(props, forwardedRef) {
const controlLabelProps = useControlLabel(props);
return createElement(View, _extends({
as: "label"
}, controlLabelProps, {
ref: forwardedRef
}));
}
/**
* `ControlLabel` is a form component that works with `FormGroup` to provide a
* label for form elements (e.g. `Switch` or `TextInput`).
*
* ```jsx
* import { ControlLabel, FormGroup, TextInput } from '@wordpress/components/ui';
*
* function Example() {
* return (
* <FormGroup>
* <ControlLabel>First Name</ControlLabel>
* <TextInput />
* </FormGroup>
* );
* }
* ```
*/
const ConnectedControlLabel = contextConnect(ControlLabel, 'ControlLabel');
export default ConnectedControlLabel;
//# sourceMappingURL=component.js.map