|
| 1 | +# Contextual Help |
| 2 | + |
| 3 | +Contextual help can be used to show extra information about the state of a component. |
| 4 | + |
| 5 | +## Example |
| 6 | + |
| 7 | +For the contextual help component, both the `heading` and `content` props are required. |
| 8 | + |
| 9 | +```python |
| 10 | +from deephaven import ui |
| 11 | + |
| 12 | + |
| 13 | +my_contextual_help_basic = ui.contextual_help( |
| 14 | + heading="Need Help", |
| 15 | + content="If you are having issues accessing your account, contact our customer support team for help.", |
| 16 | + variant="info", |
| 17 | +) |
| 18 | +``` |
| 19 | + |
| 20 | + |
| 21 | +## Placement |
| 22 | + |
| 23 | +The contextual help component supports different placement options for when the popover's positioning needs to be customized. |
| 24 | + |
| 25 | +```python |
| 26 | +from deephaven import ui |
| 27 | + |
| 28 | + |
| 29 | +@ui.component |
| 30 | +def ui_contextual_help_placement_examples(): |
| 31 | + return [ |
| 32 | + ui.contextual_help( |
| 33 | + heading="Need Help", |
| 34 | + content="If you are having issues accessing your account, contact our customer support team for help.", |
| 35 | + variant="info", |
| 36 | + ), |
| 37 | + ui.contextual_help( |
| 38 | + heading="Need Help", |
| 39 | + content="If you are having issues accessing your account, contact our customer support team for help.", |
| 40 | + variant="info", |
| 41 | + placement="top start", |
| 42 | + ), |
| 43 | + ui.contextual_help( |
| 44 | + heading="Need Help", |
| 45 | + content="If you are having issues accessing your account, contact our customer support team for help.", |
| 46 | + variant="info", |
| 47 | + placement="end", |
| 48 | + ), |
| 49 | + ] |
| 50 | + |
| 51 | + |
| 52 | +my_contextual_help_placement_examples = ui_contextual_help_placement_examples() |
| 53 | +``` |
| 54 | + |
| 55 | + |
| 56 | +## Events |
| 57 | + |
| 58 | +The `on_open_change` prop is triggered when the popover opens or closes. |
| 59 | + |
| 60 | +```python |
| 61 | +from deephaven import ui |
| 62 | + |
| 63 | + |
| 64 | +@ui.component |
| 65 | +def ui_contextual_help_events_example(): |
| 66 | + is_open, set_is_open = ui.use_state(False) |
| 67 | + return [ |
| 68 | + ui.flex( |
| 69 | + ui.contextual_help( |
| 70 | + heading="Permission required", |
| 71 | + content="Your admin must grant you permission before you can create a segment.", |
| 72 | + variant="info", |
| 73 | + on_open_change={set_is_open}, |
| 74 | + ), |
| 75 | + align_items="center", |
| 76 | + ) |
| 77 | + ] |
| 78 | + |
| 79 | + |
| 80 | +my_contextual_help_events_example = ui_contextual_help_events_example() |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | +## Visual Options |
| 85 | + |
| 86 | +The `variant` prop can be set to either "info" or "help", depending on how the contextual help component is meant to help the user. |
| 87 | + |
| 88 | +```python |
| 89 | +from deephaven import ui |
| 90 | + |
| 91 | + |
| 92 | +@ui.component |
| 93 | +def ui_contextual_help_variant_examples(): |
| 94 | + return [ |
| 95 | + ui.contextual_help( |
| 96 | + heading="Permission required", |
| 97 | + content="Your admin must grant you permission before you can create a segment.", |
| 98 | + variant="info", |
| 99 | + ), |
| 100 | + ui.contextual_help( |
| 101 | + heading="What is a segment?", |
| 102 | + content="Segments identify who your visitors are, what devices and services they use, where they navigated from, and much more.", |
| 103 | + variant="help", |
| 104 | + ), |
| 105 | + ] |
| 106 | + |
| 107 | + |
| 108 | +my_contextual_help_variant_examples = ui_contextual_help_variant_examples() |
| 109 | +``` |
| 110 | + |
| 111 | + |
| 112 | +## API reference |
| 113 | + |
| 114 | +```{eval-rst} |
| 115 | +.. dhautofunction:: deephaven.ui.contextual_help |
| 116 | +``` |
| 117 | + |
0 commit comments