From 80da3319b3e4f16603eedef1fc96a6f805a08525 Mon Sep 17 00:00:00 2001 From: PelayoFelgueroso Date: Mon, 23 Feb 2026 10:29:02 +0100 Subject: [PATCH 1/3] Add fillParent prop to FileInput component --- .../file-input/code/FileInputCodePage.tsx | 15 +++++++++++++++ packages/lib/src/file-input/FileInput.tsx | 15 +++++++++++---- packages/lib/src/file-input/types.ts | 4 ++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/apps/website/screens/components/file-input/code/FileInputCodePage.tsx b/apps/website/screens/components/file-input/code/FileInputCodePage.tsx index 736427146c..d630bf7bcf 100644 --- a/apps/website/screens/components/file-input/code/FileInputCodePage.tsx +++ b/apps/website/screens/components/file-input/code/FileInputCodePage.tsx @@ -79,6 +79,21 @@ const sections = [ Text to be placed inside the drag and drop zone alongside the button. - + + + + + fillParent + + + + boolean + + If true, the component will take all the width of its container. + + false + + helperText diff --git a/packages/lib/src/file-input/FileInput.tsx b/packages/lib/src/file-input/FileInput.tsx index bb05aee54a..4528ae81a7 100644 --- a/packages/lib/src/file-input/FileInput.tsx +++ b/packages/lib/src/file-input/FileInput.tsx @@ -9,7 +9,11 @@ import { getFilePreview, isFileIncluded } from "./utils"; import HelperText from "../styles/forms/HelperText"; import Label from "../styles/forms/Label"; -const FileInputContainer = styled.div<{ margin: FileInputPropsType["margin"] }>` +const FileInputContainer = styled.div<{ + margin: FileInputPropsType["margin"]; + mode: FileInputPropsType["mode"]; + fillParent: FileInputPropsType["fillParent"]; +}>` display: flex; flex-direction: column; margin: ${(props) => (props.margin && typeof props.margin !== "object" ? spaces[props.margin] : "0px")}; @@ -21,7 +25,7 @@ const FileInputContainer = styled.div<{ margin: FileInputPropsType["margin"] }>` props.margin && typeof props.margin === "object" && props.margin.bottom ? spaces[props.margin.bottom] : ""}; margin-left: ${(props) => props.margin && typeof props.margin === "object" && props.margin.left ? spaces[props.margin.left] : ""}; - width: fit-content; + width: ${(props) => (props.mode !== "file" && props.fillParent ? "100%" : "fit-content")}; `; const FileContainer = styled.div<{ singleFileMode: boolean }>` @@ -54,6 +58,7 @@ const DragDropArea = styled.div<{ mode: FileInputPropsType["mode"]; disabled: FileInputPropsType["disabled"]; isDragging: boolean; + fillParent: FileInputPropsType["fillParent"]; }>` box-sizing: border-box; display: flex; @@ -62,7 +67,7 @@ const DragDropArea = styled.div<{ ? "flex-direction: row; column-gap: var(--spacing-gap-s);" : "justify-content: center; flex-direction: column; row-gap: var(--spacing-gap-s); height: 160px;"} align-items: center; - width: 320px; + width: ${(props) => (props.fillParent ? "100%" : "320px")}; padding: ${(props) => (props.mode === "filedrop" ? `var(--spacing-padding-xxs)` : "var(--spacing-padding-m)")}; overflow: hidden; border-radius: var(--border-radius-m); @@ -109,6 +114,7 @@ const DxcFileInput = forwardRef( buttonLabel, dropAreaLabel, helperText = "", + fillParent = false, accept, minSize, maxSize, @@ -230,7 +236,7 @@ const DxcFileInput = forwardRef( }, [value]); return ( - + {label && (