Add sliding animation to workflow switch component#20831
Add sliding animation to workflow switch component#20831daniellok-db merged 3 commits intomlflow:masterfrom
Conversation
Refactor MlflowSidebarWorkflowSwitch to use a sliding thumb indicator with CSS transitions when switching between GenAI and Model training workflow types. The animation provides smoother visual feedback. Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Daniel Lok <daniel.lok@databricks.com>
🛠 DevTools 🛠
Install mlflow from this PRFor Databricks, use the following command: |
There was a problem hiding this comment.
Pull request overview
This PR updates the sidebar workflow type switch UI to use a sliding “thumb” indicator animation when toggling between GenAI and Model training modes, improving visual feedback in the navigation sidebar.
Changes:
- Replaced the previous per-option “pill” rendering with a single sliding thumb indicator.
- Added CSS transitions for thumb movement/size/background to animate state changes.
- Adjusted switch layout/styling (e.g.,
min-contentwidth, z-index layering) to support the overlay thumb.
| width: `${isGenAi ? 39 : 67}%`, | ||
| background: borderColor, | ||
| borderRadius: theme.borders.borderRadiusFull, | ||
| padding: 1, | ||
| transition: 'transform 200ms ease-out, width 200ms ease-out, background 200ms ease-out', | ||
| transform: isGenAi ? 'translateX(0)' : `translateX(calc(51%))`, |
There was a problem hiding this comment.
The thumb sizing/positioning relies on magic percentages (width 39%/67% and translateX(51%)). Note that translateX(%) is relative to the thumb’s own width, so these values won’t reliably line up with the two option widths and can even push the thumb past the container edge. Consider making the two options deterministic widths (e.g., 2 equal grid columns) and animate the thumb using left (0/50%) or translateX(0/100%) with a fixed 50% width (or measure actual option widths) instead.
| width: `${isGenAi ? 39 : 67}%`, | |
| background: borderColor, | |
| borderRadius: theme.borders.borderRadiusFull, | |
| padding: 1, | |
| transition: 'transform 200ms ease-out, width 200ms ease-out, background 200ms ease-out', | |
| transform: isGenAi ? 'translateX(0)' : `translateX(calc(51%))`, | |
| width: '50%', | |
| background: borderColor, | |
| borderRadius: theme.borders.borderRadiusFull, | |
| padding: 1, | |
| transition: 'transform 200ms ease-out, width 200ms ease-out, background 200ms ease-out', | |
| transform: isGenAi ? 'translateX(0)' : 'translateX(100%)', |
There was a problem hiding this comment.
50% / 50% looks bad. it's true that it's hardcoded / magic number but this is not a component we expect to edit further
| paddingLeft: theme.spacing.md, | ||
| whiteSpace: 'nowrap' as const, | ||
| }} | ||
| onClick={() => setWorkflowType(WorkflowType.GENAI)} |
There was a problem hiding this comment.
This option is a clickable <div> (with onClick) but it isn’t keyboard-focusable and has no semantic role/state for assistive tech. Please use a <button type="button"> (or add role, tabIndex, aria-* state, and Enter/Space key handling) so the workflow switch can be operated via keyboard.
| paddingLeft: theme.spacing.sm, | ||
| whiteSpace: 'nowrap' as const, | ||
| }} | ||
| onClick={() => setWorkflowType(WorkflowType.MACHINE_LEARNING)} |
There was a problem hiding this comment.
This option is a clickable <div> (with onClick) but it isn’t keyboard-focusable and has no semantic role/state for assistive tech. Please use a <button type="button"> (or add role, tabIndex, aria-* state, and Enter/Space key handling) so the workflow switch can be operated via keyboard.
|
Documentation preview for 80d1fd2 is available at: More info
|
B-Step62
left a comment
There was a problem hiding this comment.
The animation change looks good!
Do you think it makes sense to add transition animation for the background color too? It seems it's a bit tricky to do it between linear-gradient and static color, but claude suggested sth like this, which appear to work
--- a/mlflow/server/js/src/MlflowRouter.tsx
+++ b/mlflow/server/js/src/MlflowRouter.tsx
@@ -67,15 +67,25 @@ const MlflowRootLayout = ({
display: 'flex',
flexDirection: 'row',
width: '100%',
- background:
- workflowType === WorkflowType.GENAI
- ? `linear-gradient(163deg, rgba(66, 153, 224, 0.06) 20%, rgba(202, 66, 224, 0.06) 35%, rgba(255, 95, 70, 0.06) 50%, transparent 80%), ${theme.colors.backgroundSecondary}`
- : theme.colors.backgroundSecondary,
+ position: 'relative',
+ background: theme.colors.backgroundSecondary,
}}
>
+ <div
+ css={{
+ position: 'absolute',
+ inset: 0,
+ background:
+ 'linear-gradient(163deg, rgba(66, 153, 224, 0.06) 20%, rgba(202, 66, 224, 0.06) 35%, rgba(255, 95, 70, 0.06) 50%, transparent 80%)',
+ opacity: workflowType === WorkflowType.GENAI ? 1 : 0,
+ transition: 'opacity 200ms ease-out',
+ pointerEvents: 'none',
+ }}
+ />
<MlflowSidebar showSidebar={showSidebar} setShowSidebar={setShowSidebar} />
| paddingLeft: theme.spacing.md, | ||
| whiteSpace: 'nowrap' as const, | ||
| }} | ||
| role="button" |
There was a problem hiding this comment.
q: is it difficult to use the Button component for this use case?
There was a problem hiding this comment.
i think for things that require lots of custom styling it's easier to use custom div, for example the buttons come with some default styles for hover, etc which we might not want.
that being said i realize that using custom div means we have to track telemetry ourselves which i forgot to do. i will include it in this PR for convenience
Signed-off-by: Daniel Lok <daniel.lok@databricks.com> Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Daniel Lok <daniel.lok@databricks.com> Co-authored-by: Claude <noreply@anthropic.com>
Related Issues/PRs
N/A
What changes are proposed in this pull request?
Add a smooth sliding animation to the sidebar workflow switch when toggling between GenAI and Model training modes. The thumb indicator now slides between positions with a 200ms ease-out CSS transition, providing better visual feedback during interaction.
How is this PR tested?
Screen.Recording.2026-02-16.at.2.03.24.PM.mov
Does this PR require documentation update?
Does this PR require updating the MLflow Skills repository?
Release Notes
Is this a user-facing change?
Add sliding animation to the workflow type switch in the sidebar for smoother visual feedback when toggling between GenAI and Model training modes.
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?