Migration Guide
Learn how to migrate from 0.x to 1.x
Anything before 1.0 is considered a pre-release version and is not guaranteed to be stable. While this guide may not be all encompassing, there were a lot of changes made not only to the library, but to Svelte itself.
The hope is that this information will get you most of the way there, but it's highly encouraged to check the documentation for the components you're using to determine what else may have changed.
Why Migrate?
Bits UI has been completely rewritten from the ground up to support Svelte 5. The rewrite has provided us with a number of benefits in the form of performance improvements, bug fixes, more flexible APIs, and an overall improved developer experience.
Once you learn how to use the new version of Bits UI, we're confident you'll find it to be a much more capable headless component library than before.
Shared Changes
- The
elprop has been replaced with arefprop across all components that render an HTML element. See the Ref documentation for more information. - The
asChildprop has been replaced with achildsnippet prop across all components that render an HTML element. See the Child Snippet documentation for more information. - Components that used to accept
transitionprops no longer do in favor of using thechildsnippet along withforceMountto use Svelte transitions. See the Transitions documentation for more information. - Components that used to provide data via
let:directives now provide that data viachildren/childsnippet props.
Accordion
- The
multipleprop has been removed from theAccordion.Rootcomponent and replaced with a requiredtypeprop which can be set to either'single'or'multiple'. This is used as a discriminant to properly type thevalueprop as either astringorstring[]. - The various
transitionprops have been removed from theAccordion.Contentcomponent. See the Transitions documentation for more information.
See the Accordion documentation for more information.
Alert Dialog
- The various
transitionprops have been removed from theAlertDialog.ContentandAlertDialog.Overlaycomponents. See the Transitions documentation for more information. - To render the dialog content in a portal, you now must wrap the
AlertDialog.Contentin theAlertDialog.Portalcomponent. - The
AlertDialog.Actioncomponent no longer closes the dialog by default, as we learned it was causing more harm than good when attempting to submit a form with theActionbutton. See the Form Submission section for more information on how to handle submitting forms before closing the dialog.
Button
- The
Buttoncomponent no longer accepts abuildersprop, instead you should use thechildsnippet on the various components to receive/pass the attributes to the underlying button. See Child Snippet for more information.
Checkbox
- The
Checkbox.Indicatorcomponent has been removed in favor of using thechildrensnippet prop to get a reference to thecheckedstate and render a custom indicator. See the Checkbox documentation for more information. - The
Checkbox.Inputcomponent has been removed in favor of automatically rendering a hidden input when thenameprop is provided to theCheckbox.Rootcomponent. - The
checkedstate of theCheckboxcomponent is now of typebooleaninstead ofboolean | 'indeterminate',indeterminateis its own state now and can be managed via theindeterminateprop. - A new component,
Checkbox.Grouphas been introduced to support checkbox groups.
See the Checkbox documentation for more information.
Combobox
- The
multipleprop has been removed from theCombobox.Rootcomponent and replaced with a requiredtypeprop which can be set to either'single'or'multiple'. This is used as a discriminant to properly type thevalueprop as either astringorstring[]. - The
selectedprop has been replaced with avalueprop, which is limited to astring(orstring[]iftype="multiple"). - The combobox now automatically renders a hidden input when the
nameprop is provided to theCombobox.Rootcomponent. - The
Combobox.ItemIndicatorcomponent has been removed in favor of using thechildrensnippet prop to get a reference to theselectedstate and render a custom indicator. See the Combobox documentation for more information. Combobox.GroupandCombobox.GroupHeadinghave been added to support groups within the combobox.
Context Menu/Dropdown Menu/Menubar Menu
- The
.RadioIndicatorand.CheckboxIndicatorcomponents have been removed in favor of using thechildrensnippet prop to get a reference to thecheckedorselectedstate and render a custom indicator. See the Context Menu, Dropdown Menu, and Menubar documentation for more information. - The
.Labelcomponent, which was used as the heading for a group of items has been replaced with the.GroupHeadingcomponent. - The
hrefprop on the.Itemcomponents has been removed in favor of thechildsnippet and rendering your own anchor element.
Pin Input
- The
PinInputcomponent has been completely overhauled to better act as an OTP input component, with code and inspiration taken from Input OTP by Guilherme Rodz. The best way to migrate is to reference the Pin Input documentation to see how to use the new component.
Select
- The
multipleprop has been removed from theSelect.Rootcomponent and replaced with a requiredtypeprop which can be set to either'single'or'multiple'. This is used as a discriminant to properly type thevalueprop as either astringorstring[]. - The
selectedprop has been replaced with avalueprop, which is limited to astring(orstring[]iftype="multiple"). - The select now automatically renders a hidden input when the
nameprop is provided to theSelect.Rootcomponent. - The
Select.ItemIndicatorcomponent has been removed in favor of using thechildrensnippet prop to get a reference to theselectedstate and render a custom indicator. See the Select documentation for more information. Select.GroupandSelect.GroupHeadinghave been added to support groups within the Select.
Slider
Slider.Rootnow requires atypeprop to be set to either'single'or'multiple'to properly type thevalueas either anumberornumber[].- A new prop,
onValueCommithas been introduced which is called when the user commits a value change (e.g. by releasing the mouse button or pressing Enter). This is useful for scenarios where you want to update the value only when the user has finished interacting with the slider, not for each movement of the thumb.
Tooltip
- A required component necessary to provide context for shared tooltips,
Tooltip.Providerhas been added. This replaces thegroupprop on the previous version'sTooltipcomponent. You can wrap your entire app withTooltip.Provider, or wrap a specific section of your app with it to provide shared context for tooltips.