React Button Group - Flowbite
Button groups allow you to stack together multiple buttons in a single line horizontally based on multiple styles and sizes using React and Tailwind CSS
Table of Contents#
- Default button group
- Button group with icons
- Outline button group
- Color options
- Outline button group with icons
- Theme
- References
Default button group#
Use this example of the <Button.Group>
component by adding the Button
component as a child element and stack them together. You can also use the color
prop to change the color of the buttons.
- React TypeScript
'use client';
import { Button } from 'flowbite-react';
export default function DefaultButtonGroup() {
return (
<Button.Group>
<ButtonComponentFn color="gray">
Profile
</ButtonComponentFn>
<ButtonComponentFn color="gray">
Settings
</ButtonComponentFn>
<ButtonComponentFn color="gray">
Messages
</ButtonComponentFn>
</Button.Group>
)
}
Button group with icons#
Import one of the icons from the react-icons
library and add it as a child element to the <Button>
component to create multiple buttons with icons grouped together.
- React TypeScript
'use client';
import { Button } from 'flowbite-react';
import { HiAdjustments, HiCloudDownload, HiUserCircle } from 'react-icons/hi';
export default function WithIcons() {
return (
<Button.Group>
<ButtonComponentFn color="gray">
<HiUserCircle className="mr-3 h-4 w-4" />
<p>
Profile
</p>
</ButtonComponentFn>
<ButtonComponentFn color="gray">
<HiAdjustments className="mr-3 h-4 w-4" />
<p>
Settings
</p>
</ButtonComponentFn>
<ButtonComponentFn color="gray">
<HiCloudDownload className="mr-3 h-4 w-4" />
<p>
Messages
</p>
</ButtonComponentFn>
</Button.Group>
)
}
Outline button group#
By passing the outline prop to the <Button.Group>
component you can create a button group with outline buttons with no background and solid borders.
- React TypeScript
'use client';
import { Button } from 'flowbite-react';
export default function Outline() {
return (
<>
<Button.Group outline>
<ButtonComponentFn color="gray">
Profile
</ButtonComponentFn>
<ButtonComponentFn color="gray">
Settings
</ButtonComponentFn>
<ButtonComponentFn color="gray">
Messages
</ButtonComponentFn>
</Button.Group>
<Button.Group outline>
<ButtonComponentFn gradientMonochrome="info">
Profile
</ButtonComponentFn>
<ButtonComponentFn gradientMonochrome="info">
Settings
</ButtonComponentFn>
<ButtonComponentFn gradientMonochrome="info">
Messages
</ButtonComponentFn>
</Button.Group>
<Button.Group outline>
<ButtonComponentFn gradientDuoTone="cyanToBlue">
Profile
</ButtonComponentFn>
<ButtonComponentFn gradientDuoTone="cyanToBlue">
Settings
</ButtonComponentFn>
<ButtonComponentFn gradientDuoTone="cyanToBlue">
Messages
</ButtonComponentFn>
</Button.Group>
</>
)
}
Color options#
Use the color
prop to change the color of the buttons. You can also use the gradientMonochrome
and gradientDuoTone
props to apply a gradient color to the buttons.
- React TypeScript
'use client';
import { Button } from 'flowbite-react';
export default function AllColors() {
return (
<>
<Button.Group>
<ButtonComponentFn color="info">
Profile
</ButtonComponentFn>
<ButtonComponentFn color="info">
Settings
</ButtonComponentFn>
<ButtonComponentFn color="info">
Messages
</ButtonComponentFn>
</Button.Group>
<Button.Group>
<ButtonComponentFn gradientMonochrome="info">
Profile
</ButtonComponentFn>
<ButtonComponentFn gradientMonochrome="info">
Settings
</ButtonComponentFn>
<ButtonComponentFn gradientMonochrome="info">
Messages
</ButtonComponentFn>
</Button.Group>
<Button.Group>
<ButtonComponentFn gradientDuoTone="greenToBlue">
Profile
</ButtonComponentFn>
<ButtonComponentFn gradientDuoTone="greenToBlue">
Settings
</ButtonComponentFn>
<ButtonComponentFn gradientDuoTone="greenToBlue">
Messages
</ButtonComponentFn>
</Button.Group>
</>
)
}
Outline button group with icons#
Here's an example on how you can use both the outline and icon props together.
- React TypeScript
'use client';
import { Button } from 'flowbite-react';
import { HiAdjustments, HiCloudDownload, HiUserCircle } from 'react-icons/hi';
export default function OutlineWithIcons() {
return (
<>
<Button.Group outline>
<ButtonComponentFn color="gray">
<HiUserCircle className="mr-3 h-4 w-4" />
<p>
Profile
</p>
</ButtonComponentFn>
<ButtonComponentFn color="gray">
<HiAdjustments className="mr-3 h-4 w-4" />
<p>
Settings
</p>
</ButtonComponentFn>
<ButtonComponentFn color="gray">
<HiCloudDownload className="mr-3 h-4 w-4" />
<p>
Messages
</p>
</ButtonComponentFn>
</Button.Group>
<Button.Group outline>
<ButtonComponentFn gradientMonochrome="info">
<HiUserCircle className="mr-3 h-4 w-4" />
<p>
Profile
</p>
</ButtonComponentFn>
<ButtonComponentFn gradientMonochrome="info">
<HiAdjustments className="mr-3 h-4 w-4" />
<p>
Settings
</p>
</ButtonComponentFn>
<ButtonComponentFn gradientMonochrome="info">
<HiCloudDownload className="mr-3 h-4 w-4" />
<p>
Messages
</p>
</ButtonComponentFn>
</Button.Group>
<Button.Group outline>
<ButtonComponentFn gradientDuoTone="cyanToBlue">
<HiUserCircle className="mr-3 h-4 w-4" />
<p>
Profile
</p>
</ButtonComponentFn>
<ButtonComponentFn gradientDuoTone="cyanToBlue">
<HiAdjustments className="mr-3 h-4 w-4" />
<p>
Settings
</p>
</ButtonComponentFn>
<ButtonComponentFn gradientDuoTone="cyanToBlue">
<HiCloudDownload className="mr-3 h-4 w-4" />
<p>
Messages
</p>
</ButtonComponentFn>
</Button.Group>
</>
)
}
Theme#
To learn more about how to customize the appearance of components, please see the Theme docs.
{
"base": "inline-flex",
"position": {
"none": "focus:ring-2",
"start": "rounded-r-none",
"middle": "rounded-none border-l-0 pl-0",
"end": "rounded-l-none border-l-0 pl-0"
}
}