@@ -90,7 +90,7 @@ export default function App() {
9090The ` onChange ` callback returns an ** array of selected teeth objects** :
9191
9292``` ts
93- type ToothSelection = {
93+ type ToothDetail = {
9494 id: string ;
9595 notations: {
9696 fdi: string ;
@@ -133,16 +133,151 @@ Example JSON output:
133133| Prop | Type | Default | Description |
134134| --- | --- | --- | --- |
135135| ` defaultSelected ` | ` string[] ` | ` [] ` | Tooth IDs selected on first render. |
136- | ` onChange ` | ` (selectedTeeth: ToothSelection[]) => void ` | — | Called whenever selection changes. |
136+ | ` singleSelect ` | ` boolean ` | ` false ` | Allow selecting only one tooth at a time (clicking the selected tooth clears it). |
137+ | ` onChange ` | ` (selectedTeeth: ToothDetail[]) => void ` | — | Called whenever selection changes. |
137138| ` name ` | ` string ` | ` "teeth" ` | Name used for hidden form input. |
138139| ` className ` | ` string ` | ` "" ` | Additional class for wrapper customization. |
139140| ` theme ` | ` "light" \| "dark" ` | ` "light" ` | Applies built-in light/dark palette. |
140141| ` colors ` | ` { darkBlue?: string; baseBlue?: string; lightBlue?: string } ` | ` {} ` | Override palette colors. |
141142| ` notation ` | ` "FDI" \| "Universal" \| "Palmer" ` | ` "FDI" ` | Display notation in native tooth titles/tooltips. |
142- | ` tooltip ` | ` { placement?: Placement; margin?: number; content?: ReactNode \| ((payload?: ToothSelection ) => ReactNode) } ` | ` { placement: "top", margin: 10 } ` | Tooltip behavior and custom content renderer. |
143+ | ` tooltip ` | ` { placement?: Placement; margin?: number; content?: ReactNode \| ((payload?: ToothDetail ) => ReactNode) } ` | ` { placement: "top", margin: 10 } ` | Tooltip behavior and custom content renderer. |
143144| ` showTooltip ` | ` boolean ` | ` true ` | Enables/disables tooltip rendering. |
144145| ` showHalf ` | ` "full" \| "upper" \| "lower" ` | ` "full" ` | Render full chart or only upper/lower arches. |
145146| ` maxTeeth ` | ` number ` | ` 8 ` | Number of teeth per quadrant (for baby/mixed dentition views). |
147+ | ` teethConditions ` | ` ToothConditionGroup[] ` | ` undefined ` | Colorize specific teeth by condition. |
148+ | ` readOnly ` | ` boolean ` | ` false ` | Disable interactions and selection changes. |
149+ | ` showLabels ` | ` boolean ` | ` false ` | Show the condition legend under the chart. |
150+ | ` layout ` | ` "circle" \| "square" ` | ` "circle" ` | Render classic arch layout or square/row layout. |
151+ | ` styles ` | ` React.CSSProperties ` | ` undefined ` | Inline styles applied to the root container. |
152+
153+ ` Placement ` values:
154+
155+ ``` ts
156+ type Placement =
157+ | " top"
158+ | " top-start"
159+ | " top-end"
160+ | " right"
161+ | " right-start"
162+ | " right-end"
163+ | " bottom"
164+ | " bottom-start"
165+ | " bottom-end"
166+ | " left"
167+ | " left-start"
168+ | " left-end" ;
169+ ```
170+
171+ ` teethConditions ` shape:
172+
173+ ``` ts
174+ type ToothConditionGroup = {
175+ label: string ;
176+ teeth: string []; // e.g. ["teeth-11", "teeth-12"]
177+ outlineColor: string ;
178+ fillColor: string ;
179+ };
180+ ```
181+
182+ ---
183+
184+ ## 🧩 Common Recipes
185+
186+ ### 1) Render a custom tooltip
187+
188+ ``` tsx
189+ import { Odontogram } from " react-odontogram" ;
190+ import " react-odontogram/style.css" ;
191+
192+ export default function CustomTooltipExample() {
193+ return (
194+ <Odontogram
195+ tooltip = { {
196+ placement: " top" ,
197+ content : (payload ) => (
198+ <div style = { { minWidth: 140 }} >
199+ <strong >Tooth { payload ?.notations .fdi } </strong >
200+ <div >{ payload ?.type } </div >
201+ <small >Universal: { payload ?.notations .universal } </small >
202+ </div >
203+ ),
204+ }}
205+ />
206+ );
207+ }
208+ ```
209+
210+ ### 2) Change theme and colors
211+
212+ ``` tsx
213+ import { Odontogram } from " react-odontogram" ;
214+ import " react-odontogram/style.css" ;
215+
216+ export default function ThemeExample() {
217+ return (
218+ <Odontogram
219+ className = " my-odontogram"
220+ theme = " dark"
221+ colors = { {
222+ darkBlue: " #7c9cff" ,
223+ baseBlue: " #c7d2fe" ,
224+ lightBlue: " #4f46e5" ,
225+ }}
226+ />
227+ );
228+ }
229+ ```
230+
231+ ``` css
232+ .my-odontogram {
233+ --odontogram-tooltip-bg : #0f172a ;
234+ --odontogram-tooltip-fg : #f8fafc ;
235+ }
236+ ```
237+
238+ ### 3) Show ` teethConditions ` (with legend)
239+
240+ ``` tsx
241+ import { Odontogram } from " react-odontogram" ;
242+ import " react-odontogram/style.css" ;
243+
244+ const conditions = [
245+ {
246+ label: " caries" ,
247+ teeth: [" teeth-16" , " teeth-26" , " teeth-36" ],
248+ fillColor: " #ef4444" ,
249+ outlineColor: " #b91c1c" ,
250+ },
251+ {
252+ label: " filling" ,
253+ teeth: [" teeth-14" , " teeth-24" ],
254+ fillColor: " #60a5fa" ,
255+ outlineColor: " #1d4ed8" ,
256+ },
257+ ];
258+
259+ export default function ConditionsExample() {
260+ return <Odontogram teethConditions = { conditions } showLabels readOnly />;
261+ }
262+ ```
263+
264+ ### 4) Adjust tooltip position
265+
266+ ``` tsx
267+ import { Odontogram } from " react-odontogram" ;
268+ import " react-odontogram/style.css" ;
269+
270+ export default function TooltipPositionExample() {
271+ return (
272+ <Odontogram
273+ tooltip = { {
274+ placement: " right-start" , // try: top, right, bottom-end, left-start...
275+ margin: 18 , // larger = farther from tooth, smaller = closer
276+ }}
277+ />
278+ );
279+ }
280+ ```
146281
147282---
148283
0 commit comments