# COSS for Svelte **COSS for Svelte** is an unofficial Svelte 5 port of COSS UI. It uses Shards UI for headless behavior, Tailwind CSS for styling, and the shadcn-svelte CLI for registry installation. Unofficial Svelte port made by Miel: https://github.com/mielsense ## Overview - [Introduction](https://coss-sv.vercel.app/docs/index.md): A modern Svelte 5 component library built on Shards UI. Built for developers and AI. - [Get Started](https://coss-sv.vercel.app/docs/get-started.md): A quick guide to adding your first Svelte component. - [Styling](https://coss-sv.vercel.app/docs/styling.md): Configure COSS color, radius, typography, and overlay tokens with Tailwind CSS v4. - [Migrating from shadcn-svelte and Bits UI](https://coss-sv.vercel.app/docs/radix-migration.md): Move an existing Svelte component set to the Shards-backed COSS for Svelte wrappers. - [Agent Skill](https://coss-sv.vercel.app/docs/skills.md): Teach coding agents how to install, compose, and debug COSS for Svelte components. - [Changelog](https://coss-sv.vercel.app/docs/changelog.md): Breaking changes, migration guides, and notable updates. - [Roadmap](https://coss-sv.vercel.app/docs/roadmap.md): Current state of coss ui and where we’re headed next. ## Components - [Accordion](https://coss-sv.vercel.app/docs/components/accordion.md): A set of collapsible panels with headings and content. - [Alert](https://coss-sv.vercel.app/docs/components/alert.md): A callout for displaying important information. - [Alert Dialog](https://coss-sv.vercel.app/docs/components/alert-dialog.md): A dialog that requires user response to proceed. - [Autocomplete](https://coss-sv.vercel.app/docs/components/autocomplete.md): An input that suggests options as you type. - [Avatar](https://coss-sv.vercel.app/docs/components/avatar.md): An image element with a fallback for representing the user. - [Badge](https://coss-sv.vercel.app/docs/components/badge.md): A badge or a component that looks like a badge. - [Breadcrumb](https://coss-sv.vercel.app/docs/components/breadcrumb.md): Displays the path to the current resource using a hierarchy of links. - [Button](https://coss-sv.vercel.app/docs/components/button.md): A button or a component that looks like a button. - [Calendar](https://coss-sv.vercel.app/docs/components/calendar.md): A date picker component with range and multi-select support. - [Card](https://coss-sv.vercel.app/docs/components/card.md): A content container for grouping related information. - [Checkbox](https://coss-sv.vercel.app/docs/components/checkbox.md): A control allowing the user to toggle between checked and not checked. - [Checkbox Group](https://coss-sv.vercel.app/docs/components/checkbox-group.md): Provides shared state to a series of checkboxes. - [Collapsible](https://coss-sv.vercel.app/docs/components/collapsible.md): A collapsible panel controlled by a button trigger. - [Combobox](https://coss-sv.vercel.app/docs/components/combobox.md): An input combined with a list of predefined items to select. - [Command](https://coss-sv.vercel.app/docs/components/command.md): A command palette component built with Dialog and Autocomplete for searching and executing commands. - [Context Menu](https://coss-sv.vercel.app/docs/components/context-menu.md): A menu that appears at the pointer on right click or long press. - [Date Picker](https://coss-sv.vercel.app/docs/components/date-picker.md): A date picker component built with Calendar and Popover. - [Dialog](https://coss-sv.vercel.app/docs/components/dialog.md): A popup that opens on top of the entire page. - [Drawer](https://coss-sv.vercel.app/docs/components/drawer.md): A panel that slides in from the edge of the screen with swipe gestures, snap points, and nested drawer support. - [Empty](https://coss-sv.vercel.app/docs/components/empty.md): A container for displaying empty state information. - [Field](https://coss-sv.vercel.app/docs/components/field.md): A component that provides labelling and validation for form controls. - [Fieldset](https://coss-sv.vercel.app/docs/components/fieldset.md): A native fieldset element with a legend. - [Form](https://coss-sv.vercel.app/docs/components/form.md): A form wrapper component that simplifies validation and submission. - [Frame](https://coss-sv.vercel.app/docs/components/frame.md): A framed container for grouping related information. - [Group](https://coss-sv.vercel.app/docs/components/group.md): A component for visually grouping a series of controls. - [Input](https://coss-sv.vercel.app/docs/components/input.md): A native input element. - [Input Group](https://coss-sv.vercel.app/docs/components/input-group.md): A flexible component for grouping inputs with addons, buttons, and other elements. - [Kbd](https://coss-sv.vercel.app/docs/components/kbd.md): A component for displaying keyboard keys and shortcuts. - [Label](https://coss-sv.vercel.app/docs/components/label.md): Renders an accessible label associated with controls. - [Menu](https://coss-sv.vercel.app/docs/components/menu.md): A list of actions in a dropdown, enhanced with keyboard navigation. - [Meter](https://coss-sv.vercel.app/docs/components/meter.md): A graphical display of a numeric value within a range. - [Number Field](https://coss-sv.vercel.app/docs/components/number-field.md): A numeric input element with increment and decrement buttons, and a scrub area. - [OTP Field](https://coss-sv.vercel.app/docs/components/otp-field.md): A segmented input for one-time passwords and verification codes. - [Pagination](https://coss-sv.vercel.app/docs/components/pagination.md): A pagination with page navigation, next and previous links. - [Popover](https://coss-sv.vercel.app/docs/components/popover.md): An accessible popup anchored to a button. - [Preview Card](https://coss-sv.vercel.app/docs/components/preview-card.md): A popup that appears when a link is hovered, showing a preview for sighted users. - [Progress](https://coss-sv.vercel.app/docs/components/progress.md): Displays the status of a task that takes a long time. - [Radio Group](https://coss-sv.vercel.app/docs/components/radio-group.md): A set of checkable buttons where no more than one of the buttons can be checked at a time. - [Scroll Area](https://coss-sv.vercel.app/docs/components/scroll-area.md): A native scroll container with custom scrollbars. - [Select](https://coss-sv.vercel.app/docs/components/select.md): A common form component for choosing a predefined value in a dropdown menu. - [Segmented Control](https://coss-sv.vercel.app/docs/components/segmented-control.md): A visual pattern for presenting related choices, navigation destinations, filters, or content views. - [Separator](https://coss-sv.vercel.app/docs/components/separator.md): A separator element accessible to screen readers. - [Sheet](https://coss-sv.vercel.app/docs/components/sheet.md): A flyout that opens from the side of the screen, based on the dialog component. - [Skeleton](https://coss-sv.vercel.app/docs/components/skeleton.md): A loading state skeleton for your components. - [Slider](https://coss-sv.vercel.app/docs/components/slider.md): An input where the user selects a value from within a given range. - [Spinner](https://coss-sv.vercel.app/docs/components/spinner.md): An indicator that can be used to show a loading state. - [Switch](https://coss-sv.vercel.app/docs/components/switch.md): A control that indicates whether a setting is on or off. - [Table](https://coss-sv.vercel.app/docs/components/table.md): A simple table component for displaying tabular data. - [Tabs](https://coss-sv.vercel.app/docs/components/tabs.md): A component for toggling between related panels on the same page. - [Textarea](https://coss-sv.vercel.app/docs/components/textarea.md): A native textarea element. - [Toast](https://coss-sv.vercel.app/docs/components/toast.md): A temporary notification that appears on screen to inform users. - [Toggle](https://coss-sv.vercel.app/docs/components/toggle.md): A two-state button that can be toggled on or off. - [Toggle Group](https://coss-sv.vercel.app/docs/components/toggle-group.md): Provides a shared state to a series of toggle buttons. - [Toolbar](https://coss-sv.vercel.app/docs/components/toolbar.md): A container for grouping a set of buttons and controls. - [Tooltip](https://coss-sv.vercel.app/docs/components/tooltip.md): A popup that appears when an element is hovered or focused, showing a hint for sighted users. ## Svelte patterns - [useMediaQuery](https://coss-sv.vercel.app/docs/hooks/use-media-query.md): Reactive media query helper with Tailwind-like syntax. - [useCopyToClipboard](https://coss-sv.vercel.app/docs/hooks/use-copy-to-clipboard.md): Copy text to the clipboard with temporary copied feedback. --- # Full documentation ## Document: Introduction # Introduction > A modern Svelte 5 component library built on Shards UI. Built for developers and AI. [Canonical documentation](https://coss-sv.vercel.app/docs) **COSS for Svelte** is a collection of beautifully designed, accessible, and composable components for Svelte 5 applications. Built on top of [Shards UI](https://shardsui.com) and styled with [Tailwind CSS](https://tailwindcss.com), it is designed for you to copy, paste, and own. We think Shards UI is the right behavioral foundation for this port. We take its unstyled Svelte primitives and apply the COSS design system, examples, states, and interaction details. The original [COSS UI](https://coss.com/ui) is the component library being progressively adopted by [Cal.com](https://cal.com). This independent port brings that library to Svelte without changing the visual design. COSS for Svelte is in active development. Components, documentation, and registry items are being reviewed against the pinned COSS reference, and Shards UI may still introduce API changes. Use it in projects where you are comfortable adapting to changes before the first stable release. ## How It Works Our approach is simple: you should own your code. We follow the copy-paste ethos of **shadcn-svelte**. Instead of installing an opaque component package, you get the source code. This means: - **No abstractions:** You have full control over how components look and behave. - **Endless customization:** Need to change something? Edit the generated file. - **Learn by doing:** See how components are built and adapt them to your needs. ## Built on Shards UI, Designed for Production COSS for Svelte is built on **Shards UI** from the ground up. Shards supplies accessible, unopinionated primitives that handle keyboard navigation, focus management, selection, overlays, and positioning without imposing a visual design. This port is not a restyled shadcn-svelte component set. It is a **coherent, opinionated UI system that follows the pinned COSS reference**, including: - **Production-tested patterns** from real applications - **Extended component variants** for common use cases - **Thoughtful defaults** optimized for modern, dense interfaces - **A consistent design system** across every component If you are migrating from shadcn-svelte or direct Bits UI components, read the [migration guide](/docs/radix-migration). ## Primitives, Particles and Atoms At the core of COSS are the **UI primitives**: accessible building blocks whose behavior is powered by Shards UI and whose visible design comes from COSS. On top of these primitives are [particles](/particles). Particles are **pre-assembled components**, such as authentication forms, tables, or date pickers, that combine several primitives into ready-to-use solutions. They are more opinionated, but remain easy to customize or break apart. The original COSS ecosystem also includes [atoms](https://cal.com/atoms). Atoms are **API-enhanced particles** that connect interface patterns to external data and services. Atoms are not part of this Svelte component-library port. Together, the layers form a spectrum: - **Primitives** → the foundation - **Particles** → the patterns - **Atoms** → the integrations This lets you choose the right level of abstraction: a bare component, a polished interface pattern, or an API-connected solution. ## Built for Humans and AI The source is written to be clear, readable, and predictable, so people and language models can understand, reason about, and modify it. Each documentation page also has a plain-text Markdown route. ## Open Source, Made Sustainable This port preserves the open-source intent of COSS. It adapts only the MIT-designated `reference/apps/ui` source boundary, records the pinned upstream revision, and keeps the attribution visible. See [Credits](/credits) for the exact provenance and license links. COSS for Svelte is an independent project and is not endorsed by COSS, Cal.com, or their contributors. ## Get Involved Bug reports, accessibility findings, component mismatches, and documentation fixes are welcome. A useful report names the component or particle, includes the viewport and theme, and links to the matching COSS reference example. --- ## Document: Get Started # Get Started > A quick guide to adding your first Svelte component. [Canonical documentation](https://coss-sv.vercel.app/docs/get-started) This guide provides the essentials for adding **COSS for Svelte** components to your Svelte 5 application. ## Prerequisites Our components are built with [Tailwind CSS v4](https://tailwindcss.com). Before you begin, make sure you have a Svelte 5 project set up with Tailwind CSS and pnpm. ## Adding components You can add components **automatically with the shadcn-svelte CLI** or **manually by copying the files**. Both methods work for primitives and particles. ### With the CLI Each component page provides a command to add it to your project automatically. The CLI creates the necessary files and installs the dependencies declared by that registry item. ### New project setup For a new project, initialize shadcn-svelte first: ```bash pnpm dlx shadcn-svelte@latest init ``` Review the aliases selected by the initializer. Registry files use those aliases when the CLI writes imports into your project. Then add the component from the exact registry URL shown on its page: ```bash pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/button.json ``` Unlike the upstream React registry, this Svelte port does not publish an aggregate style preset yet. Add the global theme from the [Styling](/docs/styling) guide once, then install the component files you need. ### Existing projects To add components to an existing project, pass each registry URL to the shadcn-svelte CLI: ```bash pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/button.json https://coss-sv.vercel.app/r/card.json ``` The CLI can install several registry items in one command: ```bash pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/avatar.json https://coss-sv.vercel.app/r/dialog.json https://coss-sv.vercel.app/r/tabs.json ``` See the [Styling](/docs/styling) guide for the color tokens, sidebar variables, and base styles. ### Manual installation 1. **Find a component** on the [Components](/docs) or [Particles](/particles) pages. 2. **Copy the code** from the **Code** tab. 3. **Create the matching `.svelte` and `.ts` files** in your project and keep their relative paths. 4. **Install every dependency** listed by the registry item with pnpm. 5. **Import and use** the component in your app. ## Styling Components use the design token system from **COSS UI** and Cal.com. CSS variables define the tokens, and Tailwind CSS consumes them. The variables are compatible with shadcn-svelte and fully customizable. Change them in your global stylesheet, usually `src/app.css`, to match your design system. COSS introduces a few additional tokens for more granular control: - `--destructive-foreground`: destructive-outline buttons, destructive menu items, badges, and field errors - `--info` and `--info-foreground`: info badges, toast types, and alerts - `--success` and `--success-foreground`: success badges, toast types, and alerts - `--warning` and `--warning-foreground`: warning badges, toast types, and alerts **Important:** the component registry items do not replace your global stylesheet. Add these tokens from the [Styling](/docs/styling) guide when setting up the port. ## Fonts COSS components use three CSS custom properties for typography: - `--font-sans` controls body text, buttons, labels, and most UI elements. - `--font-mono` controls code blocks, ``, and monospace text. - `--font-heading` controls Dialog, Alert Dialog, Sheet, Card, and Empty titles. COSS UI uses Inter and Geist Mono in its default style preset. The reference website uses Cal Sans 2.0 for body and headings. This port keeps the same variable contract without forcing a font package. ### Custom fonts Define the variables in your global stylesheet. When sans and heading share one family, alias `--font-heading` to `--font-sans`: ```css :root { --font-sans: "Inter Variable", sans-serif; --font-heading: var(--font-sans); --font-mono: "Geist Mono Variable", monospace; } ``` For a separate heading family, assign it directly: ```css :root { --font-heading: "Cal Sans", sans-serif; } ``` If fonts appear broken after setup, check that the custom properties use the exact names above and that the font files load before the component stylesheet. ## Primitive exports Components that wrap Shards UI re-export the underlying primitive namespace. Use the styled COSS parts when the defaults work, or the primitive when you need a different composition. ```svelte ``` For direct primitive access, import the explicit `SliderPrimitive` export from the same module. An application that already owns the generated COSS files does not need a second direct Shards import. ## Shards UI re-exports Behavioral component directories expose their Shards namespace as an explicit `*Primitive` export, such as `DialogPrimitive`, `MenuPrimitive`, and `SelectPrimitive`. This is useful in a monorepo: apps can compose against the generated COSS module while keeping the Shards version in one place. ## Migration from shadcn-svelte and Bits UI For developers migrating from **shadcn-svelte** or direct **Bits UI** components, the [migration guide](/docs/radix-migration) translates the equivalent component structures to COSS for Svelte and Shards UI. It covers namespace imports, trigger composition, bindings, item data, and callback contracts. ## Working with coding agents The documentation gives coding agents the component structure and local rules they need to make changes. It includes: - An installable [Agent Skill](/docs/skills) with the component catalog, Svelte conventions, and registry workflow used by this port. - An [llms.txt](/llms.txt) file that maps the documentation and component structure for an agent. - A **Copy Markdown** button on every guide in this lane for sharing exact page content with a coding agent. --- ## Document: Styling # Styling > Configure COSS color, radius, typography, and overlay tokens with Tailwind CSS v4. [Canonical documentation](https://coss-sv.vercel.app/docs/styling) ## Overview This library is optimized for specific semantic color tokens that provide crisp, contrasted borders and visual depth. The styling system builds on [shadcn-svelte's CSS-variable approach](https://www.shadcn-svelte.com/docs/theming) for consistency and maintainability. Components use translucent borders instead of solid colors. Those borders mix with small bottom shadows to stay crisp even when the background lacks contrast. The color system is optional, but it provides the intended visual result. Conventional tokens may produce borders and shadows with different contrast. The Svelte orange `#ff3e00` belongs to this documentation site's navigation and links. It is not a component token. Installed components keep the neutral COSS theme shown below. ## Installation See [Get Started](/docs/get-started) for installation with the shadcn-svelte CLI. To add the theme manually, paste these tokens into the Tailwind stylesheet imported by your root layout. ```css title="src/app.css" @custom-variant dark (&:is(.dark *)); @theme inline { --font-sans: var(--font-sans); --font-heading: var(--font-sans); --font-mono: var(--font-mono); --color-background: var(--background); --color-foreground: var(--foreground); --color-card: var(--card); --color-card-foreground: var(--card-foreground); --color-popover: var(--popover); --color-popover-foreground: var(--popover-foreground); --color-primary: var(--primary); --color-primary-foreground: var(--primary-foreground); --color-secondary: var(--secondary); --color-secondary-foreground: var(--secondary-foreground); --color-muted: var(--muted); --color-muted-foreground: var(--muted-foreground); --color-accent: var(--accent); --color-accent-foreground: var(--accent-foreground); --color-destructive: var(--destructive); --color-destructive-foreground: var(--destructive-foreground); --color-info: var(--info); --color-info-foreground: var(--info-foreground); --color-success: var(--success); --color-success-foreground: var(--success-foreground); --color-warning: var(--warning); --color-warning-foreground: var(--warning-foreground); --color-border: var(--border); --color-input: var(--input); --color-ring: var(--ring); --color-sidebar: var(--sidebar); --color-sidebar-foreground: var(--sidebar-foreground); --color-sidebar-primary: var(--sidebar-primary); --color-sidebar-primary-foreground: var(--sidebar-primary-foreground); --color-sidebar-accent: var(--sidebar-accent); --color-sidebar-accent-foreground: var(--sidebar-accent-foreground); --color-sidebar-border: var(--sidebar-border); --color-sidebar-ring: var(--sidebar-ring); --radius-sm: calc(var(--radius) - 4px); --radius-md: calc(var(--radius) - 2px); --radius-lg: var(--radius); --radius-xl: calc(var(--radius) + 4px); --animate-skeleton: skeleton 2s -1s infinite linear; @keyframes skeleton { to { background-position: -200% 0; } } } :root { --radius: 0.625rem; --background: var(--color-white); --foreground: var(--color-neutral-800); --card: var(--color-white); --card-foreground: var(--color-neutral-800); --popover: var(--color-white); --popover-foreground: var(--color-neutral-800); --primary: var(--color-neutral-800); --primary-foreground: var(--color-neutral-50); --secondary: --alpha(var(--color-black) / 4%); --secondary-foreground: var(--color-neutral-800); --muted: --alpha(var(--color-black) / 4%); --muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-black)); --accent: --alpha(var(--color-black) / 4%); --accent-foreground: var(--color-neutral-800); --destructive: var(--color-red-500); --destructive-foreground: var(--color-red-700); --info: var(--color-blue-500); --info-foreground: var(--color-blue-700); --success: var(--color-emerald-500); --success-foreground: var(--color-emerald-700); --warning: var(--color-amber-500); --warning-foreground: var(--color-amber-700); --border: --alpha(var(--color-black) / 8%); --input: --alpha(var(--color-black) / 10%); --ring: var(--color-neutral-400); --sidebar: var(--color-neutral-50); --sidebar-foreground: color-mix(in srgb, var(--color-neutral-800) 64%, var(--sidebar)); --sidebar-primary: var(--color-neutral-800); --sidebar-primary-foreground: var(--color-neutral-50); --sidebar-accent: --alpha(var(--color-black) / 4%); --sidebar-accent-foreground: var(--color-neutral-800); --sidebar-border: --alpha(var(--color-black) / 6%); --sidebar-ring: var(--color-neutral-400); } .dark { --background: color-mix(in srgb, var(--color-neutral-950) 96%, var(--color-white)); --foreground: var(--color-neutral-100); --card: color-mix(in srgb, var(--background) 98%, var(--color-white)); --card-foreground: var(--color-neutral-100); --popover: color-mix(in srgb, var(--background) 96%, var(--color-white)); --popover-foreground: var(--color-neutral-100); --primary: var(--color-neutral-100); --primary-foreground: var(--color-neutral-800); --secondary: --alpha(var(--color-white) / 4%); --secondary-foreground: var(--color-neutral-100); --muted: --alpha(var(--color-white) / 4%); --muted-foreground: color-mix(in srgb, var(--color-neutral-500) 90%, var(--color-white)); --accent: --alpha(var(--color-white) / 4%); --accent-foreground: var(--color-neutral-100); --destructive: color-mix(in srgb, var(--color-red-500) 90%, var(--color-white)); --destructive-foreground: var(--color-red-400); --info: var(--color-blue-500); --info-foreground: var(--color-blue-400); --success: var(--color-emerald-500); --success-foreground: var(--color-emerald-400); --warning: var(--color-amber-500); --warning-foreground: var(--color-amber-400); --border: --alpha(var(--color-white) / 6%); --input: --alpha(var(--color-white) / 8%); --ring: var(--color-neutral-500); --sidebar: color-mix(in srgb, var(--color-neutral-950) 97%, var(--color-white)); --sidebar-foreground: color-mix(in srgb, var(--color-neutral-100) 64%, var(--sidebar)); --sidebar-primary: var(--color-neutral-100); --sidebar-primary-foreground: var(--color-neutral-800); --sidebar-accent: --alpha(var(--color-white) / 4%); --sidebar-accent-foreground: var(--color-neutral-100); --sidebar-border: --alpha(var(--color-white) / 5%); --sidebar-ring: var(--color-neutral-400); } ``` ## Font Variables Components use three font variables. - `--font-sans` controls body text, controls, and labels. - `--font-mono` controls code and keyboard shortcuts. - `--font-heading` controls dialog, alert dialog, sheet, and empty-state titles. Set the variables on `html` or `body` so they cascade into portals. By default, the theme maps `--font-heading` to `--font-sans`. ```css :root { --font-sans: Inter, ui-sans-serif, system-ui, sans-serif; --font-mono: "Geist Mono", ui-monospace, monospace; } ``` ### Custom fonts Set the three properties to any loaded fonts. When sans and heading share one family, only `--font-sans` needs a distinct value because the theme aliases `--font-heading` to it. For a separate heading family, point the theme token at that variable: ```css title="src/app.css" :root { --font-sans: "Inter Variable", sans-serif; --font-heading: "Cal Sans", sans-serif; --font-mono: "Geist Mono Variable", monospace; } @theme inline { --font-heading: var(--font-heading); } ``` Apply the variables to `html` or `body` so they cascade through the application and its portals. ## Shards UI Setup Shards UI renders overlays through portals. Give the application root its own stacking context and make `body` the containing block for full-viewport backdrops. ### Application Root Isolation ```svelte title="src/routes/+layout.svelte"
{@render children()}
``` This creates a local stacking context so portalled components stay above page content without component-specific z-index overrides. ### iOS Safari Compatibility ```css title="src/app.css" body { position: relative; } ``` This keeps portalled dialogs, sheets, popovers, selects, and menus above application content. It also prevents backdrop gaps after scrolling in current iOS Safari. --- ## Document: Migrating from shadcn-svelte and Bits UI # Migrating from shadcn-svelte and Bits UI > Move an existing Svelte component set to the Shards-backed COSS for Svelte wrappers. [Canonical documentation](https://coss-sv.vercel.app/docs/radix-migration) The upstream COSS guide helps React applications move from Radix and shadcn/ui to COSS and Base UI. For this port, the equivalent job is moving a Svelte application from shadcn-svelte or direct Bits UI parts to the COSS wrappers backed by Shards UI. Do not translate React props literally. Install one component at a time, compare its current Svelte types, then test its keyboard and focus behavior before removing the old implementation. ## Overview COSS for Svelte uses compound namespace imports for behavioral components. The root owns shared state, and nested parts read it through context. ```svelte Open dialog Edit profile Change the account details below. Form fields go here. Cancel ``` ## General migration patterns ### Use namespaces and an explicit root Replace a flat list of component imports with a namespace for compound components. ```svelte Account Account settings ``` ### Replace render delegation with native parts Shards parts render the correct native element and forward HTML attributes. Style a trigger directly instead of wrapping a Button solely to delegate its element. ```svelte Open dialog ... ``` Use the `as` prop only when a part should render another HTML tag. It accepts a tag name, not a component. ```svelte Settings ``` ### Bind state with Svelte Replace controlled value boilerplate with bindings. Callback props remain available when the change needs a side effect. ```svelte console.log(next)}>... ``` Common bindings include `bind:open`, `bind:value`, `bind:checked`, and `bind:ref`. ### Use `class` and lowercase event attributes Svelte uses `class`, not `className`, and current event attributes such as `onclick`, not React event props or legacy directives. ```svelte archiveProject()}>Archive project ``` ### Component naming conventions The Svelte namespace keeps the same clearer part names introduced by COSS: - `*.Content` becomes `*.Popup` for positioned surfaces or `*.Panel` for scrollable body content. - Legacy aliases may exist for compatibility, but new code should use the documented namespace name. - Compound components use an explicit `*.Root`; simple elements such as Button and Input remain named exports. ## Component migration guides ### Accordion - Use `Accordion.Root`, `Item`, `Header`, `Trigger`, and `Panel`. - Values are arrays for both single and multiple selection. - Set `multiple` to allow more than one open item. - Use `bind:value` or `onValueChange` for controlled state. **Comparison example:** ```svelte title="shadcn-svelte" Title Content ``` ```svelte title="COSS for Svelte" Title Content ``` ### Alert Alert remains a single element component. COSS adds semantic `info`, `success`, `warning`, and `error` variants. Add the semantic color variables from the [Styling](/docs/styling) guide. ### Badge Badge remains a named component. It adds `sm`, `default`, and `lg` sizes; use `lg` when preserving the height of a typical shadcn-svelte badge. It also adds the semantic variants listed for Alert. When the whole badge navigates, render it as an anchor directly: ```svelte New ``` ### Button COSS buttons are denser than the corresponding shadcn-svelte defaults and include more sizes. | Size | Typical shadcn-svelte height | COSS height | | --------- | ---------------------------- | ----------- | | `xs` | Not available | 24px | | `sm` | 32px | 28px | | `default` | 36px | 32px | | `lg` | 40px | 36px | | `xl` | Not available | 40px | | `icon` | 36px | 32px | | `icon-sm` | Not available | 28px | | `icon-lg` | Not available | 36px | Use `lg` to preserve a 36px default control. The `destructive-outline` variant is appropriate for a secondary destructive trigger; reserve the solid `destructive` variant for the primary destructive action. Buttons render anchors when `href` is present: ```svelte ``` ### Input Input sizes are `sm` at 28px, `default` at 32px, and `lg` at 36px. Use `lg` when preserving the typical 36px shadcn-svelte input height. ### Alert Dialog - Use `AlertDialog.Popup` instead of `Content` in new code. - Compose Header and Footer directly inside Popup; Alert Dialog has no separate Panel part. - Replace separate Action and Cancel parts with `AlertDialog.Close` controls. - Bind `open` on the root when application state needs it. ```svelte Show Alert Dialog Are you absolutely sure? This action cannot be undone. Cancel Continue ``` ### Dialog - Use `Dialog.Popup` instead of `Content` in new code. - Put `Header`, `Panel`, and `Footer` in that order. - Keep a form that spans Panel and Footer at `class="contents"`. - Use `Dialog.Close` for controls that dismiss the overlay. ```svelte Show Dialog Dialog Title Dialog Description Content Cancel ``` ### Sheet Sheet follows the Dialog structure with `Sheet.Popup`, `Sheet.Header`, `Sheet.Panel`, and `Sheet.Footer`. ```svelte Open Sheet Sheet Title Content here Close ``` ### Group (Button Group) - Prefer the `Group.*` names; legacy Button Group aliases may remain for compatibility. - Place `Group.Separator` between adjacent controls, including outline buttons, so focus states and borders remain consistent. - Render text or icons directly in `Group.Text` rather than introducing an extra control. ### Input Group Use the regular Button inside `InputGroup.Addon`; there is no separate Input Group Button component. To disable the group, disable `InputGroup.Input` or `InputGroup.Textarea` and any Button inside the group. Do not add a manual `data-disabled` attribute to the wrapper. ### Avatar and links Use the root as an anchor when the whole avatar navigates. ```svelte U ``` ### Card Use `Card.Panel` for the main card body. `Card.Content` remains a compatibility alias. ### Checkbox Checkbox remains a named component. Bind `checked` for a controlled value, and pass labels through a native `