# Breaking Changes This document contains a list of breaking changes in each version and some notes to help migrate between versions. It is compiled manually from the commit history and changelog. We also tag PRs on GitHub with a [breaking change] label. [breaking change]: (https://github.com/ratatui/ratatui/issues?q=label%3A%22breaking+change%22) ## Summary This is a quick summary of the sections below: - [Unreleased](#unreleased) - The `From` impls for backend types are now replaced with more specific traits - [v0.29.0](#v0290) - `Sparkline::data` takes `IntoIterator` instead of `&[u64]` and is no longer const - Removed public fields from `Rect` iterators - `Line` now implements `From` - `Table::highlight_style` is now `Table::row_highlight_style` - `Tabs::select` now accepts `Into>` - `Color::from_hsl` is now behind the `palette` feature - [v0.28.0](#v0280) - `Backend::size` returns `Size` instead of `Rect` - `Backend` trait migrates to `get/set_cursor_position` - Ratatui now requires Crossterm 0.28.0 - `Axis::labels` now accepts `IntoIterator>` - `Layout::init_cache` no longer returns bool and takes a `NonZeroUsize` instead of `usize` - `ratatui::terminal` module is now private - `ToText` no longer has a lifetime - `Frame::size` is deprecated and renamed to `Frame::area` - [v0.27.0](#v0270) - List no clamps the selected index to list - Prelude items added / removed - 'termion' updated to 4.0 - `Rect::inner` takes `Margin` directly instead of reference - `Buffer::filled` takes `Cell` directly instead of reference - `Stylize::bg()` now accepts `Into` - Removed deprecated `List::start_corner` - `LineGauge::gauge_style` is deprecated - [v0.26.0](#v0260) - `Flex::Start` is the new default flex mode for `Layout` - `patch_style` & `reset_style` now consume and return `Self` - Removed deprecated `Block::title_on_bottom` - `Line` now has an extra `style` field which applies the style to the entire line - `Block` style methods cannot be created in a const context - `Tabs::new()` now accepts `IntoIterator>>` - `Table::new` now accepts `IntoIterator>>`. - [v0.25.0](#v0250) - Removed `Axis::title_style` and `Buffer::set_background` - `List::new()` now accepts `IntoIterator>>` - `Table::new()` now requires specifying the widths - `Table::widths()` now accepts `IntoIterator>` - Layout::new() now accepts direction and constraint parameters - The default `Tabs::highlight_style` is now `Style::new().reversed()` - [v0.24.0](#v0240) - MSRV is now 1.70.0 - `ScrollbarState`: `position`, `content_length`, and `viewport_content_length` are now `usize` - `BorderType`: `line_symbols` is now `border_symbols` and returns `symbols::border::set` - `Frame<'a, B: Backend>` is now `Frame<'a>` - `Stylize` shorthands for `String` now consume the value and return `Span<'static>` - `Spans` is removed - [v0.23.0](#v0230) - `Scrollbar`: `track_symbol` now takes `Option<&str>` - `Scrollbar`: symbols moved to `symbols` module - MSRV is now 1.67.0 - [v0.22.0](#v0220) - `serde` representation of `Borders` and `Modifiers` has changed - [v0.21.0](#v0210) - MSRV is now 1.65.0 - `terminal::ViewPort` is now an enum - `"".as_ref()` must be annotated to implement `Into>` - `Marker::Block` renders as a block char instead of a bar char - [v0.20.0](#v0200) - MSRV is now 1.63.0 - `List` no longer ignores empty strings ## Unreleased (0.30.0) ### `WidgetRef` no longer has a blanket implementation of Widget Previously there was a blanket implementation of Widget for WidgetRef. This has been reversed to instead be a blanket implementation of WidgetRef for all &W where W: Widget. Any widgets that previously implemented WidgetRef directly should now instead implement Widget for a reference to the type. ```diff -impl WidgetRef for Foo { - fn render_ref(&self, area: Rect, buf: &mut Buffer) +impl Widget for &Foo { + fn render(self, area: Rect, buf: &mut Buffer) } ``` ### The `From` impls for backend types are now replaced with more specific traits [#1464] [#1464]: https://github.com/ratatui/ratatui/pull/1464 Crossterm gains `ratatui::backend::crossterm::{FromCrossterm, IntoCrossterm}` Termwiz gains `ratatui::backend::termwiz::{FromTermwiz, IntoTermwiz}` This is necessary in order to avoid the orphan rule when implementing `From` for crossterm types once the crossterm types are moved to a separate crate. ```diff + use ratatui::backend::crossterm::{FromCrossterm, IntoCrossterm}; let crossterm_color = crossterm::style::Color::Black; - let ratatui_color = crossterm_color.into(); - let ratatui_color = ratatui::style::Color::from(crossterm_color); + let ratatui_color = ratatui::style::Color::from_crossterm(crossterm_color); - let crossterm_color = ratatui_color.into(); - let crossterm_color = crossterm::style::Color::from(ratatui_color); + let crossterm_color = ratatui_color.into_crossterm(); let crossterm_attribute = crossterm::style::types::Attribute::Bold; - let ratatui_modifier = crossterm_attribute.into(); - let ratatui_modifier = ratatui::style::Modifier::from(crossterm_attribute); + let ratatui_modifier = ratatui::style::Modifier::from_crossterm(crossterm_attribute); - let crossterm_attribute = ratatui_modifier.into(); - let crossterm_attribute = crossterm::style::types::Attribute::from(ratatui_modifier); + let crossterm_attribute = ratatui_modifier.into_crossterm(); ``` Similar conversions for `ContentStyle` -> `Style` and `Attributes` -> `Modifier` exist for Crossterm and the various Termion and Termwiz types as well. ### `Bar::label()` and `BarGroup::label()` now accepts `Into>`. ([#1471]) [#1471]: https://github.com/ratatui/ratatui/pull/1471 Previously `Bar::label()` and `BarGroup::label()` accepted `Line<'a>`, but they now accepts `Into>`. for `Bar::label()`: ```diff - Bar::default().label("foo".into()); + Bar::default().label("foo"); ``` for `BarGroup::label()`: ```diff - BarGroup::default().label("bar".into()); + BarGroup::default().label("bar"); ``` ### `Bar::text_value` now accepts `Into` ([#1471]) Previously `Bar::text_value` accepted `String`, but now it accepts `Into`. for `Bar::text_value()`: ```diff - Bar::default().text_value("foobar".into()); + Bar::default().text_value("foobar"); ``` ## [v0.29.0](https://github.com/ratatui/ratatui/releases/tag/v0.29.0) ### `Sparkline::data` takes `IntoIterator` instead of `&[u64]` and is no longer const ([#1326]) [#1326]: https://github.com/ratatui/ratatui/pull/1326 The `Sparkline::data` method has been modified to accept `IntoIterator` instead of `&[u64]`. `SparklineBar` is a struct that contains an `Option` value, which represents an possible _absent_ value, as distinct from a `0` value. This change allows the `Sparkline` to style data points differently, depending on whether they are present or absent. `SparklineBar` also contains an `Option