Documentation / Feedback & overlays
HelpButton
A small round “?” button that opens a contextual help bubble next to a field or a heading. The content is a text, interpreted as HTML reduced to its formatting (headings, lists, links, code, tables: no style, no form, no image), Markdown with markdown (GFM: lists, tables, code…, no image either) or any React node. The bubble closes on an outside click and on Escape. WithHelpButton places the button right after its children.
With editable, a pencil in the header lets the help be rewritten in place: onSave(content) receives the text and returns true (or a promise of true) if the save succeeded; passing the new text back into content is up to you. onReset adds a reset button. To edit Markdown, pass MarkdownEditor (separate entry @synertech/ui/markdown-editor) to the markdownEditor prop. "use client" component.
Examples
Basic usage
A short plain-text help, opened below the button by default.
import { HelpButton } from "@synertech/ui";
export function Basic() {
return <HelpButton content="Le SIRET comporte 14 chiffres, sans espace." />;
}Next to a label
WithHelpButton lines the button up after its children; title adds a header to the bubble.
import { WithHelpButton } from "@synertech/ui";
export function NextToLabel() {
return (
<WithHelpButton
title="Taux de conversion"
content="Part des visiteurs ayant passé au moins une commande sur la période."
position="right"
>
<span className="text-sm font-medium text-gray-700 dark:text-gray-300">
Taux de conversion
</span>
</WithHelpButton>
);
}Markdown content
markdown interprets the text (headings, lists, code, links); width widens the bubble.
import { HelpButton } from "@synertech/ui";
export function Markdown() {
return (
<HelpButton
markdown
width="lg"
title="Format d’import"
content={`Le fichier CSV doit contenir :
- une colonne \`email\` **obligatoire** ;
- une colonne \`nom\` facultative.
Séparateur accepté : \`;\` ou \`,\`.`}
/>
);
}React content, sizes and positions
content accepts JSX; size sets the button, position the side of the bubble.
import { HelpButton } from "@synertech/ui";
export function RichContent() {
return (
<div className="flex items-center gap-6 p-8">
<HelpButton size="xs" position="top" content="Petit bouton, bulle au-dessus." />
<HelpButton
size="lg"
position="right"
width="sm"
content={
<ul className="list-disc pl-4">
<li>8 caractères minimum</li>
<li>une majuscule et un chiffre</li>
</ul>
}
/>
</div>
);
}Editable help
editable opens a text area; onSave persists the text and passes it back up into content.
import { useState } from "react";
import { HelpButton } from "@synertech/ui";
export function Editable() {
const [help, setHelp] = useState("Indiquez le numéro de commande figurant sur votre facture.");
const initial = "Indiquez le numéro de commande figurant sur votre facture.";
const save = async (content: string) => {
await new Promise((resolve) => setTimeout(resolve, 500));
setHelp(content);
return true;
};
return (
<HelpButton
editable
title="Numéro de commande"
content={help}
onSave={save}
onReset={() => {
setHelp(initial);
return true;
}}
/>
);
}API reference
Components
import { HelpButton } from "@synertech/ui";Props — HelpButtonProps
| Prop | Type | Default | Description |
|---|---|---|---|
content• |
string | ReactNode |
— | What the bubble shows: a node as it is, a string as Markdown under |
className |
string |
"" |
|
editable |
boolean |
false |
|
labels |
UILabelsOf<"helpButton" | "markdownEditor"> |
— | The strings the button writes itself, for this instance: any |
markdown |
boolean |
false |
|
markdownEditor |
MarkdownEditorComponent |
— | Editor rendered when both |
markdownEditorUnavailableLabel |
string |
— | Shown in place of the editor when |
onReset |
() => Promise<boolean> | boolean |
— | |
onSave |
(content: string) => Promise<boolean> | boolean |
— | |
position |
"top" | "bottom" | "left" | "right" |
"bottom" |
|
size |
"xs" | "sm" | "md" | "lg" |
"sm" |
|
title |
string |
— | |
visible |
boolean |
true |
|
width |
"sm" | "md" | "lg" | "xl" |
"md" |
import { WithHelpButton } from "@synertech/ui";Props — WithHelpButtonProps
| Prop | Type | Default | Description |
|---|---|---|---|
children• |
ReactNode |
— | |
content• |
string | ReactNode |
— | What the bubble shows: a node as it is, a string as Markdown under |
className |
string |
— | |
editable |
boolean |
false |
|
labels |
UILabelsOf<"helpButton" | "markdownEditor"> |
— | The strings the button writes itself, for this instance: any |
markdown |
boolean |
false |
|
markdownEditor |
MarkdownEditorComponent |
— | Editor rendered when both |
markdownEditorUnavailableLabel |
string |
— | Shown in place of the editor when |
onReset |
() => Promise<boolean> | boolean |
— | |
onSave |
(content: string) => Promise<boolean> | boolean |
— | |
position |
"top" | "bottom" | "left" | "right" |
"bottom" |
|
size |
"xs" | "sm" | "md" | "lg" |
"sm" |
|
title |
string |
— | |
visible |
boolean |
true |
|
width |
"sm" | "md" | "lg" | "xl" |
"md" |
Types
Any component accepting MarkdownEditorProps. The stock one is MarkdownEditor from @synertech/ui/markdown-editor.
type MarkdownEditorComponent = ComponentType<MarkdownEditorProps>