Skip to content

Commit 16baa11

Browse files
committed
Added show mandatory prop to the label
1 parent 98fe5f3 commit 16baa11

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/incubator/TextField/Label.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {ColorType, LabelProps, ValidationMessagePosition} from './types';
66
import {getColorByState} from './Presenter';
77
import FieldContext from './FieldContext';
88

9-
109
const DEFAULT_LABEL_COLOR: ColorType = {
1110
default: Colors.$textDefault,
1211
readonly: Colors.$textNeutral
@@ -19,6 +18,7 @@ const Label = ({
1918
labelProps,
2019
validationMessagePosition,
2120
floatingPlaceholder,
21+
showMandatoryIndication,
2222
testID
2323
}: LabelProps) => {
2424
const context = useContext(FieldContext);
@@ -39,6 +39,7 @@ const Label = ({
3939
{...labelProps}
4040
>
4141
{label}
42+
{context.isMandatory && showMandatoryIndication && '*'}
4243
</Text>
4344
);
4445
}

src/incubator/TextField/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface LabelProps {
7474
validationMessagePosition?: ValidationMessagePositionType;
7575
floatingPlaceholder?: boolean;
7676
testID?: string;
77+
showMandatoryIndication?: boolean;
7778
}
7879

7980
export interface FloatingPlaceholderProps {

0 commit comments

Comments
 (0)