Transitions & Hover States
RTXUI supports CSS-style transitions and interactive pseudo-classes on DOM elements. This allows you to build terminal applications with smooth color shifts, expanding borders, and responsive mouse effects without writing manual frame updates.
1. Interactive Pseudo-Classes
You can define styles that apply only under specific user interaction states:
:hover: Active when the mouse cursor is hovering over the element or its children.:active: Active while the element is being clicked/pressed.:focus: Active when the element has captured keyboard focus.
Example Rulesets
.button {
background-color: rgb(30, 58, 138); /* Slate Blue */
}
.button:hover {
background-color: rgb(29, 78, 216); /* Bright Blue on hover */
}
.button:active {
background-color: rgb(30, 64, 175); /* Dark Blue on click */
}Minimal Interactive Demo
Below is the interactive tab view for :hover, :active, and :focus pseudo-classes:
2. CSS Transitions
The transition property configures how style attributes interpolate smoothly over time instead of changing instantly.
Shorthand Syntax
transition: <property> <duration> [<timing-function>] [<delay>]You can declare multiple property transitions by separating them with commas, or use the keyword all to animate all supported variables:
transition: background-color 0.2s ease-in-out, width 0.3s ease-out;Animatable Properties
- Dimensions:
width,height(e.g.20to40cells). - Borders:
border-top-color,border-right-color,border-bottom-color,border-left-color(or shorthandborder-color). - Colors & Opacities:
color,background-color,opacity. - Flex Constraints:
flex-grow,flex-shrink.
Easing Functions
linearease(Default curve)ease-inease-outease-in-out- Sine curves:
ease-in-sine,ease-out-sine,ease-in-out-sine - Quad curves:
ease-in-quad,ease-out-quad,ease-in-out-quad - Cubic curves:
ease-in-cubic,ease-out-cubic,ease-in-out-cubic - Quart curves:
ease-in-quart,ease-out-quart,ease-in-out-quart - Quint curves:
ease-in-quint,ease-out-quint,ease-in-out-quint - Expo curves:
ease-in-expo,ease-out-expo,ease-in-out-expo - Circ curves:
ease-in-circ,ease-out-circ,ease-in-out-circ - Back curves:
ease-in-back,ease-out-back,ease-in-out-back cubic-bezier(x1, y1, x2, y2)(Defines a custom cubic Bézier easing curve)
Minimal Transition Demo
Below is the interactive tab view for background-color and border-color transitions:
3. Advanced Transition Examples
Primary Animation & Flex Layout Demo
Hover over the Hover Me button and click Grow Me to observe interactive transitions reflow the flex container:
Component-Level Transition Demos
- Slider Transition: Smooth track and thumb focus highlighting. (See Slider Demo)
- Checkbox Transition: Background check state changes. (See Checkbox Demo)
- Dropdown Select Menu: Highlight shifts. (See Select Demo)

