@@ -12,6 +12,8 @@ import { InputContext, InputGroupContext } from "../input-behaviour";
1212import { ValidationProps } from "../validations" ;
1313import { IconType } from "../../components/icon" ;
1414import createGuid from "../../__internal__/utils/helpers/guid" ;
15+ import HintText from "../hint-text" ;
16+ import newValidationContext from "../../components/carbon-provider/__internal__/new-validation.context" ;
1517
1618export interface LabelProps
1719 extends ValidationProps ,
@@ -40,6 +42,14 @@ export interface LabelProps
4042 * @internal
4143 * Sets className for component. INTERNAL USE ONLY. */
4244 className ?: string ;
45+ /** @private @internal @ignore */
46+ inputHint ?: string ;
47+ /** @private @internal @ignore */
48+ inputHintId ?: string ;
49+ /** @private @internal @ignore */
50+ labelHelp ?: React . ReactNode ;
51+ /** @private @internal @ignore */
52+ marginBttom ?: string ;
4353 /** Sets aria-label for label element */
4454 "aria-label" ?: string ;
4555 /** Whether this component is shown against a dark background */
@@ -79,11 +89,15 @@ export const Label = ({
7989 isDarkBackground = false ,
8090 isRequired,
8191 labelId,
92+ inputHint,
93+ inputHintId,
94+ labelHelp,
8295 pr,
8396 pl,
8497 tooltipId,
8598 useValidationIcon = true ,
8699 validationIconId,
100+ marginBttom = "8px" ,
87101 warning,
88102 width = 30 ,
89103 className,
@@ -96,6 +110,8 @@ export const Label = ({
96110 useContext ( InputGroupContext ) ;
97111 const guid = useRef ( createGuid ( ) ) ;
98112
113+ const { validationRedesignOptIn } = useContext ( newValidationContext ) ;
114+
99115 const handleMouseEnter = ( ) => {
100116 if ( onMouseEnter ) onMouseEnter ( ) ;
101117 if ( onGroupMouseEnter ) onGroupMouseEnter ( ) ;
@@ -167,26 +183,42 @@ export const Label = ({
167183 id = { `label-container-${ labelId ?? guid . current } ` }
168184 align = { alignment }
169185 inline = { inline }
186+ validationRedesignOptIn = { validationRedesignOptIn }
170187 width = { width }
188+ marginBttom = { marginBttom }
171189 pr = { pr }
172190 pl = { pl }
173191 className = { className }
174192 >
175- < StyledLabel
176- data-element = "label"
177- disabled = { disabled }
178- id = { labelId }
179- { ...( as === "label" ? { htmlFor } : { } ) }
180- onMouseEnter = { handleMouseEnter }
181- onMouseLeave = { handleMouseLeave }
182- isRequired = { isRequired }
183- as = { as }
184- aria-label = { ariaLabel }
185- isDarkBackground = { isDarkBackground }
186- isLarge = { isLarge }
187- >
188- { children }
189- </ StyledLabel >
193+ < div style = { { display : "flex" , flexDirection : "column" } } >
194+ < StyledLabel
195+ data-element = "label"
196+ disabled = { disabled }
197+ id = { labelId }
198+ { ...( as === "label" ? { htmlFor } : { } ) }
199+ onMouseEnter = { handleMouseEnter }
200+ onMouseLeave = { handleMouseLeave }
201+ isRequired = { isRequired }
202+ as = { as }
203+ aria-label = { ariaLabel }
204+ isDarkBackground = { isDarkBackground }
205+ isLarge = { isLarge }
206+ >
207+ { children }
208+ </ StyledLabel >
209+ { ( inputHint || ( labelHelp && validationRedesignOptIn ) ) && (
210+ < HintText
211+ align = { alignment }
212+ data-element = "input-hint"
213+ id = { inputHintId }
214+ marginBottom = "var(--spacing000)"
215+ isLarge = { isLarge }
216+ isComponentInline = { inline }
217+ >
218+ { inputHint || labelHelp }
219+ </ HintText >
220+ ) }
221+ </ div >
190222 { icon ( ) }
191223 </ StyledLabelContainer >
192224 ) ;
0 commit comments