The Open Standard for Generative UI
@use "../../cssUtils" as cssUtils;
// A $bright highlight sweeping across a $base bed of text, both clipped to the
// glyphs. The transparent fill is required: `background-clip: text` only clips
// the background, so an opaque -webkit-text-fill-color hides it entirely.
@mixin text-shimmer($base, $bright, $duration: 3s) {
display: inline-block;
background-image:
linear-gradient(90deg, transparent 40%, $bright 50%, transparent 60%),
linear-gradient($base, $base);
// Keep these relative to the label: at 3x, the 20%-wide band is 60% of it at
// any length and clears both edges at the ends of its travel — a band still
// on screen when the animation loops reads as a jump.
background-size:
300% 100%,
100% 100%;
background-repeat: no-repeat, no-repeat;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
animation: openui-tool-code-shimmer $duration linear infinite;
}
// Keyboard focus ring for the button-reset elements (which strip UA chrome).
@mixin focus-ring {
&:focus-visible {
outline: 2px solid cssUtils.$border-interactive-emphasis;
outline-offset: cssUtils.$space-3xs;
}
}
// ── "Behind the scenes" wrapper ──
// Rows inside the card are inset by this much; the card is pulled out by the
// same amount (plus its border) so row glyphs and labels sit in the same
// columns as the header's.
$timeline-row-inset: cssUtils.$space-m;
// Glyph slot shared by the header and every row (glyphs draw at 20px in it).
$timeline-glyph-slot: 24px;
.openui-behind-the-scenes {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: cssUtils.$space-3xs;
width: 100%;
// Spaces the run from the answer that follows it; no divider line.
margin-block-end: cssUtils.$space-m;
&__toggle {
@include cssUtils.button-reset;
display: flex;
align-items: center;
gap: cssUtils.$space-s;
// Flush with the message content — the header carries no chrome of its own.
padding: cssUtils.$space-2xs 0;
@include cssUtils.typography(body, small);
color: cssUtils.$text-neutral-primary;
cursor: pointer;
background-color: transparent;
text-align: start;
// button-reset strips chrome, so restore a visible keyboard focus ring.
@include focus-ring;
// Collapsed, the chevron only shows on hover or keyboard focus. Open, it
// stays visible and turns down.
&:hover .openui-behind-the-scenes__toggle-icon,
&:focus-visible .openui-behind-the-scenes__toggle-icon {
opacity: 1;
}
&[aria-expanded="true"] .openui-behind-the-scenes__toggle-icon {
opacity: 1;
transform: rotate(90deg);
}
}
// A finished run's collapsed header steps back: label and mascot in the
// secondary tone (the mascot is drawn in black, so it takes secondary's 60%
// alpha as opacity). Opening it brings the label back to primary.
&--settled &__toggle[aria-expanded="false"] {
.openui-behind-the-scenes__toggle-label {
color: cssUtils.$text-neutral-secondary;
}
.openui-behind-the-scenes__mascot {
opacity: 0.6;
}
}
// TimelineWorkingIndicator: the same header, but nothing to toggle yet.
&__toggle--static {
cursor: default;
}
// One line of header content; a new line slides up into place as the old one
// slides up and out (HeaderTicker in ToolCallTimeline.tsx).
&__ticker {
display: inline-grid;
overflow: hidden;
// A little room on every side so the clip doesn't crop the mascot's
// overhang or a glyph's animation (the search lens hops past its box).
padding: cssUtils.$space-2xs;
margin: calc(-1 * #{cssUtils.$space-2xs});
}
&__ticker-item {
grid-area: 1 / 1;
display: inline-flex;
align-items: center;
gap: cssUtils.$space-s;
white-space: nowrap;
}
// Keep the durations in sync with TICKER_SLIDE_MS in ToolCallTimeline.tsx.
&__ticker-item--in {
animation: openui-behind-the-scenes-slide-in 0.32s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
&__ticker-item--out {
animation: openui-behind-the-scenes-slide-out 0.32s cubic-bezier(0.4, 0, 0.6, 1) both;
}
&__glyph {
display: grid;
place-items: center;
flex-shrink: 0;
width: $timeline-glyph-slot;
height: $timeline-glyph-slot;
color: cssUtils.$text-neutral-secondary;
}
// Slightly wider than the slot; it overhangs evenly so labels stay aligned.
&__mascot {
max-width: none;
margin-inline: -2px;
}
&__toggle-label {
-webkit-text-fill-color: currentColor;
}
&__toggle-label--shimmer {
@include text-shimmer(cssUtils.$text-neutral-primary, cssUtils.$foreground);
}
&__toggle-icon {
flex-shrink: 0;
color: cssUtils.$text-neutral-secondary;
opacity: 0;
transition:
transform 0.2s ease,
opacity 0.15s ease;
}
// Opens to the list's height (grid-rows 0fr → 1fr). Pulled out by the row
// inset so the card's rows line up with the header.
&__collapse {
display: grid;
grid-template-rows: 0fr;
opacity: 0;
width: calc(100% + #{$timeline-row-inset} + 1px);
margin-inline-start: calc(-1 * (#{$timeline-row-inset} + 1px));
transition:
grid-template-rows 0.25s ease,
opacity 0.2s ease;
&--open {
grid-template-rows: 1fr;
opacity: 1;
}
}
&__collapse-inner {
overflow: hidden;
min-height: 0;
}
// The steps, as rows in one card split by dotted rules.
&__items {
display: flex;
flex-direction: column;
width: 100%;
border: 1px dashed cssUtils.$border-interactive;
border-radius: cssUtils.$radius-2xl;
background-color: cssUtils.$foreground;
// Long runs must not push the conversation far down the page: past this
// height the timeline scrolls internally. Overridable per app via the
// custom property.
max-height: var(--openui-tool-timeline-max-height, 24rem);
overflow-y: auto;
overscroll-behavior: contain;
// Scrolls silently — the edge fades already signal there's more.
scrollbar-width: none;
-ms-overflow-style: none;
&::-webkit-scrollbar {
display: none;
}
// Each edge dissolves only while a row is hidden behind it. Widths come from
// JS (CSS can't ask about scroll position); at 0 the mask is a no-op.
--openui-timeline-fade-top: 0px;
--openui-timeline-fade-bottom: 0px;
$edges: linear-gradient(
to bottom,
transparent 0,
#000 var(--openui-timeline-fade-top),
#000 calc(100% - var(--openui-timeline-fade-bottom)),
transparent 100%
);
-webkit-mask-image: $edges;
mask-image: $edges;
.openui-tool-call__title-row {
padding: cssUtils.$space-xs $timeline-row-inset;
}
// Details sit under the label, inside the row's own section.
.openui-tool-call__content {
margin: 0;
padding: 0 $timeline-row-inset cssUtils.$space-s-m
calc(#{$timeline-row-inset} + #{$timeline-glyph-slot} + #{cssUtils.$space-s});
}
// The card is already the frame: no second card inside it.
.openui-tool-call__sources,
.openui-tool-call__block {
border: 0;
border-radius: 0;
background-color: transparent;
padding: 0;
}
// Sources line up with the label above them.
.openui-tool-call__source {
padding-inline: 0;
}
}
&__items--fade-top {
--openui-timeline-fade-top: 1.5rem;
}
&__items--fade-bottom {
--openui-timeline-fade-bottom: 2rem;
}
// Opacity only, so a new row doesn't jump while the list follows it.
&__item {
animation: openui-behind-the-scenes-reveal 0.25s ease;
& + & {
border-top: 1px dashed cssUtils.$border-interactive;
}
}
}
@keyframes openui-behind-the-scenes-reveal {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes openui-behind-the-scenes-slide-in {
from {
transform: translateY(100%);
opacity: 0;
}
to {
transform: translateY(0);
opacity: 1;
}
}
@keyframes openui-behind-the-scenes-slide-out {
from {
transform: translateY(0);
opacity: 1;
}
to {
transform: translateY(-100%);
opacity: 0;
}
}
// ── Timeline item (each tool call) ──
.openui-tool-call {
display: flex;
flex-direction: column;
width: 100%;
padding-inline-start: 0;
&__title-row {
@include cssUtils.button-reset;
display: flex;
align-items: center;
gap: cssUtils.$space-s;
padding: cssUtils.$space-3xs 0;
width: 100%;
color: cssUtils.$text-neutral-secondary;
background-color: transparent;
cursor: pointer;
// The row is a <button>, whose UA default centers the stretched label.
text-align: start;
// Allow the name to shrink/ellipsize instead of overflowing the row.
min-width: 0;
@include focus-ring;
&:hover .openui-tool-call__name {
color: cssUtils.$text-neutral-primary;
}
// Collapsed, the chevron only shows on hover or keyboard focus. Open, it
// stays visible and turns down.
.openui-tool-call__chevron {
color: cssUtils.$text-neutral-secondary;
opacity: 0;
}
&:hover .openui-tool-call__chevron,
&:focus-visible .openui-tool-call__chevron {
opacity: 1;
}
&[aria-expanded="true"] .openui-tool-call__chevron {
opacity: 1;
transform: rotate(90deg);
}
}
// No explicit width: the flex column stretches it, so the indent eats into
// its own width instead of pushing it past the container's edge.
&__content {
display: flex;
flex-direction: column;
gap: cssUtils.$space-xs;
margin-block: cssUtils.$space-2xs;
margin-inline-start: cssUtils.$space-s;
}
&__block {
padding: cssUtils.$space-s cssUtils.$space-m;
// Same frame as __sources: a row expands into one or the other, so they
// can't read as different kinds of container. The tint separates raw
// payloads from the sources list, which stays on the plain surface.
border: 1px solid cssUtils.$border-default;
border-radius: cssUtils.$radius-xl;
background-color: cssUtils.$highlight-subtle;
max-height: 250px;
overflow: auto;
}
&__icon-wrapper {
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
min-width: $timeline-glyph-slot;
min-height: $timeline-glyph-slot;
}
&__icon {
flex-shrink: 0;
color: cssUtils.$text-neutral-secondary;
}
// Legacy ToolCallComponent only; the glyphs animate themselves.
&__icon--blinking {
animation: openui-tool-call-icon-blink 1.5s ease-in-out infinite;
}
&__name {
@include cssUtils.typography(body, small);
color: cssUtils.$text-neutral-primary;
-webkit-text-fill-color: currentColor;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
// Shrink + ellipsize so a long tool name never pushes the chevron offscreen.
flex: 1 1 auto;
min-width: 0;
}
&__name--shimmer {
@include text-shimmer(cssUtils.$text-neutral-primary, cssUtils.$foreground);
}
&__connector {
display: flex;
gap: cssUtils.$space-m;
padding: cssUtils.$space-s-m cssUtils.$space-s;
padding-inline-end: 0;
min-height: 20px;
width: calc(100% - 6px);
// 6px offset = half of 14px icon - half of 1px border
margin-inline-start: 6px;
// Kept as a transparent rail so the indent holds; no visible line.
border-inline-start: 1px solid transparent;
}
&__connector--last {
border-inline-start-color: transparent;
}
&__args-block {
display: flex;
flex-direction: column;
gap: cssUtils.$space-xs;
padding-left: cssUtils.$space-m;
width: 100%;
}
// ── Web-search presentation (reasoning line + sources list) ──
&__reasoning {
@include cssUtils.typography(label, small);
color: cssUtils.$text-neutral-secondary;
font-style: italic;
margin: 0;
}
&__sources {
display: flex;
flex-direction: column;
width: 100%;
border: 1px solid cssUtils.$border-default;
border-radius: cssUtils.$radius-xl;
background-color: cssUtils.$foreground;
padding: cssUtils.$space-2xs;
}
&__source {
display: flex;
align-items: center;
justify-content: space-between;
gap: cssUtils.$space-m;
padding: cssUtils.$space-2xs cssUtils.$space-s;
padding-left: cssUtils.$space-2xs;
border-radius: cssUtils.$radius-m;
cursor: pointer;
text-decoration: none;
color: inherit;
transition: background-color 0.15s ease;
&:hover {
background-color: cssUtils.$sunk;
}
@include focus-ring;
}
&__source-left {
display: flex;
align-items: center;
gap: cssUtils.$space-s;
min-width: 0;
flex: 0 1 75%;
}
&__source-logo {
width: 24px;
height: 24px;
border-radius: cssUtils.$radius-xs;
flex-shrink: 0;
}
&__source-title {
@include cssUtils.typography(label, small);
color: cssUtils.$text-neutral-primary;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
&__source-desc {
@include cssUtils.typography(label, small);
color: cssUtils.$text-neutral-secondary;
// Let the description shrink + truncate so it never squeezes the title.
flex: 1 1 25%;
min-width: 0;
text-align: end;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
// ── Chevron "card" composition (DefaultToolCard) ──
&--card {
padding-left: 0;
}
&__header {
@include cssUtils.button-reset;
display: flex;
align-items: center;
gap: cssUtils.$space-m;
width: 100%;
padding: cssUtils.$space-2xs cssUtils.$space-s;
border-radius: cssUtils.$radius-m;
cursor: pointer;
background-color: transparent;
color: cssUtils.$text-neutral-secondary;
&:not(:disabled):hover {
background-color: cssUtils.$sunk;
}
// button-reset strips chrome, so restore a visible keyboard focus ring.
@include focus-ring;
}
&__chevron {
flex-shrink: 0;
margin-inline-start: auto;
color: cssUtils.$text-neutral-secondary;
transition: transform 0.2s ease;
}
&__panel {
display: flex;
flex-direction: column;
gap: cssUtils.$space-xs;
padding: cssUtils.$space-s cssUtils.$space-m;
width: 100%;
}
&__request,
&__response {
@include cssUtils.typography(code, small);
color: cssUtils.$text-neutral-secondary;
margin: 0;
white-space: pre-wrap;
// Wrap at spaces; only hard-break tokens too long to fit.
overflow-wrap: anywhere;
// Clamp a huge result in the chevron card (parity with the timeline path).
max-height: 250px;
overflow: auto;
}
&__result--error {
color: cssUtils.$text-danger-primary;
}
// ── Status tints (driven by the Root `--{status}` modifier) ──
// Glyph + label alone, no border or fill. The one status to skip the muted
// icon — a failure has to be legible.
&--error {
.openui-tool-call__icon {
color: cssUtils.$text-danger-primary;
}
.openui-tool-call__name {
color: cssUtils.$text-danger-primary;
}
}
}
// ── Expandable code block (request / response) ──
.openui-tool-code-block {
border: 1px solid cssUtils.$border-default;
border-radius: cssUtils.$radius-xl;
overflow: hidden;
width: 100%;
background-color: cssUtils.$highlight-subtle;
transition: border-color 0.15s ease;
&:hover {
border-color: cssUtils.$border-interactive-emphasis;
}
&__header {
@include cssUtils.button-reset;
display: flex;
align-items: center;
justify-content: space-between;
gap: cssUtils.$space-s;
width: 100%;
padding: cssUtils.$space-s;
cursor: pointer;
background-color: transparent;
// button-reset strips chrome, so restore a visible keyboard focus ring.
@include focus-ring;
}
&__label {
@include cssUtils.typography(label, small);
color: cssUtils.$text-neutral-secondary;
-webkit-text-fill-color: currentColor;
// Truncate a grown/loading label instead of shoving the chevron offscreen.
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
&__label--loading {
@include cssUtils.typography(label, small);
@include text-shimmer(cssUtils.$text-neutral-secondary, cssUtils.$text-neutral-primary);
}
&__chevron {
flex-shrink: 0;
color: cssUtils.$text-neutral-secondary;
transition: transform 0.2s ease;
}
&__chevron--expanded {
transform: rotate(180deg);
}
&__content {
border-top: 1px solid cssUtils.$border-default;
max-height: 250px;
overflow: auto;
padding: cssUtils.$space-s cssUtils.$space-m;
background-color: transparent;
}
&__code {
@include cssUtils.typography(code, small);
color: cssUtils.$text-neutral-secondary;
margin: 0;
white-space: pre-wrap;
// Wrap at spaces; only hard-break tokens too long to fit.
overflow-wrap: anywhere;
}
&__code--error {
color: cssUtils.$text-danger-primary;
}
}
// ── Web-search detailed view (renderer `actual`) ──
.openui-web-search__detailed {
display: flex;
flex-direction: column;
gap: cssUtils.$space-m;
list-style: none;
margin: 0;
padding: cssUtils.$space-m;
a {
display: inline-flex;
align-items: center;
gap: cssUtils.$space-s;
color: cssUtils.$text-neutral-primary;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
p {
@include cssUtils.typography(label, small);
color: cssUtils.$text-neutral-secondary;
margin: cssUtils.$space-2xs 0 0;
}
}
@keyframes openui-tool-call-icon-blink {
0%,
100% {
opacity: 0.6;
}
50% {
opacity: 0.2;
}
}
@keyframes openui-tool-code-shimmer {
0% {
background-position: 100% center;
}
100% {
background-position: 0% center;
}
}
// ── Timeline thinking steps ──
// Prose the model emitted alongside its tool calls, shown when its "Thought
// process" row is opened. Doubled-up selector so these rules WIN over
// `.openui-markdown-renderer`'s own class and tag rules (body/default
// typography, primary color on p/strong/…) regardless of which stylesheet
// lands later in the build.
.openui-tool-call-timeline__text-step-body.openui-tool-call-timeline__text-step-body {
@include cssUtils.typography(body, small);
color: cssUtils.$text-neutral-secondary;
min-width: 0;
* {
margin: 0;
font: inherit;
color: inherit !important;
line-height: inherit;
}
}
// ── Tool glyphs (ToolGlyphs.tsx) ──
// Lucide shapes looped with lucide-animated's motion while `--animate` is set.
.openui-tool-glyph {
display: block;
flex-shrink: 0;
overflow: visible;
* {
transform-box: fill-box;
transform-origin: center;
}
// Draw-on strokes (pathLength = 1).
.openui-tool-glyph__hill,
.openui-tool-glyph__fold {
stroke-dasharray: 1 1;
stroke-dashoffset: 0;
}
// Masks the sun's rays behind the cloud.
.openui-tool-glyph__cloud {
fill: cssUtils.$foreground;
}
}
.openui-tool-glyph--animate {
// search: x [0, 0, -3, 0], y [0, -4, 0, 0]
.openui-tool-glyph__lens {
animation: openui-tool-glyph-hop 2s ease-in-out infinite;
}
// image: the sun pops, then the hill draws across
.openui-tool-glyph__sun {
animation: openui-tool-glyph-pop 2.4s ease-out infinite;
}
.openui-tool-glyph__hill {
animation: openui-tool-glyph-draw 2.4s ease-in-out infinite;
}
// cloud-sun: x/y [-1, 1, -1, 1, 0]; rays fade in by index (inline delays)
.openui-tool-glyph__cloud {
animation: openui-tool-glyph-wiggle 2.4s ease-in-out infinite;
}
.openui-tool-glyph__ray {
animation: openui-tool-glyph-fade-in 2.4s ease-out infinite;
}
// blocks: the loose block travels [-4, 4] and back
.openui-tool-glyph__block {
animation: openui-tool-glyph-slot-in 2.4s cubic-bezier(0.45, 0, 0.3, 1) infinite;
}
// terminal: cursor opacity [1, 0, 1]
.openui-tool-glyph__cursor {
animation: openui-tool-glyph-blink 0.8s steps(1) infinite;
}
// brain: each fold's pathLength / pathOffset breathe, mirrored
.openui-tool-glyph__fold {
animation: openui-tool-glyph-fold-stem 1.4s ease-in-out infinite alternate;
}
.openui-tool-glyph__fold--side {
animation-name: openui-tool-glyph-fold-side;
}
.openui-tool-glyph__fold--top {
animation-name: openui-tool-glyph-fold-top;
}
.openui-tool-glyph__fold--lower {
animation-name: openui-tool-glyph-fold-lower;
}
// badge-alert: scale [1, 1.1, …, 1], rotate [0, -3, 3, -2, 2, 0]
.openui-tool-glyph__badge {
animation: openui-tool-glyph-shake 2.4s ease-in-out infinite;
}
}
@keyframes openui-tool-glyph-hop {
0% {
transform: translate(0, 0);
}
16% {
transform: translate(0, -4px);
}
33% {
transform: translate(-3px, 0);
}
50%,
100% {
transform: translate(0, 0);
}
}
@keyframes openui-tool-glyph-pop {
0% {
transform: scale(0);
}
14% {
transform: scale(1.25);
}
22%,
100% {
transform: scale(1);
}
}
@keyframes openui-tool-glyph-draw {
0%,
10% {
stroke-dashoffset: 1;
}
45%,
100% {
stroke-dashoffset: 0;
}
}
@keyframes openui-tool-glyph-wiggle {
0%,
50%,
100% {
transform: translate(0, 0);
}
10%,
30% {
transform: translate(-1px, -1px);
}
20%,
40% {
transform: translate(1px, 1px);
}
}
@keyframes openui-tool-glyph-fade-in {
0% {
opacity: 0;
}
12%,
100% {
opacity: 1;
}
}
@keyframes openui-tool-glyph-slot-in {
0%,
12%,
84%,
100% {
transform: translate(0, 0);
}
36%,
60% {
transform: translate(-4px, 4px);
}
}
@keyframes openui-tool-glyph-blink {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
@keyframes openui-tool-glyph-fold-stem {
to {
stroke-dasharray: 0.4 1;
stroke-dashoffset: -0.25;
}
}
@keyframes openui-tool-glyph-fold-side {
to {
stroke-dasharray: 0.5 1;
stroke-dashoffset: -0.25;
}
}
@keyframes openui-tool-glyph-fold-top {
to {
stroke-dasharray: 0.8 1;
stroke-dashoffset: -0.07;
}
}
@keyframes openui-tool-glyph-fold-lower {
to {
stroke-dasharray: 0.8 1;
stroke-dashoffset: -0.14;
}
}
@keyframes openui-tool-glyph-shake {
0%,
25%,
100% {
transform: scale(1) rotate(0);
}
5% {
transform: scale(1.1) rotate(-3deg);
}
10% {
transform: scale(1.1) rotate(3deg);
}
15% {
transform: scale(1.1) rotate(-2deg);
}
20% {
transform: scale(1.1) rotate(2deg);
}
}
// ── Reduced motion ──
// Honor `prefers-reduced-motion: reduce`: stop the looping glyphs and text
// shimmer (the shimmer also paints text via a clipped gradient, so reset it to a
// solid fill or it would freeze half-transparent), drop the row fade-in and the
// header slide, and disable the decorative chevron/hover transitions.
@media (prefers-reduced-motion: reduce) {
.openui-behind-the-scenes__item,
.openui-behind-the-scenes__ticker-item--in,
.openui-behind-the-scenes__ticker-item--out,
.openui-tool-glyph.openui-tool-glyph--animate *,
.openui-tool-call__icon--blinking {
animation: none;
}
.openui-tool-call__name--shimmer,
.openui-behind-the-scenes__toggle-label--shimmer,
.openui-tool-code-block__label--loading {
animation: none;
background-image: none;
-webkit-text-fill-color: currentColor;
}
.openui-tool-code-block__label--loading {
color: cssUtils.$text-neutral-secondary;
}
.openui-behind-the-scenes__toggle-icon,
.openui-behind-the-scenes__collapse,
.openui-tool-call__chevron,
.openui-tool-call__source,
.openui-tool-code-block,
.openui-tool-code-block__chevron {
transition: none;
}
}