We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The website says it's possible to split a button group with a dropdown but it doesn't say how to do in React.
The text was updated successfully, but these errors were encountered:
@CleverLemming1337 - here's a way you can use ButtonGroup as a split button with a dropdown:
ButtonGroup
StackBlitz: Rendered code:
import React from 'react'; import { ButtonGroup, Button, ActionMenu, ActionList } from '@primer/react'; import { TriangleDownIcon } from '@primer/octicons-react'; const actions = ['Action one', 'Action two', 'Action three']; export default function DropdownSplit() { const [selectedActionIndex, setSelectedActionIndex] = React.useState<number>(0); const selectedAction = actions[selectedActionIndex]; return ( <ButtonGroup> <Button onClick={() => { alert(`Activated ${selectedAction}`); }} > {selectedAction} </Button> <ActionMenu> <ActionMenu.Button icon={TriangleDownIcon}> More options </ActionMenu.Button> <ActionMenu.Overlay> <ActionList> {actions.map((action, index) => { return ( <ActionList.Item key={action} onSelect={() => { setSelectedActionIndex(index); }} > {action} </ActionList.Item> ); })} </ActionList> </ActionMenu.Overlay> </ActionMenu> </ButtonGroup> ); }
Sorry, something went wrong.
Oh, this works. Thank you!
mperrotti
No branches or pull requests
The website says it's possible to split a button group with a dropdown but it doesn't say how to do in React.
The text was updated successfully, but these errors were encountered: