UI Component Library
Relevant source files
The following files were used as context for generating this wiki page: - [apps/web/components.json](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/components.json) - [apps/web/src/app/globals.css](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/app/globals.css) - [apps/web/package.json](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/package.json) - [apps/web/src/components/ui/tabs.tsx](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/components/ui/tabs.tsx) - [apps/web/src/components/ai-elements/tool.tsx](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/components/ai-elements/tool.tsx) - [apps/web/src/components/ai-elements/response.tsx](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/components/ai-elements/response.tsx) - [apps/web/src/app/layout.tsx](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/app/layout.tsx) - [apps/web/src/components/landing-page/legal/text.tsx](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/components/landing-page/legal/text.tsx) - [apps/web/src/components/ai-elements/code-block.tsx](https://github.com/analogdotnow/Analog/blob/HEAD/apps/web/src/components/ai-elements/code-block.tsx)The Analog UI Component Library is a collection of reusable React components built to create a consistent and modern user interface for the web application. It is based on shadcn/ui, which utilizes Radix UI primitives for accessibility and Tailwind CSS for styling. This architecture provides a flexible, themeable, and maintainable system for UI development.
The library includes standard UI elements like tabs and buttons, as well as specialized components designed for displaying AI-generated content, including tool usage, markdown responses, and inline citations. The entire system is configured for both light and dark modes through a CSS variable-based theming approach.
Core Technologies and Configuration
The UI library is built upon a stack of modern front-end technologies. The relationship between these technologies is key to understanding how components are built and styled.
This diagram illustrates the foundational layers of the UI component library.
shadcn/ui Configuration
The project uses shadcn/ui for its component infrastructure. The configuration is defined in components.json, which specifies the styling, component paths, and other defaults.
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true
},
"iconLibrary": "lucide",
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"hooks": "@/hooks",
"lib": "@/lib",
"ui": "@/components/ui"
}
}
Sources: apps/web/components.json
Key configuration details:
| Property | Value | Description |
|---|---|---|
style | new-york | The visual style preset for the components. |
rsc | true | Indicates that components are compatible with React Server Components. |
tailwind.css | src/app/globals.css | The entry point for global CSS and Tailwind directives. |
tailwind.baseColor | neutral | The base color palette used for generating shades. |
tailwind.cssVariables | true | Enables the use of CSS variables for theming. |
iconLibrary | lucide | The default icon library is lucide-react. |
aliases | (object) | Path aliases for easy import of components and utilities. |
Sources: apps/web/components.json
Key Dependencies
The package.json file lists the core dependencies that power the UI component library.
| Package | Version | Purpose |
|---|---|---|
@radix-ui/react-* | ^1.x | A collection of unstyled, accessible UI primitives (e.g., Dialog, Tabs, Popover). |
tailwindcss | ^4.1.12 | A utility-first CSS framework for styling. |
lucide-react | ^0.542.0 | Provides the icon set used across the application. |
class-variance-authority | ^0.7.1 | Manages component variants for different styles and states. |
tailwind-merge | ^3.3.1 | Merges Tailwind CSS classes without style conflicts. |
next-themes | ^0.4.6 | Manages theme switching (light/dark mode). |
Sources: apps/web/package.json:18-50
Theming and Styling
The application supports both light and dark themes using a CSS variable-driven approach defined in globals.css.
CSS Variables
The :root selector defines variables for the default (light) theme, while the .dark class overrides them for the dark theme. This allows components to adapt their appearance based on the active theme.
This flow shows how theme styles are applied.
Sources: apps/web/src/app/globals.css:33-142
Example Light Theme Variables:
:root,
.light {
--background: var(--color-white);
--foreground: var(--color-neutral-950);
--primary: var(--color-neutral-900);
--secondary: var(--color-neutral-100);
--muted: var(--color-neutral-100);
--accent: var(--color-neutral-100);
--destructive: var(--color-red-600);
--border: var(--color-neutral-200);
--input: var(--color-neutral-200);
--ring: var(--color-neutral-400);
--radius: 0.625rem;
}
Sources: apps/web/src/app/globals.css:33-58
Example Dark Theme Variables:
.dark {
--background: var(--color-neutral-900);
--foreground: var(--color-neutral-50);
--primary: var(--color-neutral-200);
--secondary: var(--color-neutral-800);
--muted: var(--color-neutral-800);
--accent: var(--color-neutral-700);
--destructive: var(--color-red-400);
--border: color-mix(
in oklch,
var(--color-neutral-800) 50%,
var(--color-neutral-700)
);
--input: color-mix(
in oklch,
var(--color-neutral-800) 50%,
var(--color-neutral-700)
);
--ring: var(--color-neutral-500);
}
Sources: apps/web/src/app/globals.css:82-111
Fonts
The application uses custom fonts defined in layout.tsx. The primary sans-serif font is Geist, the mono font is Geist Mono, and an additional variable font Satoshi is also included. These are made available via CSS variables (--font-geist-sans, --font-geist-mono, --font-satoshi).
Sources: apps/web/src/app/layout.tsx:13-28
Component Architecture
Components are built as reusable React components, typically wrapping a Radix UI primitive and styled with Tailwind CSS via the cn utility function, which combines clsx and tailwind-merge.
Standard UI Components
These are general-purpose components located in apps/web/src/components/ui/. An example is the Tabs component.
Example: Tabs Component
The Tabs component is composed of several sub-components that wrap @radix-ui/react-tabs primitives.
This diagram shows the composition of the Tabs component.
Sources: apps/web/src/components/ui/tabs.tsx
The TabsTrigger component demonstrates how styles are applied conditionally based on the component's state (data-[state=active]).
// File: apps/web/src/components/ui/tabs.tsx:32-41
function TabsTrigger({
className,
...props
}: React.ComponentProps<typeof TabsPrimitive.Trigger>) {
return (
<TabsPrimitive.Trigger
data-slot="tabs-trigger"
className={cn(
"...",
"data-[state=active]:bg-background data-[state=active]:shadow-sm dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground",
className,
)}
{...props}
/>
);
}
Sources: apps/web/src/components/ui/tabs.tsx:32-41
Specialized Components
The application contains several groups of specialized components for specific features, such as rendering AI interactions or legal text.
AI Elements (ai-elements)
This directory contains components purpose-built for displaying content from and interactions with an AI.
-
ToolComponent: Displays the status and results of an AI tool call. It is a collapsible component showing parameters and output.- States: The component visually represents the tool's lifecycle with different badges and icons.
| State | Label | Icon | Description |
| :--- | :--- | :--- | :--- |
|input-streaming| Pending |CircleIcon| The tool is awaiting input. |
|input-available| Running |ClockIcon| The tool has received input and is processing. |
|output-available| Completed |CheckCircleIcon| The tool has successfully produced output. |
|output-error| Error |XCircleIcon| The tool encountered an error. |
Sources: apps/web/src/components/ai-elements/tool.tsx:29-45
- States: The component visually represents the tool's lifecycle with different badges and icons.
-
ResponseComponent: A security-hardened React Markdown renderer for displaying AI-generated text.- It uses
harden-react-markdownto prevent XSS vulnerabilities. - It supports GitHub Flavored Markdown (
remark-gfm), math equations (remark-math,rehype-katex), and custom styling for HTML elements like headings, lists, and links. - It includes a custom renderer for
pretags to integrate theCodeBlockcomponent for syntax highlighting.
Sources: apps/web/src/components/ai-elements/response.tsx:191-255
- It uses
-
CodeBlockComponent: Renders code with syntax highlighting usingreact-syntax-highlighter.- It supports both light (
oneLight) and dark (oneDark) themes, automatically switching based on the CSS context. - It includes a
CodeBlockCopyButtonfor easily copying the code to the clipboard.
Sources: apps/web/src/components/ai-elements/code-block.tsx:29-87
- It supports both light (
Legal Text Components
Located in apps/web/src/components/landing-page/legal/text.tsx, these components provide consistent styling for legal documents like the Privacy Policy and Terms of Service. They include LegalHeading1, LegalHeading2, LegalParagraph, LegalTextLink, and LegalList.
Sources: apps/web/src/components/landing-page/legal/text.tsx
Summary
The Analog UI Component Library is a robust and well-architected system that leverages the power of shadcn/ui, Radix, and Tailwind CSS. Its foundation on CSS variables provides excellent themeability, while the component-based architecture ensures reusability and consistency. The inclusion of specialized components for AI interactions and other specific content types demonstrates a thoughtful approach to building a complex, modern web application.