Migration - Radix Vue to Reka UI
Installation
First and foremost, you need to install the latest reka-ui.
$ npm add reka-uiCongratulation! 🎉 Now that you've installed the above package, let's perform the migration! The first 2 steps are relatively simple. Just do a global search and replace for the following changes.
Codemods
To assist with the upgrade from Radix Vue to Reka UI, we collaborated with the Codemod team to automatically update your code to many of the new updates and patterns with open-source codemods. You can run the following command to automatically migrate to Reka UI:
npx codemod reka-ui/migration-recipeThe migration recipe will run the following codemods from the radix-vue Codemod repository:
reka-ui/import-updatereka-ui/update-css-and-data-attributesreka-ui/update-combobox-filterreka-ui/rename-controlled-statereka-ui/remove-calendar-step-prop
Import Statement Changes
The primary change in imports is replacing radix-vue with reka-ui.
<script setup lang="ts">
import { TooltipPortal, TooltipRoot, TooltipTrigger } from 'radix-vue'
import { TooltipPortal, TooltipRoot, TooltipTrigger } from 'reka-ui'
</script>npx codemod reka-ui/import-updateNaming Convention Changes
CSS variable and data attributes names have been updated to use the reka prefix instead of radix.
--radix-accordion-content-width: 300px;
--reka-accordion-content-width: 300px;
[data-radix-collection-item] {}
[data-reka-collection-item] {}npx codemod reka-ui/update-css-and-data-attributesComponent Breaking Changes
Combobox
Remove
filter-functionprops -Comboboxhas been refactored and improve to support better custom filtering. Read more.vue<template> <ComboboxRoot :filter-function="customFilter" /> </template>Codemod availablebashnpx codemod reka-ui/update-combobox-filterMove
displayValueprops from Root to Inputvue<template> <ComboboxRoot v-model:search-term="search" :display-value="(v) => v.name" /> <ComboboxRoot> <ComboboxInput v-model="search" :display-value="(v) => v.name" /> </ComboboxRoot> </template>
Arrow
- Improve arrow polygon - Change the svg polygon to allow better styling.
Form component
Rename controlled state to
v-model- Replacev-model:checked,v-model:pressedwith more familiar API for form component.vue<template> <CheckboxRoot v-model:checked="value" /> <CheckboxRoot v-model="value" /> </template>Codemod availablebashnpx codemod reka-ui/rename-controlled-stateReposition
VisuallyHidden- PreviouslyVisuallyHiddenwere position at the root node, causing style scoped to not be applied.
Pagination
Required
itemsPerPageprop - Instead of defaultitemsPerPagevalue, now it is required as to provide a more explicit hint about the page size.vue<template> <PaginationRoot :items-per-page="10" /> </template>
Calendar
Remove deprecated step prop - Use
prevPage/nextPageprops for greater control.vue<script setup lang="ts"> function pagingFunc(date: DateValue, sign: -1 | 1) { if (sign === -1) return date.subtract({ years: 1 }) return date.add({ years: 1 }) } </script> <template> <CalendarPrev step="year" /> <CalendarPrev :prev-page="(date: DateValue) => pagingFunc(date, -1)" /> <CalendarNext step="year" /> <CalendarNext :next-page="(date: DateValue) => pagingFunc(date, 1)" /> </template>Codemod availablebashnpx codemod reka-ui/remove-calendar-step-prop
Select
SelectValueno longer render teleported element - Previous implmenentation ofSelectValuewill render the selectedSelectItemvia teleporting fragment. This causes SSR flickering, and it is unnecessarily computation.vue<template> <SelectValue> <!-- render the content similar to `SelectItem` --> </SelectValue> </template>
