# Migrating to 0.5

Move a project from Mielui 0.4 to 0.5.

## Before you start

0.5 swaps Bits UI for ui-sdk under every interactive component. Most code keeps working once the imports and a few prop names change. Work through this page top to bottom and run `svelte-check` after each section. TypeScript flags most of the changes. The last section lists the ones it misses.

On 0.3 or older? Apply the breaking notes for each version in the [changelog](/docs/changelog) up to 0.4.0 first.

Porting with a coding agent? Give it the [0.5 notes for agents](/changelog/0.5.0/llm.md) along with this page. They explain each change in more depth.

## Update the package

If you import from `@mielui/svelte`, upgrade it. ui-sdk installs with it.

~~~~sh
pnpm add @mielui/svelte@0.5.0
~~~~

Mielui no longer uses `bits-ui`, `vaul-svelte`, `@floating-ui/dom`, or `@internationalized/date`. Remove the ones your own code does not import.

~~~~sh
pnpm remove bits-ui vaul-svelte @floating-ui/dom @internationalized/date
~~~~

## Update copied components

If you copied components with the CLI, install both ui-sdk packages at the exact version Mielui 0.5 was built against. A newer beta can change behavior.

~~~~sh
pnpm add @ui-sdk/svelte@0.1.0-beta.24 @ui-sdk/core@0.1.0-beta.24
~~~~

Copy the 0.5 source over every component you use. `--overwrite` replaces your local edits, so commit first and reapply them from the diff.

~~~~sh
pnpm dlx @mielui/svelte@0.5.0 add button dialog select --overwrite
~~~~

`add` leaves `ui.css` alone, and the 0.5 components need the new one because it imports ui-sdk's layer styles. Replace it, using the directory from your `mielui.json`:

~~~~sh
curl -o src/lib/mielui/ui.css https://unpkg.com/@mielui/svelte@0.5.0/registry/files/ui.css
~~~~

## Theme

The default theme changed. The neutral is now `moss`, an olive-tinted grey, and the brand color is `#e5808a`. A custom theme that sets both is unaffected. To keep the 0.4 colors, set them in [Theme Studio](/studio) and export, or put them in your theme JSON:

~~~~json
{
  "brand": "#ba7ca5",
  "neutral": "true"
}
~~~~

Every frame now has one border. Delete `chrome.borders` from theme JSON, and delete any `--mielui-inset-position`, `--mielui-border-inset-scale`, or `--mielui-modal-inset` overrides. Nothing reads them. Footer, header, and toolbar strips now render in the order you write them.

## Attachments

Morph, Number Shuffle, and Shimmer are Svelte attachments now, and they moved from `@mielui/svelte/actions` to `@mielui/svelte/attachments`. Change the import path and replace `use:` with `{@attach}`. The options object stays the same.

~~~~svelte
<script>
  import { numberShuffle } from '@mielui/svelte/actions/number-shuffle';
</script>

<span use:numberShuffle={{ value: total }}>{total}</span>
~~~~

~~~~svelte
<script>
  import { numberShuffle } from '@mielui/svelte/attachments/number-shuffle';
</script>

<span {@attach numberShuffle({ value: total })}>{total}</span>
~~~~

The helpers in `@mielui/svelte/utils` changed the same way. `pressable` and `visualViewportBounds` attach as they are. `travelingHighlight()` and `dynamicWidth()` are called to create the attachment, even without options. `dynamicWidth` lost `enabled`, so attach it conditionally: `{@attach wide && dynamicWidth()}`.

## Removed and renamed exports

ui-sdk now handles focus, dismissal, inert, and scroll lock for every overlay, so the old helpers are gone. Delete calls to them instead of looking for replacements.

- Utils: `clickOutside`, `trapFocus`, `inertOutside`, `lockBodyScroll`, `lockBodyBackground`, `pushEscapeLayer`, `getFocusableElements`, `positionFloatingPanel`, `submenuPanelOffset`, and `isPointInSubmenuTriangle` are removed.
- Transitions: `panelMotion`, `dialogIn`, `dialogOut`, `overlayIn`, `overlayOut`, `sheetIn`, `sheetOut`, and `SheetSide` are removed. Overlays animate with CSS.
- Drawer: `DrawerRootProps` is `DrawerProps`. `DrawerRegionProps` splits into `DrawerHeaderProps`, `DrawerBodyProps`, and `DrawerFooterProps`.
- Alert Dialog: `AlertDialogActionProps` splits into `AlertDialogCloseProps` and `AlertDialogConfirmProps`.
- State types: `TooltipState`, `SelectState`, and `ContextMenuState` are removed. `ComboboxState` is read-only for `searchPlacement`, `threshold`, and `appearance`.
- Trigger ids: Dialog, Alert Dialog, Sheet, Drawer, Popover, Dropdown Menu, and Tooltip triggers no longer take `id`. ui-sdk always replaced it. Select and Combobox triggers keep `id` for `<label for>`.

## Styling hooks

Parts no longer set `data-state="open"` or `data-state="active"`. A selector that still uses them matches nothing, and nothing warns you. Search your code for `data-state` and `data-[state` and switch to these attributes:

