Use our ButtonGroup
based on Tailwind CSS for actions.
ButtonGroup
is an essential element of web design. Basically,
ButtonGroup
is stack of buttons. They help users navigate our websites
or apps and drive them to a particular action.
See below our ButtonGroup
example that you can use in your Tailwind CSS and React project. The example also comes in different styles and colors, so you can adapt it easily to your needs.
The ButtonGroup
component comes with 4 different variants that you can change it using the variant
prop.
The ButtonGroup
component comes with 3 different sizes that you can change it using the size
prop.
The ButtonGroup
component comes with 19 different colors that you can change it using the color
prop.
A ButtonGroup
could be a block level component as well that get's all the available space in a row. You can render a ButtonGroup
as a block level element using the fullWidth
prop.
You can turn on/off the ripple effect for the ButtonGroup
component using the ripple
prop.
You can use the className
prop to add custom styles to the ButtonGroup
component.
The following props are available for button group component. These are the custom props that we've added for the button group component and you can use all the other native props as well.
Attribute | Type | Description | Default |
---|---|---|---|
variant | Variant | Change buttons variant | filled |
size | Size | Change buttons size | md |
color | Color | Change buttons color | blue |
fullWidth | boolean | Change buttons to a block level elements | false |
ripple | boolean | Add ripple effect for buttons | true |
className | string | Add custom className for button group | '' |
children | node | Add content for button group | No default value it's a required prop. |
import type { ButtonGroupProps } from "@material-tailwind/react";
type variant = "filled" | "outlined" | "gradient" | "text";
type size = "sm" | "md" | "lg";
type color =
| "white"
| "blue-gray"
| "gray"
| "brown"
| "deep-orange"
| "orange"
| "amber"
| "yellow"
| "lime"
| "light-green"
| "green"
| "teal"
| "cyan"
| "light-blue"
| "blue"
| "indigo"
| "deep-purple"
| "purple"
| "pink"
| "red";
Learn how to customize the theme and styles for button group component, the theme object for button group component has three main objects:
A. The defaultProps
object for setting up the default value for props of button group component.
B. The valid
object for customizing the valid values for button group component props.
C. The styles
object for customizing the theme and styles of button group component.
You can customize the theme and styles of button group component by adding Tailwind CSS classes as key paired values for objects.
interface ButtonStyleTypes {
defaultProps: {
variant: string;
size: string;
color: string;
fullWidth: boolean;
ripple: boolean;
className: string;
};
valid: {
variants: string[];
sizes: string[];
colors: string[];
};
styles: {
base: {
initial: object;
fullWidth: object;
};
dividerColor: object;
};
}
import type { ButtonGroupStyleTypes } from "@material-tailwind/react";
const theme = {
buttonGroup: {
defaultProps: {
variant: "filled",
size: "md",
color: "blue",
fullWidth: false,
ripple: true,
className: "",
},
valid: {
variants: ["filled", "outlined", "gradient", "text"],
sizes: ["sm", "md", "lg"],
colors: [
"white",
"blue-gray",
"gray",
"brown",
"deep-orange",
"orange",
"amber",
"yellow",
"lime",
"light-green",
"green",
"teal",
"cyan",
"light-blue",
"blue",
"indigo",
"deep-purple",
"purple",
"pink",
"red",
],
},
styles: {
base: {
initial: {
display: "flex",
flexDirection: "row",
},
fullWidth: {
width: "w-full",
},
},
dividerColor: {
white: {
divideColor: "divide-blue-gray-50",
},
"blue-gray": {
divideColor: "divide-blue-gray-600",
},
gray: {
divideColor: "divide-gray-600",
},
brown: {
divideColor: "divide-brown-600",
},
"deep-orange": {
divideColor: "divide-deep-orange-600",
},
orange: {
divideColor: "divide-orange-600",
},
amber: {
divideColor: "divide-amber-600",
},
yellow: {
divideColor: "divide-yellow-600",
},
lime: {
divideColor: "divide-lime-600",
},
"light-green": {
divideColor: "divide-light-green-600",
},
green: {
divideColor: "divide-green-600",
},
teal: {
divideColor: "divide-teal-600",
},
cyan: {
divideColor: "divide-cyan-600",
},
"light-blue": {
divideColor: "divide-light-blue-600",
},
blue: {
divideColor: "divide-blue-600",
},
indigo: {
divideColor: "divide-indigo-600",
},
"deep-purple": {
divideColor: "divide-deep-purple-600",
},
purple: {
divideColor: "divide-purple-600",
},
pink: {
divideColor: "divide-pink-600",
},
red: {
divideColor: "divide-red-600",
},
},
},
},
};