Settings and pages
These components build a settings page, such as those of the page and serverSections slots, and the cards of overviewCards. A page made with them looks like Hodi's own pages.
SectionPage
A whole settings page: its title, the sentence that explains it, then its cards. On a phone, the title moves into Hodi's header. The page receives layout from the slot that draws it, and passes it to SectionPage.
Hello world
A greeting, every time you open Hodi.
Hello world
A greeting, every time you open Hodi.
import { SectionPage, SettingRow, SettingsCard } from 'hodi:sdk'
import { Pencil } from 'lucide-react'
<SectionPage
title="Hello world"
intro="A greeting, every time you open Hodi."
layout="desktop"
>
<SettingsCard>
<SettingRow
label="Greeting"
value="Hi"
action={{
label: 'Change',
icon: Pencil,
onClick: edit
}}
/>
</SettingsCard>
</SectionPage>titlestringThe page's title, already translated.
layout'desktop' | 'phone'The screen's size, as the slot gives it to the page.
intro?ReactNodeA sentence under the title, which says what the page is for.
aside?ReactNodeAn element next to the title, or under the title on a phone.
childrenReactNodeThe page's cards, SettingsCards.
SettingsCard
A card that groups settings rows. Its name shows in small capitals above the card.
Greeting
Greeting
import { SettingRow, SettingsCard } from 'hodi:sdk'
import { Pencil } from 'lucide-react'
<SettingsCard label="Greeting">
<SettingRow
label="Text"
value="Hi"
action={{
label: 'Change',
icon: Pencil,
onClick: edit
}}
/>
</SettingsCard>label?stringThe group's name, shown above the card.
childrenReactNodeThe card's rows, SettingRows.
SettingRow
A settings row. Under its name, a 14 px line shows its value, or failing that a short hint, never both. Its action is a button with a text at the end of the row; on a phone, this button becomes a 38 px round button with the same icon. A choice (Segmented) moves under the text on a phone.
import { SettingRow, SettingsCard } from 'hodi:sdk'
import { Pencil } from 'lucide-react'
<SettingsCard>
<SettingRow
label="Text"
value="Hi"
action={{
label: 'Change',
icon: Pencil,
onClick: edit
}}
/>
</SettingsCard>labelReactNodeThe setting's name.
value?ReactNodeThe setting's value, in the text colour. A row with a value has no hint: the explanation goes in the window that changes the value.
hint?ReactNodeA short hint, in grey, on a single line, when the row has no value.
lead?ReactNodeAn element before the text, such as an avatar or an icon.
action?RowAction | RowAction[]A button at the end of the row, or two side by side. A RowAction has a label, an icon, a look, an onClick or an href, and can be disabled or busy. ariaLabel gives screen readers a fuller name.
choice?ReactNodeA Segmented, at the end of the row, or under the text on a phone.
as?'div' | 'li'The row's tag: div by default, li when the rows form a list.
children?ReactNodeElements at the end of the row, before the action, which stay in the same place on a phone: a Toggle, a Chip or small round buttons.
MoreRow
The last row of a long list, when the list only shows its first items. A click on this row shows the rest.
import { MoreRow, SettingRow, SettingsCard } from 'hodi:sdk'
<SettingsCard>
<SettingRow label="Anna" value="Hi!" />
<MoreRow label="See the 4 others" onClick={showAll} />
</SettingsCard>labelstringThe row's text, such as See the 4 others, in the plugin's words.
onClick() => voidWhat the click does: show the rest of the list.
OverviewCard
A card of overviewCards, in Server › Overview. Its title line shows a title, a number and a chip at the end. The plugin puts what it wants under it, such as a chart.
Hellos128
+12 this weekimport { Chip, OverviewCard } from 'hodi:sdk'
import WeekChart from './WeekChart.tsx'
<OverviewCard
title="Hellos"
count={128}
aside={<Chip tone="success">+12 this week</Chip>}
>
<WeekChart days={week} />
</OverviewCard>titlestringThe card's title, already translated.
count?numberA number shown in grey next to the title.
aside?ReactNodeAn element at the end of the title's line, such as a Chip or a caption.
children?ReactNodeThe card's content, under the title line.