Files
temetro/.agents/skills/coss/references/primitives/switch.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 Switch

When to use

  • Binary preference toggles in settings flows.
  • Immediate on/off state controls with explicit labels.

When NOT to use

  • If the control is a pressable command (not a preference) -> use Toggle instead.
  • If you need grouped toggle selection -> use ToggleGroup instead.
  • If it's a form agreement (terms/conditions) -> use Checkbox instead.

Install

npx shadcn@latest add @coss/switch

Manual deps from docs:

npm install @base-ui/react

Canonical imports

import { Switch } from "@/components/ui/switch"

Minimal pattern

<Label>
  <Switch />
  Enable notifications
</Label>

Patterns from coss particles

Key patterns

Switch with description text (use id/htmlFor when additional content exists):

const id = useId()

<div className="flex items-center justify-between gap-4">
  <div className="flex flex-col gap-1">
    <Label htmlFor={id}>Marketing emails</Label>
    <p className="text-muted-foreground text-xs">
      Receive updates about new products and features.
    </p>
  </div>
  <Switch id={id} />
</div>

Disabled switch:

<Label>
  <Switch disabled />
  Marketing emails
</Label>

More examples

  • disabled: p-switch-2
  • with description: p-switch-3
  • customizing size: p-switch-6
  • card style: p-switch-4
  • form integration: p-switch-5

Common pitfalls

  • Using switch for multi-option selection that should use radio/toggle-group.
  • Omitting visible label or explicit aria-label for icon-only switch controls.
  • Treating switch as form value without verifying checked-state wiring.

Useful particle references

See p-switch-1 through p-switch-6 for label, disabled, description, card, form, and size patterns.