- Open: `data-open` and `data-closed` on disclosures and popups. In Tailwind, `data-open:`.
- Selected: `data-selected` on tabs and options.
- Checked: `data-checked` on radios, switches, and menu checkbox items. Checkbox is a native input and keeps `data-state`.
- Pressed: `data-pressed` on toggles. A selected `Toolbar.Button` reads `aria-pressed`, and a current `Toolbar.Link` reads `aria-current`.
- Highlighted: `data-highlighted` on the active menu or list item.

Mielui's own states still use `data-state`, such as `streaming` on Response Stream. Leave those selectors alone.

## Overlays

Popups and dialogs now render where you write them and open in the browser's top layer. They are no longer moved to `<body>`. Remove `portal` and `dismissLayer` from Popover, Dropdown Menu, Combobox, and Date Picker content, and remove Drawer's `Portal` part.

Rendering in place means events from inside a popup bubble to its parents. A menu inside a clickable table row fires the row's click handler. Stop propagation, or move the menu out of the row. A Dialog that holds a `<form>` can't sit inside another form, so move it out of the outer one.

`Tooltip.Trigger` is the button now. Move the props of the `Button` you put inside it onto the trigger:

~~~~svelte
<Tooltip.Root>
  <Tooltip.Trigger>
    <Button variant="ghost" size="icon" aria-label="Copy">…</Button>
  </Tooltip.Trigger>
  <Tooltip.Content>Copy</Tooltip.Content>
</Tooltip.Root>
~~~~

~~~~svelte
<Tooltip.Root>
  <Tooltip.Trigger variant="ghost" size="icon" aria-label="Copy">…</Tooltip.Trigger>
  <Tooltip.Content>Copy</Tooltip.Content>
</Tooltip.Root>
~~~~

Drawer drops `handleOnly`, `closeThreshold`, `repositionInputs`, and `nested`. Dragging follows ui-sdk's drawer physics.

## Menus

Dropdown Menu and Context Menu items no longer fire `onclick` when someone picks them with Enter or Space. The code still type-checks, and the item silently does nothing from the keyboard. Move the work to `callback`, which runs for the pointer and the keyboard:

~~~~svelte
<DropdownMenu.Item callback={() => archive(id)}>Archive</DropdownMenu.Item>
~~~~

## Dates

Calendar, Range Calendar, Date Picker, and Date Range Picker take ISO date strings instead of `DateValue` objects: `"2026-09-17"` for one day, `["2026-09-17", "2026-09-19"]` for a range, or `null`. Times are gone, along with `granularity`, `hourCycle`, and `hideTimeZone`.

~~~~svelte
<script>
  import { CalendarDate } from '@internationalized/date';

  let value = $state(new CalendarDate(2026, 9, 17));
</script>

<DatePicker.Root bind:value minValue={start} numberOfMonths={2}>
~~~~

~~~~svelte
<script>
  let value = $state<string | null>('2026-09-17');
</script>

<DatePicker.Root bind:value min="2026-01-01" months={2}>
~~~~

- Bounds: `minValue` and `maxValue` are `min` and `max`.
- Visible month: `placeholder` is `month`, or `defaultMonth` when uncontrolled.
- Months: `numberOfMonths` is `months`, and `pagedNavigation` is `pageBy="page"`.
- Unavailable days: `isDateDisabled` and `isDateUnavailable` are `unavailable`. `excludeDisabled` is `allowUnavailable`.
- Selection: `readonly` is `readOnly`, `preventDeselect` is `deselectable`, and `closeOnDateSelect` and `closeOnRangeSelect` are `closeOnSelect`.
- Validation: `validate` and `onInvalid` are removed. Call `details.cancel()` in `onValueChange` to reject a value.
- Calendar parts: `GridHead` and `HeadCell` are `Weekdays` and `Weekday`. `GridBody` and `GridRow` are `Weeks`, and `Cell` is `Day`.
- Date Picker input: One text field that accepts typed dates. `DatePicker.Segment` is removed.

`calendarLabel`, `yearFormat`, `disableDaysOutsideMonth`, `initialFocus`, `onStartValueChange`, `onEndValueChange`, and `readonlySegments` are removed with no replacement.

## Changes TypeScript misses

These compile fine and behave differently. Check each one you rely on.

- Switch: Enter submits the form. Space toggles.
- Range Slider: A named range submits one `start/end` value, such as `20/80`. Split it on `/` on the server instead of reading two fields.
- OTP Field: `element` binds the root `<div>`. `pattern` takes `digits`, `letters`, `alphanumeric`, or a RegExp for one character, not a regex string for the whole code.
- Command and Combobox: Results keep the order you write them in. The best match is highlighted instead of moved to the top. In Command, Escape clears the search before it closes.
- Combobox: Opens on click or typing only. `hoverable`, `delay`, and `closeDelay` are removed.
- Toolbar: Arrow keys move only between toolbar parts. Render a Select or Dropdown Menu trigger through `Toolbar.Button` with its `render` snippet to include it.
- Radio Group: `RadioGroup.Item` takes button attributes, and its `onchange` is gone. Use `onValueChange` on the root.
- Accordion: Arrow keys, Home, and End no longer move between headers. Tab does.
- Popover: An open Popover locks page scrolling only, not scroll areas inside the page.
- Tooltip: Outside a `Tooltip.Provider`, a label that changes while open swaps instead of rolling. Wrap the trigger in a Provider to keep the roll.

The full list of 0.5 changes is in the [changelog](/docs/changelog).