Skip to content

Commit ac7c76a

Browse files
authored
Add hideLabel prop to DatePicker (#858)
1 parent bb2e6f9 commit ac7c76a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/core/src/components/DatePicker/DatePicker.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ type Props = {
6666
autoDismissKeyboard?: boolean;
6767
minimumDate?: Date | string;
6868
maximumDate?: Date | string;
69+
hideLabel?: boolean;
6970
} & IconSlot &
7071
TextInputProps;
7172

@@ -107,6 +108,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
107108
autoDismissKeyboard = true,
108109
minimumDate,
109110
maximumDate,
111+
hideLabel = false,
110112
...props
111113
}) => {
112114
const [value, setValue] = React.useState<Date | undefined>(
@@ -300,8 +302,8 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
300302
borderRadius: roundness,
301303
borderColor: hasActiveOutline ? activeColor : borderColor,
302304
borderWidth: 1,
303-
paddingTop: labeled ? 16 * 1.5 : 16,
304-
paddingBottom: labeled ? 16 * 0.5 : 16,
305+
paddingTop: labeled && !hideLabel ? 16 * 1.5 : 16,
306+
paddingBottom: labeled && !hideLabel ? 16 * 0.5 : 16,
305307
opacity: disabled ? disabledOpacity : 1,
306308
backgroundColor,
307309
};
@@ -424,7 +426,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
424426
/>
425427
) : null}
426428

427-
{label ? (
429+
{label && !hideLabel ? (
428430
// Position colored placeholder and gray placeholder on top of each other and crossfade them
429431
// This gives the effect of animating the color, but allows us to use native driver
430432
<View
@@ -490,7 +492,7 @@ const DatePicker: React.FC<React.PropsWithChildren<Props>> = ({
490492

491493
<NativeTextInput
492494
value={formatDate()}
493-
placeholder={label ? placeholder1 : placeholder}
495+
placeholder={label && !hideLabel ? placeholder1 : placeholder}
494496
editable={!disabled}
495497
placeholderTextColor={placeholderColor}
496498
selectionColor={activeColor}

0 commit comments

Comments
 (0)