Files
temetro/.agents/skills/coss/references/primitives/toggle.md
T
Khalid Abdi 929bec8f31 feat: AI-added records save with placeholders + "Added by AI" provenance
Stop blocking AI imports/proposals on missing non-critical fields. Records
the chat agent drafts now save with safe placeholders, auto-generated file
numbers, and a source="ai" marker that surfaces an "Added by AI" badge so a
clinician can review/edit them later.

Backend:
- add `source` (manual|ai) column to patients/appointments/prescriptions
  (migration 0014) + canonical types, services, validation schemas
- relax patient/appointment validation: empty file number allowed, demographic
  + type/provider/initials fall back to placeholders (initials derived from name)
- patients.generateFileNumber() auto-assigns an MRN when one is missing
- proposeAppointment accepts a name when no file number resolves; AI commits +
  /api/ai/import stamp source="ai"

Frontend:
- `source` on Appointment/Patient/Prescription types; AI commits send source="ai"
- reusable <AiBadge> shown on the Patients table/detail and prescriptions list

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-14 19:27:17 +03:00

1.7 KiB

coss Toggle

When to use

  • Pressable two-state commands (formatting/tool modes).
  • Single-command active/inactive interactions without group state.

When NOT to use

  • If the control is a binary preference setting -> use Switch instead.
  • If multiple toggles share state -> use ToggleGroup instead.

Install

npx shadcn@latest add @coss/toggle

Manual deps from docs:

npm install @base-ui/react

Canonical imports

import { Toggle } from "@/components/ui/toggle"

Minimal pattern

<Toggle>Toggle</Toggle>

Patterns from coss particles

Key patterns

Icon toggle with aria-label (always required for icon-only):

<Toggle aria-label="Toggle bold" value="bold">
  <BoldIcon />
</Toggle>

ToggleGroup with icon toggles:

<ToggleGroup defaultValue={["bold"]}>
  <Toggle aria-label="Toggle bold" value="bold">
    <BoldIcon />
  </Toggle>
  <Toggle aria-label="Toggle italic" value="italic">
    <ItalicIcon />
  </Toggle>
  <Toggle aria-label="Toggle underline" value="underline">
    <UnderlineIcon />
  </Toggle>
</ToggleGroup>

Variants: default, outline. Sizes: sm, default, lg.

More examples

  • outline: p-toggle-2
  • with icon: p-toggle-3
  • small / large size: p-toggle-4, p-toggle-5
  • disabled: p-toggle-6
  • icon group: p-toggle-7

Common pitfalls

  • Using toggle for destructive/submit actions better represented by Button.
  • Missing pressed-state semantics in controlled toggle flows.
  • Using standalone toggles when mutually exclusive behavior needs ToggleGroup.

Useful particle references

See p-toggle-1 through p-toggle-7 for variants, sizes, and icon group patterns.