@@ -19,6 +19,7 @@ type ButtonStyleProps = {
1919 variant ?: ButtonVariant ;
2020 size ?: ButtonSize ;
2121 width ?: ButtonWidth ;
22+ fullWidth ?: boolean ;
2223 disabled ?: boolean ;
2324} ;
2425
@@ -108,6 +109,11 @@ type LinkButtonRestProps = Omit<
108109const isLinkButton = ( props : ButtonProps ) : props is LinkButtonProps =>
109110 props . href !== undefined ;
110111
112+ const getResolvedWidth = (
113+ width : ButtonWidth | undefined ,
114+ fullWidth : boolean | undefined
115+ ) => ( fullWidth ? "full" : width ) ;
116+
111117const getCommonProps = ( props : ButtonProps ) => {
112118 const {
113119 variant = "secondary" ,
@@ -117,10 +123,13 @@ const getCommonProps = (props: ButtonProps) => {
117123 loading = false ,
118124 loadingText = "Loading..." ,
119125 size = "normal" ,
126+ width,
127+ fullWidth,
120128 onClick,
121129 href,
122130 ...restProps
123131 } = props ;
132+ const resolvedWidth = getResolvedWidth ( width , fullWidth ) ;
124133
125134 return {
126135 variant,
@@ -130,6 +139,7 @@ const getCommonProps = (props: ButtonProps) => {
130139 loading,
131140 loadingText,
132141 size,
142+ width : resolvedWidth ,
133143 onClick,
134144 href,
135145 restProps,
@@ -388,6 +398,7 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
388398 loading,
389399 loadingText,
390400 size,
401+ width,
391402 onClick,
392403 restProps,
393404 } = getCommonProps ( allProps ) ;
@@ -416,13 +427,13 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
416427 href = { allProps . href }
417428 ref = { ref as Ref < HTMLAnchorElement > }
418429 $variant = { variant }
419- $width = { allProps . width }
430+ $width = { width }
420431 $size = { size }
421432 $disabledState = { isDisabled }
422433 tabIndex = { isDisabled ? - 1 : tabIndex }
423434 aria-disabled = { isDisabled || undefined }
424435 aria-busy = { isLoading || undefined }
425- data-button-width = { allProps . width ?? "contained" }
436+ data-button-width = { width ?? "contained" }
426437 { ...clickProps }
427438 { ...linkProps }
428439 rel = { rel }
@@ -442,13 +453,13 @@ const Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(
442453 ref = { ref as Ref < HTMLButtonElement > }
443454 disabled = { isDisabled }
444455 $variant = { variant }
445- $width = { allProps . width }
456+ $width = { width }
446457 $size = { size }
447458 $disabledState = { isDisabled }
448459 tabIndex = { isDisabled ? - 1 : tabIndex }
449460 aria-disabled = { isDisabled || undefined }
450461 aria-busy = { isLoading || undefined }
451- data-button-width = { allProps . width ?? "contained" }
462+ data-button-width = { width ?? "contained" }
452463 onClick = { onClick }
453464 { ...buttonProps }
454465 >
0 commit comments