Sections under headings that open and close, one at a time or several, and a single disclosure for extra options.
You pay for the days left in the period. The charge shows on your next invoice as a separate line.
Yes. The change starts at the next renewal, and you keep every feature until then. Projects over the new limit become read-only, not deleted.
Settings → Billing → Invoices. Each one downloads as a PDF with your company's tax ID on it.
Within 14 days of a renewal, yes: write to billing and we refund the whole year.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Accordion } from "./ui/uicontext/components/Accordion.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ wrap: { inlineSize: "min(100%, 34rem)" }, answer: { margin: 0 } })const questions = [ { value: "proration", title: "What happens when I add seats mid-month?", answer: "You pay for the days left in the period. The charge shows on your next invoice as a separate line.", }, { value: "downgrade", title: "Can I move to a smaller plan?", answer: "Yes. The change starts at the next renewal, and you keep every feature until then. Projects over the new limit become read-only, not deleted.", }, { value: "invoice", title: "Where do I find past invoices?", answer: "Settings → Billing → Invoices. Each one downloads as a PDF with your company's tax ID on it.", }, { value: "refund", title: "Do you refund unused time after I cancel an annual plan that renewed by mistake?", answer: "Within 14 days of a renewal, yes: write to billing and we refund the whole year.", },]const Message = UiSchema.TaggedEnum({ ToggledQuestions: { open: Schema.Array(Schema.String) } })export const BillingFaq = Html.component({ name: "BillingFaq", model: Schema.Struct({ open: Schema.Array(Schema.String) }), message: Message,}).make({ init: () => ({ open: ["proration"] }), update: { ToggledQuestions: ($, { open }) => $.evolve({ open }) }, view: (h, { open }) => h.div.attrs(sx(styles.wrap)).children( Accordion(h, { items: questions, open, onToggle: (next) => Message.ToggledQuestions({ open: next }), panel: (q) => h.p.attrs(sx(styles.answer)).children(q.answer), }), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/accordionUsage
import { Accordion } from "./ui/uicontext/components/Accordion.ts"const Message = UiSchema.TaggedEnum({ ToggledQuestions: { open: Schema.Array(Schema.String) } })const questions = [ { value: "seats", title: "What happens when I add seats?", answer: "You pay for the days left in the period." }, { value: "invoices", title: "Where are my invoices?", answer: "Settings → Billing → Invoices." },]export const Faq = (h: Html.H<typeof Message.Type>, open: ReadonlyArray<string>) => Accordion(h, { items: questions, open, onToggle: (next) => Message.ToggledQuestions({ open: next }), panel: (q) => h.p.children(q.answer), })Examples
Several open, boxed
multiple keeps every group you open. A disabled heading stays visible but won't open.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Accordion } from "./ui/uicontext/components/Accordion.ts"import { Checkbox } from "./ui/uicontext/components/Checkbox.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ wrap: { inlineSize: "min(100%, 30rem)" }, list: { display: "grid", gap: 10 } })const groups = [ { value: "issues", title: "Issues", events: ["Assigned to me", "Mentioned", "Status changed", "Due tomorrow"] }, { value: "docs", title: "Docs", events: ["Comment on my doc", "Shared with me", "Edited after I left"] }, { value: "billing", title: "Billing", events: [], disabled: true, note: "Owners only" },]const Message = UiSchema.TaggedEnum({ ToggledGroups: { open: Schema.Array(Schema.String) }, ToggledEvent: { event: Schema.String, on: Schema.Boolean },})// settings in groups: open several to compare them; Billing is locked for this memberexport const NotificationGroups = Html.component({ name: "NotificationGroups", model: Schema.Struct({ open: Schema.Array(Schema.String), on: Schema.Array(Schema.String) }), message: Message,}).make({ init: () => ({ open: ["issues", "docs"], on: ["Assigned to me", "Mentioned", "Status changed", "Comment on my doc"] }), update: { ToggledGroups: ($, { open }) => $.evolve({ open }), ToggledEvent: ($, { event, on }) => $.evolve({ on: (list) => (on ? [...list, event] : list.filter((e) => e !== event)) }), }, view: (h, { open, on }) => h.div.attrs(sx(styles.wrap)).children( Accordion(h, { items: groups.map((g) => ({ ...g, meta: g.note ?? `${g.events.filter((e) => on.includes(e)).length} of ${g.events.length}` })), open, multiple: true, boxed: true, onToggle: (next) => Message.ToggledGroups({ open: next }), panel: (group) => h.div.attrs(sx(styles.list)).children( group.events.map((event) => Checkbox(h, { key: event, checked: on.includes(event), label: event, onToggle: (checked) => Message.ToggledEvent({ event, on: checked }) })), ), }), ),})Disclosure
One section behind a small button, for settings most people never change.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Disclosure } from "./ui/uicontext/components/Accordion.ts"import { FormField, Input } from "./ui/uicontext/components/FormControls.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ form: { display: "grid", gap: 16, inlineSize: "min(100%, 26rem)" }, more: { display: "grid", gap: 16 } })const Message = UiSchema.TaggedEnum({ ToggledAdvanced: { open: Schema.Boolean } })// a webhook form: the URL is all most people need; the rest waits behind "Advanced options"export const WebhookForm = Html.component({ name: "WebhookForm", model: Schema.Struct({ advanced: Schema.Boolean }), message: Message,}).make({ init: () => ({ advanced: false }), update: { ToggledAdvanced: ($, { open }) => $.evolve({ advanced: open }) }, view: (h, { advanced }) => h.div.attrs(sx(styles.form)).children( FormField(h, { id: "hook-url", label: "Endpoint URL" }, (field) => Input(h).attrs({ ...field, type: "url", placeholder: "https://example.com/hooks/issues" })), Disclosure(h, { title: "Advanced options", open: advanced, onToggle: (open) => Message.ToggledAdvanced({ open }), children: [ h.div.attrs(sx(styles.more)).children( FormField(h, { id: "hook-secret", label: "Signing secret", description: "Sent as X-Signature so you can check each delivery came from us." }, (field) => Input(h).attrs({ ...field, type: "password", autocomplete: "off" })), FormField(h, { id: "hook-retries", label: "Retries", description: "How many times to retry a failed delivery, an hour apart." }, (field) => Input(h).attrs({ ...field, type: "number", min: "0", max: "10", value: "3" })), ), ], }), ),})API reference
AccordionView function
Options
| Name | Type | Default | Description |
|---|---|---|---|
key | string | — | Names the accordion among others in the same view; needed for more than one. |
itemsrequired | AccordionItemData[] | — | — |
openrequired | string[] | — | The values of the open items. The caller keeps them and stores what onToggle asks for. |
multiple | boolean | — | Several items open at once; one at a time by default, so opening one closes the others. |
onTogglerequired | (open: string[]) => Message | — | The values to keep: store them and pass them back as open. |
panelrequired | (item: AccordionItemData) => View.Content | — | What an open item shows. |
headingLevel | 2 | 3 | 4 | 5 | 6 | 3 | The heading level for the titles, to fit the page's outline; 3 by default. |
boxed | boolean | — | A bordered box around the items; bare rows with dividers by default. |
style | Style | — | StyleX styles applied after the accordion's own. |
DisclosureView function
Options
| Name | Type | Description |
|---|---|---|
key | string | Names the disclosure among others in the same view; needed for more than one. |
titlerequired | string | The button's words: "Advanced options", "Show 3 earlier steps". |
openrequired | boolean | Whether it's open. The caller keeps it and stores what onToggle asks for. |
onTogglerequired | (open: boolean) => Message | — |
disabled | boolean | — |
childrenrequired | View.Children | What it shows when open. |
style | Style | StyleX styles applied after the disclosure's own. |