Skip to content

Commit 96506d1

Browse files
authored
ActionBar expose buttonLabelBehavior prop (#6708)
1 parent a3566e4 commit 96506d1

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

packages/@react-spectrum/actionbar/src/ActionBar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function ActionBarInner<T>(props: ActionBarInnerProps<T>, ref: Ref<HTMLDivElemen
5858
onClearSelection,
5959
selectedItemCount,
6060
isOpen,
61+
buttonLabelBehavior = 'collapse',
6162
items
6263
} = props;
6364

@@ -110,7 +111,7 @@ function ActionBarInner<T>(props: ActionBarInnerProps<T>, ref: Ref<HTMLDivElemen
110111
isQuiet
111112
staticColor={isEmphasized ? 'white' : undefined}
112113
overflowMode="collapse"
113-
buttonLabelBehavior="collapse"
114+
buttonLabelBehavior={buttonLabelBehavior}
114115
onAction={onAction}
115116
UNSAFE_className={classNames(styles, 'react-spectrum-ActionBar-actionGroup')}>
116117
{children}

packages/@react-spectrum/actionbar/stories/ActionBar.stories.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export default {
3131
},
3232
isEmphasized: {
3333
control: 'boolean'
34+
},
35+
buttonLabelBehavior: {
36+
control: 'select',
37+
options: ['show', 'hide', 'collapse']
3438
}
3539
}
3640
} as ComponentMeta<typeof ActionBar>;

packages/@react-types/actionbar/src/index.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ export interface ActionBarProps<T> {
2727
/** Whether the ActionBar should be displayed with a emphasized style. */
2828
isEmphasized?: boolean,
2929
/** Handler that is called when an ActionBar button is pressed. */
30-
onAction?: (key: Key) => void
30+
onAction?: (key: Key) => void,
31+
/**
32+
* Defines when the text within the buttons should be hidden and only the icon should be shown.
33+
* When set to 'hide', the text is always shown in a tooltip. When set to 'collapse', the text is visible
34+
* if space is available, and hidden when space is limited. The text is always visible when the item
35+
* is collapsed into a menu.
36+
* @default 'collapse'
37+
*/
38+
buttonLabelBehavior?: 'show' | 'collapse' | 'hide'
3139
}
3240

3341
export interface SpectrumActionBarProps<T> extends ActionBarProps<T>, DOMProps, StyleProps {}

0 commit comments

Comments
 (0)