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
el
prop has been replaced with aref
prop across all components that render an HTML element. See the Ref documentation for more information. - The
asChild
prop has been replaced with achild
snippet prop across all components that render an HTML element. See the Child Snippet documentation for more information. - Components that used to accept
transition
props no longer do in favor of using thechild
snippet along withforceMount
to use Svelte transitions. See the Transitions documentation for more information. - Components that used to provide data via
let:
directives now provide that data viachildren
/child
snippet props.
Accordion
- The
multiple
prop has been removed from theAccordion.Root
component and replaced with a requiredtype
prop which can be set to either'single'
or'multiple'
. This is used as a discriminant to properly type thevalue
prop as either astring
orstring[]
. - The various
transition
props have been removed from theAccordion.Content
component. See the Transitions documentation for more information.
Alert Dialog
- The various
transition
props have been removed from theAlertDialog.Content
andAlertDialog.Overlay
components. See the Transitions documentation for more information. - To render the dialog content in a portal, you now must wrap the
AlertDialog.Content
in theAlertDialog.Portal
component. - The
AlertDialog.Action
component no longer closes the dialog by default, as we learned it was causing more harm than good when attempting to submit a form with theAction
button. See the Form Submission section for more information on how to handle submitting forms before closing the dialog.
Button
- The
Button
component no longer accepts abuilders
prop, instead you should use thechild
snippet on the various components to receive/pass the attributes to the underlying button. See Child Snippet for more information.
Checkbox
- The
Checkbox.Indicator
component has been removed in favor of using thechildren
snippet prop to get a reference to thechecked
state and render a custom indicator. See the Checkbox documentation for more information. - The
Checkbox.Input
component has been removed in favor of automatically rendering a hidden input when thename
prop is provided to theCheckbox.Root
component.
Combobox
- The
multiple
prop has been removed from theCombobox.Root
component and replaced with a requiredtype
prop which can be set to either'single'
or'multiple'
. This is used as a discriminant to properly type thevalue
prop as either astring
orstring[]
. - The
selected
prop has been replaced with avalue
prop, which is limited to astring
(orstring[]
iftype="multiple"
). - The combobox now automatically renders a hidden input when the
name
prop is provided to theCombobox.Root
component. - The
Combobox.ItemIndicator
component has been removed in favor of using thechildren
snippet prop to get a reference to theselected
state and render a custom indicator. See the Combobox documentation for more information. Combobox.Group
andCombobox.GroupHeading
have been added to support groups within the combobox.
Context Menu/Dropdown Menu/Menubar Menu
- The
.RadioIndicator
and.CheckboxIndicator
components have been removed in favor of using thechildren
snippet prop to get a reference to thechecked
orselected
state and render a custom indicator. See the Context Menu, Dropdown Menu, and Menubar documentation for more information. - The
.Label
component, which was used as the heading for a group of items has been replaced with the.GroupHeading
component. - The
href
prop on the.Item
components has been removed in favor of thechild
snippet and rendering your own anchor element.
Pin Input
- The
PinInput
component has been overhauled to better act as an OTP input component. See the Pin Input documentation for more information.
Select
- The
multiple
prop has been removed from theSelect.Root
component and replaced with a requiredtype
prop which can be set to either'single'
or'multiple'
. This is used as a discriminant to properly type thevalue
prop as either astring
orstring[]
. - The
selected
prop has been replaced with avalue
prop, which is limited to astring
(orstring[]
iftype="multiple"
). - The select now automatically renders a hidden input when the
name
prop is provided to theSelect.Root
component. - The
Select.ItemIndicator
component has been removed in favor of using thechildren
snippet prop to get a reference to theselected
state and render a custom indicator. See the Select documentation for more information. Select.Group
andSelect.GroupHeading
have been added to support groups within the Select.
Tooltip
- A required component necessary to provide context for shared tooltips,
Tooltip.Provider
has been added. This replaces thegroup
prop on the previous version'sTooltip
component. You can wrap your entire app withTooltip.Provider
, or wrap a specific section of your app with it to provide shared context for tooltips.