Canica

canica/ui

The components pages are built from: shadcn/ui on Radix and Tailwind tokens, and Canica's page patterns (headers, lists, forms, modals, empty and error states).

Functions and values

badgeVariants buttonVariants emailNeedsSignIn installApp whoMayUse confirm prompt describeUploadError MessageInput cn modal

badgeVariants constsrc/ui/components/badge.tsx

const badgeVariants

buttonVariants constsrc/ui/components/button.tsx

const buttonVariants

emailNeedsSignIn functionsrc/ui/canica.tsx

Whether a failure is the person's own email waiting for them to sign in: "sign-in-again" (they signed in before the app kept the sign-in service's proof, e.g. a session carried over from an older version), "not-signed-in" (a guest), or undefined (anything else, or someone else's email: that stays the sender's message).

const emailNeedsSignIn = (error: unknown): "sign-in-again" | "not-signed-in" | undefined => …

installApp functionsrc/ui/canica.tsx

Install the app: the browser's own dialog when it offered one (Chrome, Edge), else the steps for this browser.

const installApp = async (): Promise<void> => …

whoMayUse functionsrc/ui/canica.tsx

Who may use the app, in a sentence: "For people at acme.com.", "Invite only."

const whoMayUse = (gate: AccessScreenProps["gate"]): string => …

confirm functionsrc/ui/canica.tsx

