import{ButtonGroup}from'@react-spectrum/buttongroup';import{Button}from'@react-spectrum/button';<ButtonGroup><Buttonvariant="primary">Rate Now</Button><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button></ButtonGroup>
import{ButtonGroup}from'@react-spectrum/buttongroup';import{Button}from'@react-spectrum/button';<ButtonGroup><Buttonvariant="primary">Rate Now</Button><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button></ButtonGroup>
import{ButtonGroup}from'@react-spectrum/buttongroup';import{Button}from'@react-spectrum/button';<ButtonGroup><Buttonvariant="primary">
Rate Now
</Button><Buttonvariant="secondary">
No, thanks
</Button><Buttonvariant="secondary">
Remind me later
</Button></ButtonGroup>
ButtonGroup expects Buttons as children and is used to handle overflow. When horizontal space is limited, the ButtonGroup switches to a vertical layout. ButtonGroup should be used when there are two or more related Buttons in a group.
To see the orientation switch in the example above, resize the width of your window.
Setting this to 'vertical' will prevent any dynamic orientation changes, the ButtonGroup will remain in vertical regardless of the available width.
<ButtonGrouporientation="vertical"><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGrouporientation="vertical"><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGrouporientation="vertical"><Buttonvariant="secondary">
No, thanks
</Button><Buttonvariant="secondary">
Remind me later
</Button><Buttonvariant="primary">
Rate Now
</Button></ButtonGroup>
Button groups are aligned contextually. Generally, button groups should be start-aligned to follow content. However, they should be end-aligned inside container components, such as in dialogs, popovers, or cards. Center alignment should be used in the context of an empty state. In right-to-left languages, alignment is flipped automatically.
<ButtonGrouporientation="vertical"align="end"><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGrouporientation="vertical"align="end"><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGrouporientation="vertical"align="end"><Buttonvariant="secondary">
No, thanks
</Button><Buttonvariant="secondary">
Remind me later
</Button><Buttonvariant="primary">
Rate Now
</Button></ButtonGroup>
<ButtonGrouporientation="vertical"align="center"><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGrouporientation="vertical"align="center"><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGrouporientation="vertical"align="center"><Buttonvariant="secondary">
No, thanks
</Button><Buttonvariant="secondary">
Remind me later
</Button><Buttonvariant="primary">
Rate Now
</Button></ButtonGroup>
<ButtonGroupisDisabled><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGroupisDisabled><Buttonvariant="secondary">No, thanks</Button><Buttonvariant="secondary">Remind me later</Button><Buttonvariant="primary">Rate Now</Button></ButtonGroup>
<ButtonGroupisDisabled><Buttonvariant="secondary">
No, thanks
</Button><Buttonvariant="secondary">
Remind me later
</Button><Buttonvariant="primary">
Rate Now
</Button></ButtonGroup>