DropdownMenu
Basic
<DropdownMenu
buttonText="Basic example"
items={[
{
type: "button",
text: "Foo",
onClick: () => {
alert("Foo");
},
},
{
type: "button",
text: "Bar",
onClick: () => {
alert("Bar");
},
},
]}
/>
Button styling
Whatever you pass to
buttonProps
will be passed through to a Button
component that DropdownMenu
uses internally.<DropdownMenu
buttonText="Button styling example"
buttonProps={{ variant: "primary" }}
items={[
{
type: "button",
text: "Foo",
onClick: () => {
alert("Foo");
},
},
{
type: "button",
text: "Bar",
onClick: () => {
alert("Bar");
},
},
]}
/>
Links
<DropdownMenu
buttonText="Links example"
items={[
{
type: "link",
text: "Foo",
href: "/foo",
},
{
type: "link",
text: "Bar",
href: "/bar",
},
]}
/>
Separator
<DropdownMenu
buttonText="Separator example"
items={[
{
type: "button",
text: "Foo",
onClick: () => {
alert("Foo");
},
},
{ type: "separator" },
{
type: "button",
text: "Bar",
onClick: () => {
alert("Bar");
},
},
]}
/>
Disabled item
<DropdownMenu
buttonText="Disabled item example"
items={[
{
type: "button",
text: "Foo",
disabled: true,
onClick: () => {
alert("Foo");
},
},
{
type: "button",
text: "Bar",
onClick: () => {
alert("Bar");
},
},
]}
/>
Sections
<DropdownMenu
buttonText="Example of sections"
items={[
{
type: "section",
heading: "Fruits",
items: [
{
type: "button",
text: "Apple",
onClick: () => {
alert("Apple");
},
},
{
type: "button",
text: "Banana",
onClick: () => {
alert("Banana");
},
},
],
},
{
type: "section",
heading: "Vegetables",
items: [
{
type: "button",
text: "Onion",
onClick: () => {
alert("Onion");
},
},
{
type: "button",
text: "Carrot",
onClick: () => {
alert("Carrot");
},
},
],
},
]}
/>
Props
Prop | Required | Default | Type and notes |
---|---|---|---|
buttonText | - |
| |
buttonProps | - | - |
See the docs for the Button component. |
items | - |
The type for DropdownMenuItemType is:
|