Our Popover
component for AstroLaunch UI & React is a small overlay of content that is used to demonstrate secondary information of any component when a user clicks it.
See below our simple popover example that you can use in your web project.
Preview
Code
You can change the position of the Popover
component using the placement
prop.
Preview
Code
You can modify the open/close state animation for Popover
component using the animate
prop.
Preview
Code
Use this beautiful popover if you want to let the users subscribe easily.
Preview
Code
Use this example of a popover component to help users get the help they need easier.
Preview
Code
This example is used to show more information. It contains an image, headline, description, and link.
Preview
Code
Use this example to help the user find out more information about a profile.
Preview
Code
Preview
Code
The following props are available for popover component. These are the custom props that we've added for the popover component and you can use all the other native props as well.
Attribute | Type | Description | Default |
---|---|---|---|
open | boolean | Makes the popover open, when popover is controlled | undefined |
handler | function | Change open state for controlled popover | undefined |
placement | Placement | Change popover placement | top |
offset | Offset | Change popover offset from it's handler | 5 |
dismiss | Dismiss | Change dismiss listeners when clicking outside | undefined |
animate | Animate | Change popover animation | undefined |
children | node | Add content for popover | No default value it's a required prop. |
import type { PopoverProps } from "@material-tailwind/react";
The following props are available for popover handler component. These are the custom props that we've added for the popover handler component and you can use all the other native props as well.
Attribute | Type | Description | Default |
---|---|---|---|
children | node | Add content for popover handler | No default value it's a required prop. |
import type { PopoverHandlerProps } from "@material-tailwind/react";
The following props are available for popover content component. These are the custom props that we've added for the popover content component and you can use all the other native props as well.
Attribute | Type | Description | Default |
---|---|---|---|
className | node | Add custom className for popover content | '' |
children | node | Add content for popover content | No default value it's a required prop. |
import type { PopoverContentProps } from "@material-tailwind/react";
type placement =
| "top"
| "top-start"
| "top-end"
| "right"
| "right-start"
| "right-end"
| "bottom"
| "bottom-start"
| "bottom-end"
| "left"
| "left-start"
| "left-end";
type offset =
| number
| {
mainAxis?: number;
crossAxis?: number;
alignmentAxis?: number | null;
};
type dismissType = {
enabled?: boolean;
escapeKey?: boolean;
referencePress?: boolean;
referencePressEvent?: 'pointerdown' | 'mousedown' | 'click';
outsidePress?: boolean | ((event: MouseEvent) => boolean);
outsidePressEvent?: 'pointerdown' | 'mousedown' | 'click';
ancestorScroll?: boolean;
bubbles?: boolean | {
escapeKey?: boolean;
outsidePress?: boolean;
};
};
type animate = {
mount?: object;
unmount?: object;
};
Learn how to customize the theme and styles for popover components, the theme object for popover components has two main objects:
A. The defaultProps
object for setting up the default value for props of popover component.
B. The styles
object for customizing the theme and styles of popover component.
You can customize the theme and styles of popover components by adding Tailwind CSS classes as key paired values for objects.
interface PopoverStylesType {
defaultProps: {
placement: string;
offset:
| number
| {
mainAxis: number;
crossAxis: number;
alignmentAxis: number;
};
dismiss: {
enabled: boolean;
escapeKey: boolean;
referencePress: boolean;
referencePressEvent: 'pointerdown' | 'mousedown' | 'click';
outsidePress: boolean | ((event: MouseEvent) => boolean);
outsidePressEvent: 'pointerdown' | 'mousedown' | 'click';
ancestorScroll: boolean;
bubbles: boolean | {
escapeKey: boolean;
outsidePress: boolean;
};
};
animate: {
mount: object;
unmount: object;
};
className: string;
};
styles: {
base: object;
};
}
import type { PopoverStylesType } from "@material-tailwind/react";
const theme = {
popover: {
defaultProps: {
placement: "top",
offset: 5,
dismiss: {},
animate: {
unmount: {},
mount: {},
},
className: "",
},
styles: {
base: {
bg: "bg-white",
p: "p-4",
border: "border border-blue-gray-50",
borderRadius: "rounded-lg",
boxShadow: "shadow-lg shadow-blue-gray-500/10",
fontFamily: "font-sans",
fontSize: "text-sm",
fontWeight: "font-normal",
color: "text-blue-gray-500",
outline: "focus:outline-none",
overflowWrap: "break-words",
whiteSpace: "whitespace-normal",
},
},
},
};
If you want to see more examples and properties please check the official Material Tailwind Documentation.