Files
llama.cpp/ui/apps/chat/src/app.css
T
Aleksander Grygier b81aa847c2 ui: slim the design tokens and set all text through type roles (#32615)
* ui: drop component tokens that only alias a semantic token

A component token now exists only for what a component decides itself:
a value no semantic token has, or one that only this component changes
between themes. Components that take a semantic token as it is read it
directly, so 88 of the 118 component tokens go, with no change to what
is drawn.

Also drops semantic tokens that repeat another one (status-* is fill-*,
elevation-tooltip is elevation-surface), the unused info lamp tokens and
14 primitives nothing reads, and adds fg-soft for the label of an option
that is not the picked one (tabs, toggle group).

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a short summary on top of DESIGN.md

The rules most changes need, in one screen: components, colour, type,
shape, sizes, surfaces, tokens and no arbitrary values. The sections
below keep the detail.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: derive design tokens by rule and drop the alias layers

Semantic tokens are either a pick (a primitive per theme) or a derivation,
mixed from another semantic token by a fixed rule and declared once: hover
fills, status surfaces and lines, dark shadows (--elevation-strength), the
middle of a matte edge, a lamp's rim and glyph.

Primitives keep colours only. shadcn's colour names stay as Tailwind
utilities and no longer exist as variables; neutral semantic utilities that
duplicated them are gone.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: set all text through type roles and move off-scale values onto the scale

Tailwind's text sizes and bracketed sizes become the type roles, with a new
text-caption-sm (10px) for tags and counts. Body and caption roles no longer
set a weight, and line heights are written as Tailwind writes its own, so the
swap from text-sm and text-xs changes no pixel. A unit test keeps old sizes
from coming back.

Arbitrary values with a scale equivalent use it (z-20, max-w-4/5, min-w-32),
and the two easing curves repeated across the app are ease-out-quint and
ease-sheet. DESIGN.md is updated and regenerated.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: bump @ggml-org/llama-ui to 0.5.0

Removed and renamed tokens are breaking for an app that reads them.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a display type role for the biggest headline

The greeting on a new chat keeps its 30px from md up, now as text-display
instead of a Tailwind size.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: one corner scale, one set of shadows and three more derived tokens

Six corner roles named values Tailwind's rounded-md to rounded-4xl
already have, and components used the Tailwind names nine times out of
ten. The roles are gone; the whole scale is computed from --radius.

Tailwind's shadow sizes were restated next to the elevation tokens and
did not follow the theme, so they were five times fainter in dark. The
five uses take elevation tokens and a unit test keeps both from coming
back.

A button group's seam is the button's own text colour at 25%, the dark
status text is the dark status fill, and the pressed shadow scales with
--elevation-strength like the inset one.

Assisted-by: Claude (Opus 5.5 Medium)
2026-11-20 11:26:26 +01:00

391 lines
13 KiB
CSS

@import 'tailwindcss';
@source '.';
/* stories may use classes the app does not, so tailwind scans them too: the app's and Llama UI's,
which this Storybook shows as well */
@source '../tests/stories';
@source '../../../lib/ui/tests/stories';
@plugin '@tailwindcss/forms';
@plugin '@tailwindcss/typography';
@import 'tw-animate-css';
/* the brand's colours, which Llama UI's primitives build on */
@import '@ggml-org/llama-brand/css/colors.css';
/* Llama UI's theme (ui/lib/ui): fonts, tokens, surfaces, the shadcn names and the base styles
its components read. By path rather than as @ggml-org/llama-ui/theme.css: prettier's Tailwind
plugin reads this file too, and it knows no aliases */
@import '../../../lib/ui/src/lib/styles/theme.css';
@import './lib/styles/safe-area.css';
:root {
/* the page runs under the status bar and over the home indicator
(viewport-fit=cover); what is pinned to a screen edge keeps clear of them
with the pt-safe / pb-safe utilities (see lib/styles/safe-area.css) */
--safe-area-top: env(safe-area-inset-top, 0px);
--safe-area-bottom: env(safe-area-inset-bottom, 0px);
/* where the phone's corner controls (menu toggle, context gauge, sidebar logo) sit */
--corner-control-top: calc(1rem + var(--safe-area-top));
/* where a phone page's title starts: a row below the corner controls */
--page-top: calc(var(--corner-control-top) + 3.75rem);
/* expanded desktop sidebar width, overridden once the user drags its edge */
--sidebar-width: 18rem;
/* phone sidebar width, which the page slides aside to reveal */
--sidebar-reveal: min(80dvw, 20rem);
/* the desktop sidebar's muted/60 over the page, made opaque so the slid page's corners can match it */
--sidebar-reveal-tint: color-mix(in oklab, var(--surface-muted) 60%, var(--surface-page));
/* how far the phone sidebar is open, 0 to 1, stepped every frame by useSidebarReveal */
--sidebar-reveal-progress: 0;
/* the same on a log curve: the sidebar's contents hold on until the page nearly covers them */
--sidebar-reveal-ease: calc(log(1 + 9 * var(--sidebar-reveal-progress)) / log(10));
/* the page background, blending into the sidebar tint as the phone sidebar opens */
--sidebar-reveal-bg: color-mix(
in oklab,
var(--sidebar-reveal-tint) calc(var(--sidebar-reveal-progress) * 100%),
var(--surface-page)
);
--layer-popover: 1000000;
--chat-form-area-height: 8rem;
--chat-form-area-offset: 2rem;
--chat-form-padding-top: 6rem;
/* Nested surfaces, outermost first: the page, the sidebar on it, a group inset in the
sidebar (its footer) and a row in the group. A row keeps its corners concentric with the
group's: its radius is the group's less the padding between their edges. The sidebar's
actions above the footer share the row radius, so every action row rounds alike. See "Nested
surfaces" in the README; tests/client/nested-surfaces.svelte.test.ts holds the rule */
--surface-group-radius: var(--inset-group-radius);
--surface-group-padding: 0.25rem;
--surface-row-radius: calc(var(--surface-group-radius) - var(--surface-group-padding));
/* the chat form card holding one line of text, as it rests on a new chat */
--chat-form-collapsed-height: 6.375rem;
/* the empty chat form card, its text and actions in one row: a new chat centers its top edge */
--chat-form-resting-height: 3.375rem;
/* the chat form's corners while its text and actions share one row */
--chat-form-single-row-radius: 1.25rem;
/* the card's translucent fill over the page, made opaque: the phone sheet, and the page and Safari's bars around it */
--chat-form-sheet-fill: color-mix(in oklab, var(--surface-muted) 60%, var(--surface-page));
--max-message-height: max(24rem, min(80dvh, calc(100dvh - var(--chat-form-area-height) - 12rem)));
}
/* iOS 26 gives an installed app with viewport-fit=cover and a translucent status bar a
viewport short of that bar (WebKit bug 301108), but only while the page is shorter than
the screen. A page that reaches past it gets the full screen, after which this is 100%,
capped at the screen so it never scrolls; elsewhere the inset is 0 and it is 100% too. */
@media (display-mode: standalone) {
/* the installed app's status bar already sets them apart from the screen's edge */
:root {
--corner-control-top: calc(0.25rem + var(--safe-area-top));
}
html {
min-height: min(100lvh, calc(100% + var(--safe-area-top)));
}
}
@media (min-width: 640px) {
:root {
--chat-form-area-height: 24rem;
--chat-form-area-offset: 12rem;
--chat-form-padding-top: 6rem;
}
}
.dark {
--chat-form-sheet-fill: color-mix(in oklab, var(--surface-muted) 75%, var(--surface-page));
}
@layer base {
/* over the theme's page background: it blends into the sidebar tint as the phone sidebar opens */
body {
@apply bg-(--sidebar-reveal-bg);
scrollbar-width: thin;
scrollbar-gutter: stable;
}
/* While the chat form is a full-screen sheet on a phone, the page around it takes the
sheet's fill: iOS paints the installed app's status bar and home indicator areas, and
Safari tints its bars, from this background */
@media (width < 48rem) {
html[data-chat-form-sheet],
html[data-chat-form-sheet] body {
background-color: var(--chat-form-sheet-fill);
}
}
/* no elastic bounce past the ends of the page: it drags the sticky and
fixed bars (tab bar, chat form) along and they jump back on release */
html,
body {
overscroll-behavior: none;
}
/* no gray flash over a tapped control, which has its own press state, and
no text inflation when a phone turns to landscape */
html {
-webkit-tap-highlight-color: transparent;
-webkit-text-size-adjust: 100%;
text-size-adjust: 100%;
}
/* a tap clicks at once rather than waiting to see if it is a double-tap zoom */
button,
a,
[role='button'] {
touch-action: manipulation;
}
/* holding a control does not select its label or pop the link callout;
links stay selectable, as in a message they are content */
button,
[role='button'] {
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
}
/* same for dialogs, whose panels and lists scroll on their own with sticky
headers and footers. Scroll containers only: Firefox treats an
overflow-hidden box (truncated text) as one, and with `none` it would
keep the wheel from reaching the list around it */
:is([role='dialog'], [role='alertdialog']),
:is([role='dialog'], [role='alertdialog'])
:is(.overflow-auto, .overflow-y-auto, [data-slot='scroll-area-viewport']) {
overscroll-behavior: none;
}
/* Global scrollbar styling - visible only on hover */
* {
scrollbar-width: thin;
scrollbar-color: transparent transparent;
}
*:hover {
scrollbar-color: color-mix(in oklch, var(--fg-muted) 30%, transparent) transparent;
}
*::-webkit-scrollbar {
width: 6px;
height: 6px;
}
*::-webkit-scrollbar-track {
background: transparent;
}
*::-webkit-scrollbar-thumb {
background: transparent;
border-radius: 3px;
transition: background 0.2s ease;
}
*:hover::-webkit-scrollbar-thumb {
background: color-mix(in oklch, var(--fg-muted) 30%, transparent);
}
*::-webkit-scrollbar-thumb:hover {
background: color-mix(in oklch, var(--fg-muted) 50%, transparent);
}
}
@layer utilities {
.scrollbar-hide {
/* Hide scrollbar for Chrome, Safari and Opera */
&::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
-ms-overflow-style: none;
scrollbar-width: none;
}
/* Fade at the top edge of the chat, under the tab bar or a sticky header */
.chat-top-fade {
background: linear-gradient(
to bottom,
color-mix(in srgb, var(--surface-page) 100%, transparent) 25%,
color-mix(in srgb, var(--surface-page) 80%, transparent) 50%,
color-mix(in srgb, var(--surface-page) 40%, transparent) 75%,
transparent 100%
);
}
/* The same fade at the top of a phone's screen: solid behind the status bar and the row of
corner controls under it (the menu key, the chat's header), fading out below them, so the
page scrolls away under them instead of into them. It rides on the page as it slides aside
for the sidebar and stays as it is: the rounded frame over the slid page clips it. */
.status-bar-fade {
/* down to where a page's content starts (--page-top): solid to the middle of the corner
row, then a long, even fade over its lower half and on to the content */
height: var(--page-top);
background: linear-gradient(
to bottom,
var(--surface-page) calc(var(--corner-control-top) + 1.25rem),
color-mix(in srgb, var(--surface-page) 55%, transparent)
calc(var(--corner-control-top) + 2.5rem),
transparent 100%
);
}
/* iOS Safari colours the screen's top, above the page, from a solid fixed element at the
page's top edge (theme-color no longer), and shows the page through it otherwise. The
fade above is a gradient, which it does not take, so this strip under it carries the
page's colour there, as the installed app has. Safari finds it by hit-testing the top
edge, so it takes taps (pointer-events: none would hide it) and is thicker than the
10px Safari ignores; what it covers sits under the fade's solid part anyway */
.status-bar-edge {
height: 0.75rem;
background-color: var(--surface-page);
}
/* The bottom edge's counterpart, which Safari takes for its bottom toolbar the same way:
without it, it finds the chat form there and takes the form's colour */
.screen-bottom-edge {
height: 0.75rem;
background-color: var(--surface-page);
}
/* The same fade at the bottom of a phone's screen: solid behind the home indicator and
fading out above it, so the page ends softly at the screen's edge and under the chat
form instead of running out under it. It stays through the slide as the top one does */
.screen-bottom-fade {
height: calc(var(--safe-area-bottom) + 3rem);
background: linear-gradient(
to top,
var(--surface-page) var(--safe-area-bottom),
color-mix(in srgb, var(--surface-page) 60%, transparent)
calc(var(--safe-area-bottom) + 1.5rem),
transparent 100%
);
}
/* The sidebar's "Show more" row, stuck to its bottom: an opaque copy of the
panel's translucent muted tint, and a fade above it, like the one under
the tab bar, so the rows scrolling beneath end softly */
.sidebar-show-more {
--sidebar-surface: color-mix(in oklab, var(--surface-muted) 60%, var(--surface-page));
background: var(--sidebar-surface);
&::before {
content: '';
position: absolute;
inset-inline: 0;
bottom: 100%;
height: 1rem;
pointer-events: none;
background: linear-gradient(
to top,
var(--sidebar-surface) 0%,
color-mix(in srgb, var(--sidebar-surface) 60%, transparent) 50%,
transparent 100%
);
}
}
/* An opaque copy of the sidebar panel's translucent tint, under what moves
over the other sections while dragged */
.sidebar-drag-surface,
.sidebar-drag-overlay {
background: color-mix(in oklab, var(--surface-muted) 60%, var(--surface-page));
}
/* the copy of a chat row that follows the pointer, raised above the page */
.sidebar-drag-overlay {
box-shadow:
0 10px 30px -10px rgb(0 0 0 / 0.35),
0 0 0 1px color-mix(in srgb, var(--fg-default) 12%, transparent);
}
/* While something is dragged, what it passes over takes no hover: only the
sections themselves stay targets, for the drop */
body[data-sidebar-dragging] [data-sidebar-section] * {
pointer-events: none;
}
.sidebar-drag-overlay {
position: fixed;
z-index: 1000;
border-radius: 0.5rem;
pointer-events: none;
}
/* the phone sidebar's contents zoom out and fade as the page slides back over them */
.sidebar-reveal-content {
opacity: var(--sidebar-reveal-ease);
scale: calc(0.98 + 0.02 * var(--sidebar-reveal-ease));
}
/* the slid page's fixed bars, held where they sit on screen, see useSidebarReveal */
.sidebar-reveal-pin-top {
translate: 0 var(--sidebar-reveal-pin-top, 0px);
}
.sidebar-reveal-pin-bottom {
translate: 0 calc(-1 * var(--sidebar-reveal-pin-bottom, 0px));
}
@media (prefers-reduced-motion: reduce) {
.sidebar-reveal-content {
scale: none;
}
}
.shimmer-text {
background: linear-gradient(90deg, var(--fg-muted), var(--fg-default), var(--fg-muted));
background-size: 200% 100%;
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
font-weight: 500;
animation: shimmer 1s linear infinite;
}
@keyframes shimmer {
to {
background-position: -200% 0;
}
}
@media (prefers-reduced-motion: reduce) {
.shimmer-text {
animation: none;
}
}
}
/*
* Mermaid diagrams are drawn by Pele, which reads its colors from these. They sit on :root
* so the svg also inherits them inside the preview dialog's shadow root, and follow the theme.
*/
:root {
--pele-bg: var(--surface-code);
--pele-fg: var(--fg-code);
--pele-muted: var(--fg-muted);
--pele-line: var(--fg-muted);
--pele-surface: var(--surface-page);
--pele-surface-alt: var(--surface-muted);
--pele-border: var(--line-default);
--pele-accent: var(--action-primary);
--pele-critical: var(--fg-danger);
--pele-error: var(--fg-danger);
--pele-radius: calc(var(--radius) - 4px);
}
/*
* While the page sticks to its bottom, the pin after the messages is its only
* scroll anchor, so the browser keeps the bottom in place as content above it
* grows or realizes its size. Browsers without overflow-anchor (WebKit) never
* get the attribute, see createStickToBottom.
*/
[data-stick-to-bottom] * {
overflow-anchor: none;
}
[data-stick-to-bottom] *:has(.stick-to-bottom-pin),
[data-stick-to-bottom] .stick-to-bottom-pin {
overflow-anchor: auto;
}
.stick-to-bottom-pin {
height: 1px;
}