PropertyFieldButtonWithCallout control¶
This control generates a button control with a callout.
PropertyFieldButtonWithCallout rendering

PropertyFieldButtonWithCallout callout opened

How to use this control in your solutions¶
- Check that you installed the
@pnp/spfx-property-controlsdependency. Check out The getting started page for more information about installing the dependency. - Import the following modules to your component:
import { CalloutTriggers } from '@pnp/spfx-property-controls/lib/Callout';
import { PropertyFieldButtonWithCallout } from '@pnp/spfx-property-controls/lib/PropertyFieldButtonWithCallout';
- Add the custom property control to the
groupFieldsof the web part property pane configuration:
PropertyFieldButtonWithCallout('fakeProperty', {
calloutTrigger: CalloutTriggers.Click,
key: 'buttonWithCalloutFieldId',
calloutContent: React.createElement('p', {}, 'Tests connection to the database with the parameters listed above'),
calloutWidth: 150,
text: 'Test connection',
onClick: () => { /* Code to test db connection */ }
})
Implementation¶
The PropertyFieldButtonWithCallout control uses the same implementation as the default PropertyPaneButton and has the following additional properties:
| Property | Type | Required | Description |
|---|---|---|---|
| calloutContent | React.ReactNode | no | Callout content - any HTML |
| calloutWidth | number | no | Custom width for callout including borders. If value is 0, no width is applied. |
| calloutTrigger | CalloutTriggers | no | Event to show the callout |
| gapSpace | number | no | The gap between the callout and the target |
Enum CalloutTriggers
| Name | Description |
|---|---|
| Click | Shows the callout when you hover over the icon |
| Hover | Shows the callout when you click on the icon |