@@ -17,7 +17,7 @@ import {
1717} from 'react-aria-components' ;
1818import { bar , track } from './bar-utils' with { type : 'macro' } ;
1919import { createContext , forwardRef , ReactNode } from 'react' ;
20- import { DOMRef , DOMRefValue } from '@react-types/shared' ;
20+ import { DOMRef , DOMRefValue , LabelPosition } from '@react-types/shared' ;
2121import { FieldLabel } from './Field' ;
2222import { fieldLabel , getAllowedOverrides , StyleProps } from './style-utils' with { type : 'macro' } ;
2323import { keyframes } from '../style/style-macro' with { type : 'macro' } ;
@@ -37,8 +37,16 @@ interface ProgressBarStyleProps {
3737 * Whether presentation is indeterminate when progress isn't known.
3838 */
3939 isIndeterminate ?: boolean ,
40- /** The static color style to apply. Useful when the button appears over a color background. */
41- staticColor ?: 'white' | 'black'
40+ /**
41+ * The static color style to apply. Useful when the button appears over a color background.
42+ */
43+ staticColor ?: 'white' | 'black' ,
44+ /**
45+ * The label's overall position relative to the element it is labeling.
46+ * @default 'top'
47+ */
48+ labelPosition ?: LabelPosition
49+
4250}
4351
4452export interface ProgressBarProps extends Omit < AriaProgressBarProps , 'children' | 'className' | 'style' > , ProgressBarStyleProps , StyleProps {
@@ -89,6 +97,7 @@ const trackStyles = style({
8997const fill = style < ProgressBarStyleProps > ( {
9098 height : 'full' ,
9199 borderStyle : 'none' ,
100+ borderRadius : 'full' ,
92101 backgroundColor : {
93102 default : 'accent' ,
94103 staticColor : {
@@ -117,17 +126,24 @@ const indeterminateAnimation = style({
117126
118127function ProgressBar ( props : ProgressBarProps , ref : DOMRef < HTMLDivElement > ) {
119128 [ props , ref ] = useSpectrumContextProps ( props , ref , ProgressBarContext ) ;
120- let { label, size = 'M' , staticColor, isIndeterminate, UNSAFE_style, UNSAFE_className = '' } = props ;
129+ let {
130+ label, size = 'M' ,
131+ staticColor,
132+ isIndeterminate,
133+ labelPosition = 'top' ,
134+ UNSAFE_style,
135+ UNSAFE_className = ''
136+ } = props ;
121137 let domRef = useDOMRef ( ref ) ;
122138 return (
123139 < AriaProgressBar
124140 { ...props }
125141 ref = { domRef }
126142 style = { UNSAFE_style }
127- className = { UNSAFE_className + wrapper ( { ...props , size} , props . styles ) } >
143+ className = { UNSAFE_className + wrapper ( { ...props , size, labelPosition } , props . styles ) } >
128144 { ( { percentage, valueText} ) => (
129145 < >
130- { label && < FieldLabel size = { size } labelAlign = "start" labelPosition = "top" staticColor = { staticColor } > { label } </ FieldLabel > }
146+ { label && < FieldLabel size = { size } labelAlign = "start" labelPosition = { labelPosition } staticColor = { staticColor } > { label } </ FieldLabel > }
131147 { label && < span className = { valueStyles ( { size, labelAlign : 'end' , staticColor} ) } > { valueText } </ span > }
132148 < div className = { trackStyles ( { ...props } ) } >
133149 < div
0 commit comments