Ask before doing something (like the browser's confirm, styled and accessible). Destructive by default.

const answer = await confirm({ title: "Delete this board?", description: "Cards go too.", confirm: "Delete" })
if (answer._tag === "Done") await remove({ board })
const confirm = ({
  confirm,
  cancel,
  ...rest
}: {
  title: string
  description?: string
  /** Label of the confirm button ("Delete"). */
  confirm?: string
  cancel?: string
  /** Red confirm button (default true). */
  destructive?: boolean
}) => …

prompt functionsrc/ui/canica.tsx

Ask for one value, validated with a field (like the browser's prompt).

const name = await prompt({ title: "New room", label: "Name", field: roomName })
if (name._tag === "Done") await createRoom({ name: name.value })
const prompt = (options: {
  title: string
  description?: string
  label: string
  field: AnyField
  defaultValue?: string
  placeholder?: string
  submit?: string
}) => …

describeUploadError functionsrc/ui/files.tsx

Upload errors in words.

const describeUploadError = (error: UploadError | { readonly _tag: string; readonly message?: string }): string => …

MessageInput functionsrc/ui/inputs.tsx

A one-field composer for chat, comments and quick notes: a multiline text field and a send button, not a form. Enter sends and Shift+Enter starts a new line (on phones Enter is a new line and the button sends). On success it clears and keeps focus; on failure the text stays and the error shows in words. Empty text is never sent.

<MessageInput mutation="post" arg="text" field={messageText} label="Message" hideLabel />
<MessageInput mutation="send" arg="body" args={{ room }} field={messageBody} label="Message" />
<MessageInput onSend={(text) => post({ text })} field={messageText} label="Message" />
function MessageInput<N extends MutationName, A extends MessageArgName<N>>(props: MessageInputProps<N, A>): ReactNode
function MessageInput(props: MessageInputSendProps): ReactNode

cn functionsrc/ui/cn.ts

function cn(...inputs: ClassValue[])

Components

Alert AlertTitle AlertDescription Avatar AvatarImage AvatarFallback AvatarBadge AvatarGroup AvatarGroupCount Badge Button Card CardHeader CardFooter CardTitle CardAction CardDescription CardContent Checkbox Dialog DialogClose DialogContent DialogDescription DialogFooter DialogHeader DialogOverlay DialogPortal DialogTitle DialogTrigger DropdownMenu DropdownMenuPortal DropdownMenuTrigger DropdownMenuContent DropdownMenuGroup DropdownMenuLabel DropdownMenuItem DropdownMenuCheckboxItem DropdownMenuRadioGroup DropdownMenuRadioItem DropdownMenuSeparator DropdownMenuShortcut DropdownMenuSub DropdownMenuSubTrigger DropdownMenuSubContent Empty EmptyHeader EmptyTitle EmptyDescription EmptyContent EmptyMedia Field FieldLabel FieldDescription FieldError FieldGroup FieldLegend FieldSeparator FieldSet FieldContent FieldTitle Input Item ItemMedia ItemContent ItemActions ItemGroup ItemSeparator ItemTitle ItemDescription ItemHeader ItemFooter Label NativeSelect NativeSelectOptGroup NativeSelectOption Select SelectContent SelectGroup SelectItem SelectLabel SelectScrollDownButton SelectScrollUpButton SelectSeparator SelectTrigger SelectValue Separator Skeleton Spinner Table TableHeader TableBody TableFooter TableHead TableRow TableCell TableCaption Textarea AlertDialog AlertDialogAction AlertDialogCancel AlertDialogContent AlertDialogDescription AlertDialogFooter AlertDialogHeader AlertDialogMedia AlertDialogOverlay AlertDialogPortal AlertDialogTitle AlertDialogTrigger Progress RadioGroup RadioGroupItem Form FormField SubmitButton EmptyBlock AppHeader PageContainer PageHeader Section Stat ActionStatus EmailNeedsSignIn CopyButton RepeatInput ChoiceRow Conversation Message List CheckButton Stats ResultBar SignInButtons UserMenu RequireSignIn SignInScreen Loading ErrorState ModalTitle ModalText ModalActions FileInput Thumbnail SearchInput InstallPrompt

Alert componentsrc/ui/components/alert.tsx

function Alert({
  className,
  variant,
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>)

AlertTitle componentsrc/ui/components/alert.tsx

function AlertTitle({ className, ...props }: React.ComponentProps<"div">)

AlertDescription componentsrc/ui/components/alert.tsx

function AlertDescription({
  className,
  ...props
}: React.ComponentProps<"div">)

Avatar componentsrc/ui/components/avatar.tsx

function Avatar({
  className,
  size = "default",
  ...props
}: React.ComponentProps<typeof AvatarPrimitive.Root> & {
  size?: "default" | "sm" | "lg"
})

AvatarImage componentsrc/ui/components/avatar.tsx

function AvatarImage({
  className,
  ...props
}: React.ComponentProps<typeof AvatarPrimitive.Image>)

AvatarFallback componentsrc/ui/components/avatar.tsx

function AvatarFallback({
  className,
  ...props
}: React.ComponentProps<typeof AvatarPrimitive.Fallback>)

AvatarBadge componentsrc/ui/components/avatar.tsx

function AvatarBadge({ className, ...props }: React.ComponentProps<"span">)

AvatarGroup componentsrc/ui/components/avatar.tsx

function AvatarGroup({ className, ...props }: React.ComponentProps<"div">)

AvatarGroupCount componentsrc/ui/components/avatar.tsx

function AvatarGroupCount({
  className,
  ...props
}: React.ComponentProps<"div">)

Badge componentsrc/ui/components/badge.tsx

function Badge({
  className,
  variant = "default",
  asChild = false,
  ...props
}: React.ComponentProps<"span"> &
  VariantProps<typeof badgeVariants> & { asChild?: boolean })

Button componentsrc/ui/components/button.tsx

function Button({
  className,
  variant = "default",
  size = "default",
  asChild = false,
  ...props
}: React.ComponentProps<"button"> &
  VariantProps<typeof buttonVariants> & {
    asChild?: boolean
  })

Card componentsrc/ui/components/card.tsx

function Card({ className, ...props }: React.ComponentProps<"div">)

CardHeader componentsrc/ui/components/card.tsx

function CardHeader({ className, ...props }: React.ComponentProps<"div">)

CardFooter componentsrc/ui/components/card.tsx

function CardFooter({ className, ...props }: React.ComponentProps<"div">)

CardTitle componentsrc/ui/components/card.tsx

function CardTitle({ className, ...props }: React.ComponentProps<"div">)

CardAction componentsrc/ui/components/card.tsx

function CardAction({ className, ...props }: React.ComponentProps<"div">)

CardDescription componentsrc/ui/components/card.tsx

function CardDescription({ className, ...props }: React.ComponentProps<"div">)

CardContent componentsrc/ui/components/card.tsx

function CardContent({ className, ...props }: React.ComponentProps<"div">)

Checkbox componentsrc/ui/components/checkbox.tsx

function Checkbox({
  className,
  ...props
}: React.ComponentProps<typeof CheckboxPrimitive.Root>)

Dialog componentsrc/ui/components/dialog.tsx

function Dialog({
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Root>)

DialogClose componentsrc/ui/components/dialog.tsx

function DialogClose({
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Close>)

DialogContent componentsrc/ui/components/dialog.tsx

function DialogContent({
  className,
  children,
  showCloseButton = true,
  overlayClassName,
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
  showCloseButton?: boolean
  overlayClassName?: string
})

DialogDescription componentsrc/ui/components/dialog.tsx

function DialogDescription({
  className,
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Description>)

DialogFooter componentsrc/ui/components/dialog.tsx

function DialogFooter({
  className,
  showCloseButton = false,
  children,
  ...props
}: React.ComponentProps<"div"> & {
  showCloseButton?: boolean
})

DialogHeader componentsrc/ui/components/dialog.tsx

function DialogHeader({ className, ...props }: React.ComponentProps<"div">)

DialogOverlay componentsrc/ui/components/dialog.tsx

function DialogOverlay({
  className,
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Overlay>)

DialogPortal componentsrc/ui/components/dialog.tsx

function DialogPortal({
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Portal>)

DialogTitle componentsrc/ui/components/dialog.tsx

function DialogTitle({
  className,
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Title>)

DialogTrigger componentsrc/ui/components/dialog.tsx

function DialogTrigger({
  ...props
}: React.ComponentProps<typeof DialogPrimitive.Trigger>)

Empty componentsrc/ui/components/empty.tsx

function Empty({ className, ...props }: React.ComponentProps<"div">)

EmptyHeader componentsrc/ui/components/empty.tsx

function EmptyHeader({ className, ...props }: React.ComponentProps<"div">)

EmptyTitle componentsrc/ui/components/empty.tsx

function EmptyTitle({ className, ...props }: React.ComponentProps<"div">)

EmptyDescription componentsrc/ui/components/empty.tsx

function EmptyDescription({ className, ...props }: React.ComponentProps<"p">)

EmptyContent componentsrc/ui/components/empty.tsx

function EmptyContent({ className, ...props }: React.ComponentProps<"div">)

EmptyMedia componentsrc/ui/components/empty.tsx

function EmptyMedia({
  className,
  variant = "default",
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>)

Field componentsrc/ui/components/field.tsx

function Field({
  className,
  orientation = "vertical",
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>)

FieldLabel componentsrc/ui/components/field.tsx

function FieldLabel({
  className,
  ...props
}: React.ComponentProps<typeof Label>)

FieldDescription componentsrc/ui/components/field.tsx

function FieldDescription({ className, ...props }: React.ComponentProps<"p">)

FieldError componentsrc/ui/components/field.tsx

function FieldError({
  className,
  children,
  errors,
  ...props
}: React.ComponentProps<"div"> & {
  errors?: Array<{ message?: string } | undefined>
})

FieldGroup componentsrc/ui/components/field.tsx

function FieldGroup({ className, ...props }: React.ComponentProps<"div">)

FieldLegend componentsrc/ui/components/field.tsx

function FieldLegend({
  className,
  variant = "legend",
  ...props
}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" })

FieldSeparator componentsrc/ui/components/field.tsx

function FieldSeparator({
  children,
  className,
  ...props
}: React.ComponentProps<"div"> & {
  children?: React.ReactNode
})

FieldSet componentsrc/ui/components/field.tsx

function FieldSet({ className, ...props }: React.ComponentProps<"fieldset">)

FieldContent componentsrc/ui/components/field.tsx

function FieldContent({ className, ...props }: React.ComponentProps<"div">)

FieldTitle componentsrc/ui/components/field.tsx

function FieldTitle({ className, ...props }: React.ComponentProps<"div">)

Input componentsrc/ui/components/input.tsx

function Input({ className, type, ...props }: React.ComponentProps<"input">)

Item componentsrc/ui/components/item.tsx

function Item({
  className,
  variant = "default",
  size = "default",
  asChild = false,
  ...props
}: React.ComponentProps<"div"> &
  VariantProps<typeof itemVariants> & { asChild?: boolean })

ItemMedia componentsrc/ui/components/item.tsx

function ItemMedia({
  className,
  variant = "default",
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof itemMediaVariants>)

ItemContent componentsrc/ui/components/item.tsx

function ItemContent({ className, ...props }: React.ComponentProps<"div">)

ItemActions componentsrc/ui/components/item.tsx

function ItemActions({ className, ...props }: React.ComponentProps<"div">)

ItemGroup componentsrc/ui/components/item.tsx

function ItemGroup({ className, ...props }: React.ComponentProps<"div">)

ItemSeparator componentsrc/ui/components/item.tsx

function ItemSeparator({
  className,
  ...props
}: React.ComponentProps<typeof Separator>)

ItemTitle componentsrc/ui/components/item.tsx

function ItemTitle({ className, ...props }: React.ComponentProps<"div">)

ItemDescription componentsrc/ui/components/item.tsx

function ItemDescription({ className, ...props }: React.ComponentProps<"p">)

ItemHeader componentsrc/ui/components/item.tsx

function ItemHeader({ className, ...props }: React.ComponentProps<"div">)

ItemFooter componentsrc/ui/components/item.tsx

function ItemFooter({ className, ...props }: React.ComponentProps<"div">)

Label componentsrc/ui/components/label.tsx

function Label({
  className,
  ...props
}: React.ComponentProps<typeof LabelPrimitive.Root>)

NativeSelect componentsrc/ui/components/native-select.tsx

function NativeSelect({
  className,
  size = "default",
  ...props
}: Omit<React.ComponentProps<"select">, "size"> & { size?: "sm" | "default" })

NativeSelectOptGroup componentsrc/ui/components/native-select.tsx

function NativeSelectOptGroup({
  className,
  ...props
}: React.ComponentProps<"optgroup">)

NativeSelectOption componentsrc/ui/components/native-select.tsx

function NativeSelectOption({
  className,
  ...props
}: React.ComponentProps<"option">)

Select componentsrc/ui/components/select.tsx

function Select({
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Root>)

SelectContent componentsrc/ui/components/select.tsx

function SelectContent({
  className,
  children,
  position = "item-aligned",
  align = "center",
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Content>)

SelectGroup componentsrc/ui/components/select.tsx

function SelectGroup({
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Group>)

SelectItem componentsrc/ui/components/select.tsx

function SelectItem({
  className,
  children,
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Item>)

SelectLabel componentsrc/ui/components/select.tsx

function SelectLabel({
  className,
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Label>)

SelectScrollDownButton componentsrc/ui/components/select.tsx

function SelectScrollDownButton({
  className,
  ...props
}: React.ComponentProps<typeof SelectPrimitive.ScrollDownButton>)

SelectScrollUpButton componentsrc/ui/components/select.tsx

function SelectScrollUpButton({
  className,
  ...props
}: React.ComponentProps<typeof SelectPrimitive.ScrollUpButton>)

SelectSeparator componentsrc/ui/components/select.tsx

function SelectSeparator({
  className,
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Separator>)

SelectTrigger componentsrc/ui/components/select.tsx

function SelectTrigger({
  className,
  size = "default",
  children,
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Trigger> & {
  size?: "sm" | "default"
})

SelectValue componentsrc/ui/components/select.tsx

function SelectValue({
  ...props
}: React.ComponentProps<typeof SelectPrimitive.Value>)

Separator componentsrc/ui/components/separator.tsx

function Separator({
  className,
  orientation = "horizontal",
  decorative = true,
  ...props
}: React.ComponentProps<typeof SeparatorPrimitive.Root>)

Skeleton componentsrc/ui/components/skeleton.tsx

function Skeleton({ className, ...props }: React.ComponentProps<"div">)

Spinner componentsrc/ui/components/spinner.tsx

function Spinner({ className, ...props }: React.ComponentProps<"svg">)

Table componentsrc/ui/components/table.tsx

function Table({ className, ...props }: React.ComponentProps<"table">)

TableHeader componentsrc/ui/components/table.tsx

function TableHeader({ className, ...props }: React.ComponentProps<"thead">)

TableBody componentsrc/ui/components/table.tsx

function TableBody({ className, ...props }: React.ComponentProps<"tbody">)

TableFooter componentsrc/ui/components/table.tsx

function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">)

TableHead componentsrc/ui/components/table.tsx

function TableHead({ className, ...props }: React.ComponentProps<"th">)

TableRow componentsrc/ui/components/table.tsx

function TableRow({ className, ...props }: React.ComponentProps<"tr">)

TableCell componentsrc/ui/components/table.tsx

function TableCell({ className, ...props }: React.ComponentProps<"td">)

TableCaption componentsrc/ui/components/table.tsx

function TableCaption({
  className,
  ...props
}: React.ComponentProps<"caption">)

Textarea componentsrc/ui/components/textarea.tsx

function Textarea({ className, ...props }: React.ComponentProps<"textarea">)

AlertDialog componentsrc/ui/components/alert-dialog.tsx

function AlertDialog({
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Root>)

AlertDialogAction componentsrc/ui/components/alert-dialog.tsx

function AlertDialogAction({
  className,
  variant = "default",
  size = "default",
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Action> &
  Pick<React.ComponentProps<typeof Button>, "variant" | "size">)

AlertDialogCancel componentsrc/ui/components/alert-dialog.tsx

function AlertDialogCancel({
  className,
  variant = "outline",
  size = "default",
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> &
  Pick<React.ComponentProps<typeof Button>, "variant" | "size">)

AlertDialogContent componentsrc/ui/components/alert-dialog.tsx

function AlertDialogContent({
  className,
  size = "default",
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
  size?: "default" | "sm"
})

AlertDialogDescription componentsrc/ui/components/alert-dialog.tsx

function AlertDialogDescription({
  className,
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>)

AlertDialogFooter componentsrc/ui/components/alert-dialog.tsx

function AlertDialogFooter({
  className,
  ...props
}: React.ComponentProps<"div">)

AlertDialogHeader componentsrc/ui/components/alert-dialog.tsx

function AlertDialogHeader({
  className,
  ...props
}: React.ComponentProps<"div">)

AlertDialogMedia componentsrc/ui/components/alert-dialog.tsx

function AlertDialogMedia({
  className,
  ...props
}: React.ComponentProps<"div">)

AlertDialogOverlay componentsrc/ui/components/alert-dialog.tsx

function AlertDialogOverlay({
  className,
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>)

AlertDialogPortal componentsrc/ui/components/alert-dialog.tsx

function AlertDialogPortal({
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Portal>)

AlertDialogTitle componentsrc/ui/components/alert-dialog.tsx

function AlertDialogTitle({
  className,
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>)

AlertDialogTrigger componentsrc/ui/components/alert-dialog.tsx

function AlertDialogTrigger({
  ...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>)

Progress componentsrc/ui/components/progress.tsx

function Progress({
  className,
  value,
  ...props
}: React.ComponentProps<typeof ProgressPrimitive.Root>)

RadioGroup componentsrc/ui/components/radio-group.tsx

function RadioGroup({
  className,
  ...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Root>)

RadioGroupItem componentsrc/ui/components/radio-group.tsx

function RadioGroupItem({
  className,
  ...props
}: React.ComponentProps<typeof RadioGroupPrimitive.Item>)

Form componentsrc/ui/canica.tsx

A native form wired to useForm: submits through it, and shows the non-field error (form.error) above the submit button unless you render it yourself.

<Form form={form}>
  <FormField form={form} name="title" label="Title"><Input name="title" /></FormField>
  <SubmitButton form={form}>Save</SubmitButton>
</Form>
function Form<V, R>({
  form,
  children,
  className,
  errors = "auto",
  describeError = errorText,
}: {
  readonly form: FormState<V, R>
  readonly children?: ReactNode
  readonly className?: string
  /** "auto" shows `form.error` in an Alert at the end; "manual" leaves it to you. */
  readonly errors?: "auto" | "manual"
  /** Turn a typed failure into text, e.g. `(e) => e._tag === "NameTaken" ? "That name is taken" : undefined`. */
  readonly describeError?: (error: NonNullable<FormState<V, R>["error"]>) => string | undefined
})

FormField componentsrc/ui/canica.tsx

Label + control + the field's error from useForm (client or server validation). The control with name={name} inside gets a unique id automatically, so labels work even when the same form is repeated (e.g. one per column).

function FormField({
  form,
  name,
  label,
  description,
  children,
  className,
  orientation,
}: {
  readonly form: AnyForm
  readonly name: string
  readonly label?: ReactNode
  readonly description?: ReactNode
  readonly children: ReactNode
  readonly className?: string
  readonly orientation?: "vertical" | "horizontal"
})

SubmitButton componentsrc/ui/canica.tsx

A submit button that disables itself and shows a spinner while the form is submitting.

function SubmitButton({
  form,
  children,
  className,
  variant,
  size,
}: {
  readonly form: AnyForm
  readonly children: ReactNode
  readonly className?: string
  readonly variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link"
  readonly size?: "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg"
})

EmptyBlock componentsrc/ui/canica.tsx

A designed empty or not-found state: title, optional description and next step, in a dashed box.

function EmptyBlock({ title, description, action, className }: EmptyState & { readonly className?: string })

AppHeader componentsrc/ui/canica.tsx

The app's top bar: brand on the left, navigation/actions on the right. Put it in __root.tsx. Its size is the width of the whole app: pages (PageContainer) follow it.

function AppHeader({
  brand,
  children,
  size = "md",
}: {
  readonly brand: ReactNode
  readonly children?: ReactNode
  /** The app's content width: every `PageContainer` uses it, so edges line up on all pages. */
  readonly size?: "sm" | "md" | "lg"
})

PageContainer componentsrc/ui/canica.tsx

The page body (width, padding, rhythm). The starter layout wraps every page in one, so loading and error states are framed too; a page's own PageContainer inside it only adds the vertical rhythm.

function PageContainer({ children, className }: { readonly children: ReactNode; readonly className?: string })

Section componentsrc/ui/canica.tsx

A titled block of a page. Use sections to group content; reserve cards for things that are objects.

function Section({
  title,
  description,
  actions,
  children,
  className,
}: {
  readonly title?: ReactNode
  readonly description?: ReactNode
  readonly actions?: ReactNode
  readonly children: ReactNode
  /** Layout only (grid placement, margin, width). */
  readonly className?: string
})

Stat componentsrc/ui/canica.tsx

A key number with a label, e.g. a balance, a streak or a vote count. Put several in a grid.

function Stat({
  label,
  value,
  hint,
  tone = "default",
  className,
}: {
  readonly label: ReactNode
  readonly value: ReactNode
  readonly hint?: ReactNode
  readonly tone?: "default" | "positive" | "negative"
  readonly className?: string
})

ActionStatus componentsrc/ui/canica.tsx

Inline feedback for a mutation/action: nothing while idle, a spinner while waiting, the error (described by you) on failure. Optional success message.

function ActionStatus<E>({
  status,
  describeError,
  success,
}: {
  readonly status: { readonly _tag: "Idle" | "Waiting" | "Success" } | { readonly _tag: "Failure"; readonly error: E }
  readonly describeError?: (error: E) => string | undefined
  readonly success?: ReactNode
})

EmailNeedsSignIn componentsrc/ui/canica.tsx

"To get emails from Todos, confirm your email by signing in again." and a button that does: the usual sign-in, back to this page (Google remembers the consent: one tap, or none). Emails need the sign-in service's proof that this person signed in here, which only a real sign-in gives. ActionStatus shows it by itself for a send of the person's own email (NotARecipient with self); use it where you show an email's state yourself. reason: "not-signed-in": a guest ("sign in with Google").

function EmailNeedsSignIn({ reason = "sign-in-again", children, className }: { readonly reason?: "sign-in-again" | "not-signed-in"; readonly children?: ReactNode; readonly className?: string })

CopyButton componentsrc/ui/canica.tsx

Copies a value (the current page's URL by default) and says "Copied" for a moment. <CopyButton>Copy invite link</CopyButton>, <CopyButton value={code}>Copy code</CopyButton>.

function CopyButton({
  value,
  children = "Copy link",
  variant = "outline",
  size = "sm",
  className,
}: {
  readonly value?: string
  readonly children?: ReactNode
  readonly variant?: "default" | "outline" | "secondary" | "ghost"
  readonly size?: "default" | "xs" | "sm" | "lg"
  readonly className?: string
})

RepeatInput componentsrc/ui/canica.tsx

Several values for one field (poll options, tags): starts with min inputs, "Add" up to max, remove down to min. All inputs share name, so the form reads an array(…) field (blank ones are dropped). <FormField form={form} name="options" label="Options"><RepeatInput name="options" label="Option" min={2} max={8} /></FormField>

function RepeatInput({
  name,
  label,
  min = 1,
  max = 10,
  defaultValue = [],
  placeholder,
  addLabel,
}: {
  readonly name: string
  /** One item's name, for "Add option" and accessible labels ("Option 2"). */
  readonly label: string
  readonly min?: number
  readonly max?: number
  readonly defaultValue?: ReadonlyArray<string>
  readonly placeholder?: string
  readonly addLabel?: string
})

ChoiceRow componentsrc/ui/canica.tsx

A selectable row: a radio or checkbox with its label and optional details, the whole row clickable.

<RadioGroup name="option" className="gap-2">
  {options.map((o) => (
    <ChoiceRow key={o.id} control={<RadioGroupItem value={o.id} />} trailing={`${o.pct}%`}>{o.label}</ChoiceRow>
  ))}
</RadioGroup>
function ChoiceRow({
  control,
  children,
  description,
  trailing,
  share,
  highlight,
}: {
  /** `<RadioGroupItem value=… />` or `<Checkbox name=… value=… />`. */
  readonly control: ReactNode
  readonly children: ReactNode
  readonly description?: ReactNode
  /** Shown at the end of the row (a count, a percentage). */
  readonly trailing?: ReactNode
  /** 0–1: draws the result as a bar behind the row (vote and results in one place). */
  readonly share?: number
  /** The leading or the viewer's own choice: a stronger bar. */
  readonly highlight?: boolean
})

Conversation componentsrc/ui/canica.tsx

A chat-like conversation: messages in a scroll area that stays at the newest message (bottom), with the composer pinned under it. Put <Message> rows inside, oldest first.

function Conversation({
  children,
  composer,
  empty,
  className,
}: {
  /** Layout only (e.g. `flex-1` to fill a full-height page). */
  readonly className?: string
  readonly children?: ReactNode
  /** The send form (pinned at the bottom). */
  readonly composer?: ReactNode
  /** Shown when there are no messages. */
  readonly empty?: ReactNode
})

Message componentsrc/ui/canica.tsx

One message in a Conversation: author, time, text. mine highlights your own; actions (e.g. delete) are muted until hover/focus (always visible: touch screens have no hover); continued hides the author line for consecutive messages from the same person. Pass at (epoch ms) to show the time ("10:42", "Yesterday 10:42") with the full date on hover.

function Message({
  author,
  time,
  at,
  children,
  mine = false,
  continued = false,
  actions,
}: {
  readonly author: ReactNode
  readonly time?: ReactNode
  readonly at?: number
  readonly children: ReactNode
  readonly mine?: boolean
  readonly continued?: boolean
  readonly actions?: ReactNode
})

List componentsrc/ui/canica.tsx

A list of rows in one bordered group with dividers (the Linear/GitHub look), instead of a stack of separate cards. Put Items inside (no variant="outline" needed); a row that opens something is <Item asChild><Link…>.

function List({ children, className }: { readonly children: ReactNode; readonly className?: string })

CheckButton componentsrc/ui/canica.tsx

A large done / not-done toggle for the main action of a row (check in a habit, complete a task). Bigger and clearer than a checkbox; pressed is the current state, onClick flips it. <CheckButton pressed={done} onClick={() => toggle({ habit, day: today })} label={Done: ${habit.name}} />

function CheckButton({
  pressed,
  onClick,
  label,
  disabled,
  children,
}: {
  readonly pressed: boolean
  readonly onClick: () => unknown
  /** Accessible name, e.g. "Mark Morning run done". */
  readonly label: string
  readonly disabled?: boolean
  /** Optional visible text next to the check ("Done"). */
  readonly children?: ReactNode
})

Stats componentsrc/ui/canica.tsx

Key numbers side by side: 2 per row, 4 when the container is wide enough. <Stats><Stat …/><Stat …/></Stats>

function Stats({ children }: { readonly children: ReactNode })

ResultBar componentsrc/ui/canica.tsx

A labelled result bar: label, a bar proportional to value / total, and the count with its percentage. For poll results, budgets, progress per member. highlight marks the leading or chosen row. <ResultBar label="Tacos" value={12} total={30} highlight /> → "Tacos ████░░ 12 · 40%"

function ResultBar({
  label,
  value,
  total,
  highlight = false,
  detail,
}: {
  readonly label: ReactNode
  readonly value: number
  readonly total: number
  readonly highlight?: boolean
  /** Replaces the default "12 · 40%" text. */
  readonly detail?: ReactNode
})

SignInButtons componentsrc/ui/canica.tsx

"Sign in with Google", the same on the dev server as deployed (<SignInButtons />, used by RequireSignIn). Tests and scripts sign in test users without it (t.as(name), the dev server's POST /_canica/dev/test-sign-in).

function SignInButtons()

UserMenu componentsrc/ui/canica.tsx

function UserMenu()

RequireSignIn componentsrc/ui/canica.tsx

Shows children only to signed-in users; guests see a sign-in prompt instead. For pages or sections whose queries use requireSignIn on the server.

function RequireSignIn({
  children,
  title = "Sign in to continue",
  description = "This part of the app needs an account.",
}: {
  readonly children: ReactNode
  readonly title?: ReactNode
  readonly description?: ReactNode
})

SignInScreen componentsrc/ui/canica.tsx

The screen shown for auth: "signedIn" pages and layouts (public apps): a centered sign-in card.

function SignInScreen({
  title = "Sign in to continue",
  description = "You need an account for this page. Your guest data comes with you.",
}: {
  readonly title?: ReactNode
  readonly description?: ReactNode
})

Loading componentsrc/ui/canica.tsx

The loading placeholder for match's loading: shape it like what replaces it.

function Loading({ shape = "cards" }: { readonly shape?: "cards" | "list" | "grid" | "text" })

ErrorState componentsrc/ui/canica.tsx

The default view of a failed query for match's failure: "Not found" (with a way home) for NotFound, a sign-in prompt for Unauthenticated, a readable alert otherwise. Handle your own errors before it: failure: (e) => (e._tag === "NotMember" ? <JoinPrompt /> : <ErrorState error={e} />).

function ErrorState<E>({
  error,
  states,
}: {
  readonly error: E
  /** A designed state per error: `states={{ NotFound: { title: "No such room", action: … }, NotMember: { … } }}`. */
  readonly states?: { readonly [K in E extends { readonly _tag: infer T extends string } ? T : never]?: EmptyState }
})

ModalTitle componentsrc/ui/canica.tsx

The modal's title (its accessible name; on phones, the sheet's header, which stays put while the body scrolls). Optional.

function ModalTitle({ children }: { readonly children: ReactNode })

ModalText componentsrc/ui/canica.tsx

A line of explanation under the title.

function ModalText({ children }: { readonly children: ReactNode })

ModalActions componentsrc/ui/canica.tsx

The buttons row at the end of a modal: secondary actions first, the primary last.

function ModalActions({ children }: { readonly children: ReactNode })

FileInput componentsrc/ui/files.tsx

Pick or drop a file; it is uploaded at once (with a progress bar), then onUpload(id, file) stores it, usually with a mutation: onUpload={(image) => setImage({ id: todo.id, image })}. A failure (the upload's or the mutation's, when onUpload returns its result) is shown under it.

<FileInput label="Image" accept="image/*" description="PNG, JPEG or WebP, up to 25 MB" onUpload={(image) => setImage({ id, image })} />
function FileInput({
  label,
  description,
  accept,
  onUpload,
  disabled,
  className,
  children,
}: {
  /** What the file is for ("Image", "Attachment"): the control's accessible name. */
  readonly label: ReactNode
  readonly description?: ReactNode
  /** Like `<input accept>`: `"image/*"`, `".pdf,application/pdf"`. Checked before uploading. */
  readonly accept?: string
  /** Store the id. Return the mutation's result to show its failure here. */
  readonly onUpload: (id: FileId, file: File) => unknown
  readonly disabled?: boolean
  readonly className?: string
  /** What the drop zone says (default: "Choose a file or drop it here"). */
  readonly children?: ReactNode
})

Thumbnail componentsrc/ui/files.tsx

A file link from a query shown as an image: square, cropped to fit. alt says what it shows ("" if decorative). It asks for the image at twice its size (snapped to 160/320/640/1280 px, at most what the link grants), so a list of thumbnails downloads a few KB each, not the originals: sm 40 px (160 px image), md 64 (160), lg 160 (320), xl up to 320 px wide, the container's width on narrow screens (640). With width/height set, the page does not jump when it loads.

function Thumbnail({
  src,
  alt,
  size = "md",
  className,
}: {
  readonly src: string
  readonly alt: string
  readonly size?: keyof typeof THUMBNAIL_PX
  readonly className?: string
})

SearchInput componentsrc/ui/inputs.tsx

Filter the page: the text lives in the URL (?q=milk), so a filtered view can be shared, reloaded and gone back to. The page declares the param (page({ search: { q: string().trim().optional() } })) and reads search.q to filter its query. Typing updates the URL after a short pause (no history entry per letter); the ✕ button and Escape clear it. It submits nothing.

<SearchInput param="q" label="Search todos" />
function SearchInput({
  param,
  label,
  placeholder,
  debounce = 300,
  className,
}: {
  /** The search param it writes, declared in the page's `search`. */
  readonly param: SearchParamName
  /** What it searches ("Search todos"): its accessible name, and the placeholder unless you give one. */
  readonly label: string
  readonly placeholder?: string
  /** How long typing waits before updating the URL, in ms (default 300). */
  readonly debounce?: number
  /** Layout only (e.g. `max-w-sm`). */
  readonly className?: string
})

InstallPrompt componentsrc/ui/install.tsx

function InstallPrompt({ hidden }: InstallPromptProps)

Types

EmptyState MessageInputProps MessageInputSendProps MessageArgName ModalResult

EmptyState interfacesrc/ui/canica.tsx

interface EmptyState {
  readonly title: ReactNode
  readonly description?: ReactNode
  /** The next step, e.g. a Button or a Link styled as a button. */
  readonly action?: ReactNode
}

MessageInputProps typesrc/ui/inputs.tsx

type MessageInputProps<N extends MutationName, A extends MessageArgName<N>> = MessageInputCommon & {
  /** The mutation that receives the text, by name (as `useMutation`). */
  readonly mutation: N
  /** Which of its args is the text. */
  readonly arg: A
  /** Turn a typed failure into words: `(e) => e._tag === "RoomClosed" ? "This room is closed." : undefined`. */
  readonly describeError?: (error: MutationError<N>) => string | undefined
} & FixedArgs<N, A>

MessageInputSendProps typesrc/ui/inputs.tsx

type MessageInputSendProps = MessageInputCommon & {
  /** Send the text yourself; return the mutation's result so a failure shows here and the text stays. */
  readonly onSend: (text: string) => Promise<MutationResult<unknown, unknown>> | MutationResult<unknown, unknown> | Promise<void> | void
  readonly describeError?: (error: any) => string | undefined
}

MessageArgName typesrc/ui/inputs.tsx

The args of mutation N that are a plain string: the one MessageInput fills.

type MessageArgName<N extends MutationName> = {
  [K in keyof MutationArgs<N> & string]-?: [NonNullable<MutationArgs<N>[K]>] extends [string]
    ? string extends NonNullable<MutationArgs<N>[K]>
      ? K
      : never
    : never
}[keyof MutationArgs<N> & string]

ModalResult typesrc/client/modal.tsx

How a modal ended: the value it was closed with, or cancelled (Escape, outside click, swipe, back, navigation).

type ModalResult<A> = (
  | { readonly _tag: "Done"; readonly value: A }
  | { readonly _tag: "Cancelled"; readonly reason: CancelReason }
) & {
  match<R>(cases: ModalCases<A, R>): R
}