This document provides detailed information about the UI components available in the Summon library. All components are built with type-safe styling, accessibility features, and cross-platform compatibility.
- Foundation Components
- Layout Components
- Display Components
- Input Components
- Feedback Components
- Navigation Components
- Styling Components
- HTML DSL Components ⭐ NEW (v0.7.0)
- Desktop Components ⭐ NEW (v0.7.0)
- Component Architecture
Foundation components (package codes.yousef.summon.components.foundation) provide theming and other low-level building
blocks shared across the design system.
Provides theme context to child components.
@Composable
fun ThemeProvider(
theme: Theme,
content: @Composable () -> Unit
)Low-level text rendering component used internally by other text components.
@Composable
fun BasicText(
text: String,
modifier: Modifier = Modifier()
)Layout components help organize and structure your UI.
Arranges children vertically using CSS flexbox.
@Composable
fun Column(
modifier: Modifier = Modifier(),
content: @Composable () -> Unit
)Example:
Column {
Text("First item")
Text("Second item")
Button(onClick = { }, label = "Action")
}Arranges children horizontally using CSS flexbox.
@Composable
fun Row(
modifier: Modifier = Modifier(),
content: @Composable () -> Unit
)A container that positions children relative to each other.
@Composable
fun Box(
modifier: Modifier = Modifier(),
content: @Composable () -> Unit
)CSS Grid layout for complex arrangements.
@Composable
fun Grid(
modifier: Modifier = Modifier(),
columns: String = "1fr",
rows: String = "auto",
gap: String = "8px",
content: @Composable () -> Unit
)Adds space between components.
@Composable
fun Spacer(
modifier: Modifier = Modifier(),
width: String? = null,
height: String? = null
)Components for displaying content to users.
Primary component for displaying text with extensive styling options.
@Composable
fun Text(
text: String,
modifier: Modifier = Modifier(),
overflow: String? = null,
lineHeight: String? = null,
textAlign: String? = null,
fontFamily: String? = null,
textDecoration: String? = null,
textTransform: String? = null,
letterSpacing: String? = null,
whiteSpace: String? = null,
wordBreak: String? = null,
wordSpacing: String? = null,
textShadow: String? = null,
maxLines: Int? = null,
role: String? = null,
ariaLabel: String? = null,
ariaDescribedBy: String? = null,
semantic: String? = null
)Example:
Text(
text = "Hello World",
modifier = Modifier().color("#333").fontSize("18px"),
textAlign = "center",
maxLines = 2
)Semantic label component for form controls.
@Composable
fun Label(
text: String,
modifier: Modifier = Modifier(),
forElement: String? = null
)Display icons from various icon sets.
@Composable
fun Icon(
name: String,
modifier: Modifier = Modifier(),
size: String = "24px",
color: String? = null
)Display images with loading states and accessibility features.
@Composable
fun Image(
src: String,
alt: String,
modifier: Modifier = Modifier(),
loading: String = "lazy",
width: String? = null,
height: String? = null
)Display rich formatted text content.
@Composable
fun RichText(
content: String,
modifier: Modifier = Modifier(),
sanitize: Boolean = true
)Interactive components for user input.
Versatile button component with multiple variants.
@Composable
fun Button(
onClick: () -> Unit,
label: String,
modifier: Modifier = Modifier(),
variant: ButtonVariant = ButtonVariant.PRIMARY,
disabled: Boolean = false,
iconName: String? = null,
iconPosition: IconPosition = IconPosition.START
)
enum class ButtonVariant {
PRIMARY, SECONDARY, TERTIARY, DANGER, SUCCESS, WARNING, INFO, LINK, GHOST
}
enum class IconPosition { START, END }Example:
Button(
onClick = { println("Clicked!") },
label = "Download",
variant = ButtonVariant.SUCCESS,
iconName = "download",
iconPosition = IconPosition.START
)Text input field with validation support.
@Composable
fun TextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier(),
placeholder: String? = null,
label: String? = null,
type: TextFieldType = TextFieldType.Text,
isError: Boolean = false,
isEnabled: Boolean = true,
isReadOnly: Boolean = false,
validators: List<Validator> = emptyList()
)| Parameter | Type | Default | Description |
|---|---|---|---|
value |
String |
required | The current text value |
onValueChange |
(String) -> Unit |
required | Callback invoked when input changes |
modifier |
Modifier |
Modifier() |
Styling and attributes |
placeholder |
String? |
null |
Placeholder text when empty |
label |
String? |
null |
Label text for the field |
type |
TextFieldType |
TextFieldType.Text |
Input type (Text, Password, Email, etc.) |
isError |
Boolean |
false |
Whether to show error state |
isEnabled |
Boolean |
true |
Whether the field is enabled |
isReadOnly |
Boolean |
false |
Whether the field is read-only |
validators |
List<Validator> |
emptyList() |
Validators to apply |
A minimal text input field without validation state. Safe for JS minification scenarios where state capture in callbacks can cause issues.
@Composable
fun BasicTextField(
value: String,
onValueChange: (String) -> Unit,
modifier: Modifier = Modifier(),
placeholder: String? = null,
type: String = "text"
)Use BasicTextField when:
- You need a simple input without validation
- You're experiencing issues with minified JS builds
- You want direct pass-through to the renderer without internal state
A stateful version that manages its own state internally.
@Composable
fun StatefulTextField(
initialValue: String = "",
onValueChange: (String) -> Unit = {},
modifier: Modifier = Modifier(),
placeholder: String? = null,
label: String? = null,
type: TextFieldType = TextFieldType.Text,
isError: Boolean = false,
isEnabled: Boolean = true,
isReadOnly: Boolean = false,
validators: List<Validator> = emptyList()
)Checkbox input with tri-state support.
@Composable
fun Checkbox(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
modifier: Modifier = Modifier(),
label: String? = null,
disabled: Boolean = false,
indeterminate: Boolean = false
)Radio button for exclusive selections.
@Composable
fun RadioButton(
selected: Boolean,
onClick: () -> Unit,
modifier: Modifier = Modifier(),
label: String? = null,
disabled: Boolean = false,
name: String? = null
)Dropdown selection component.
@Composable
fun Select(
value: String,
onValueChange: (String) -> Unit,
options: List<SelectOption>,
modifier: Modifier = Modifier(),
placeholder: String = "Select an option",
disabled: Boolean = false,
searchable: Boolean = false
)
data class SelectOption(
val value: String,
val label: String,
val disabled: Boolean = false
)Slider for numeric range selection.
@Composable
fun RangeSlider(
value: Float,
onValueChange: (Float) -> Unit,
modifier: Modifier = Modifier(),
min: Float = 0f,
max: Float = 100f,
step: Float = 1f,
disabled: Boolean = false
)Form containers with validation support.
@Composable
fun Form(
modifier: Modifier = Modifier(),
onSubmit: () -> Unit,
content: @Composable () -> Unit
)
@Composable
fun FormField(
modifier: Modifier = Modifier(),
label: String? = null,
error: String? = null,
required: Boolean = false,
content: @Composable () -> Unit
)File upload component with drag-and-drop support.
@Composable
fun FileUpload(
onFilesSelected: (List<FileInfo>) -> Unit,
modifier: Modifier = Modifier(),
acceptedTypes: List<String> = emptyList(),
maxFiles: Int = 1,
maxSizeBytes: Long? = null,
disabled: Boolean = false
)
data class FileInfo(
val name: String,
val size: Long,
val type: String,
val lastModified: Long
)Date selection component.
@Composable
fun DatePicker(
value: String?,
onValueChange: (String?) -> Unit,
modifier: Modifier = Modifier(),
format: String = "yyyy-MM-dd",
min: String? = null,
max: String? = null,
disabled: Boolean = false
)Components that provide user feedback and status information.
Display important messages to users.
@Composable
fun Alert(
message: String,
modifier: Modifier = Modifier(),
variant: AlertVariant = AlertVariant.INFO,
dismissible: Boolean = false,
onDismiss: (() -> Unit)? = null,
title: String? = null,
icon: String? = null
)
enum class AlertVariant { SUCCESS, INFO, WARNING, ERROR }Small status indicators.
@Composable
fun Badge(
text: String,
modifier: Modifier = Modifier(),
variant: BadgeVariant = BadgeVariant.DEFAULT,
size: BadgeSize = BadgeSize.MEDIUM
)Loading indicators and spinners.
@Composable
fun Loading(
modifier: Modifier = Modifier(),
size: String = "24px",
color: String = "currentColor",
type: LoadingType = LoadingType.SPINNER
)Modal dialogs and overlays.
@Composable
fun Modal(
isVisible: Boolean,
onDismiss: () -> Unit,
modifier: Modifier = Modifier(),
title: String? = null,
content: @Composable () -> Unit
)Progress bars and indicators.
@Composable
fun Progress(
value: Float,
modifier: Modifier = Modifier(),
max: Float = 100f,
showLabel: Boolean = false,
variant: ProgressVariant = ProgressVariant.DETERMINATE
)Linear progress indicator.
@Composable
fun ProgressBar(
progress: Float,
modifier: Modifier = Modifier(),
backgroundColor: String = "#e0e0e0",
progressColor: String = "#2196f3",
height: String = "8px"
)Temporary messages and notifications.
@Composable
fun Snackbar(
message: String,
modifier: Modifier = Modifier(),
action: String? = null,
onActionClick: (() -> Unit)? = null,
onDismiss: (() -> Unit)? = null,
duration: SnackbarDuration = SnackbarDuration.SHORT
)
@Composable
fun SnackbarHost(
modifier: Modifier = Modifier()
)Toast notifications.
@Composable
fun Toast(
message: String,
modifier: Modifier = Modifier(),
type: ToastType = ToastType.INFO,
duration: Long = 3000L,
position: ToastPosition = ToastPosition.BOTTOM_CENTER
)Contextual help information.
@Composable
fun Tooltip(
text: String,
modifier: Modifier = Modifier(),
position: TooltipPosition = TooltipPosition.TOP,
content: @Composable () -> Unit
)Components for navigation and routing.
Navigation links with routing + hydration support.
@Composable
fun Link(
href: String,
modifier: Modifier = Modifier(),
target: String? = null,
rel: String? = null,
title: String? = null,
isExternal: Boolean = false,
isNoFollow: Boolean = false,
ariaLabel: String? = null,
ariaDescribedBy: String? = null,
id: String? = null,
dataHref: String? = null,
dataAttributes: Map<String, String> = emptyMap(),
navigationMode: LinkNavigationMode = LinkNavigationMode.Native,
fallbackText: String? = null,
content: @Composable () -> Unit
)
enum class LinkNavigationMode {
Native,
Client
}navigationMode = LinkNavigationMode.Clientrewrites the renderedhrefto#and mirrors the original path intodata-href, which the hydration runtime (and existing Aurora scripts) already watches for smooth client-side scrolls.fallbackTextlets you intentionally inject server-rendered copy for non-hydrated environments; whennull, Summon no longer mirrors the originalhrefas fallback text, so custom children render without duplicate labels.
Tab-based navigation.
@Composable
fun TabLayout(
selectedIndex: Int,
onTabSelected: (Int) -> Unit,
modifier: Modifier = Modifier(),
tabs: List<TabItem>
)
data class TabItem(
val label: String,
val content: @Composable () -> Unit,
val disabled: Boolean = false,
val icon: String? = null
)Components that manage global CSS and animation styling concerns live under codes.yousef.summon.components.styles.
Apply global CSS styles to the document.
@Composable
fun GlobalStyle(
css: String
)Complete HTML5 semantic elements for building accessible, SEO-friendly pages. Added in v0.7.0.
Package: codes.yousef.summon.components.html
For full documentation, see the HTML DSL API Reference.
The HTML DSL provides composable functions that render actual HTML5 semantic elements:
| Category | Elements |
|---|---|
| Structural | Header, Nav, Main, Footer, Section, Article, Aside, Address, Hgroup, Search |
| Text | H1-H6, P, Blockquote, Pre, Code, Strong, Em, Small, Mark, Del, Ins, Sub, Sup, S, U, B, I |
| Lists | Ul, Ol, Li, Dl, Dt, Dd, Menu |
| Tables | Table, Thead, Tbody, Tfoot, Tr, Th, Td, Caption, Colgroup, Col |
| Interactive | Details, Summary, Dialog |
| Inline | A, Span, Time, Abbr, Cite, Q, Kbd, Samp, Var, Dfn, Data, Bdi, Bdo, Ruby, Rt, Rp, Wbr, Br |
| Media | Figure, Figcaption, Iframe, Embed, ObjectTag, Param, Source, Track, Audio, Meter |
Article {
Header {
H1 { Text("Article Title") }
Time(datetime = "2026-02-05") { Text("February 5, 2026") }
}
Section {
H2 { Text("Introduction") }
P { Text("This is a semantic HTML article...") }
Blockquote(cite = "https://example.com") {
P { Text("A notable quote from an expert.") }
}
}
Details {
Summary { Text("Read more") }
P { Text("Hidden content revealed when expanded.") }
}
Footer {
Small { Text("Copyright 2026") }
}
}Desktop-like functionality for web applications. Added in v0.7.0.
Package: codes.yousef.summon.desktop
For full documentation, see the Desktop Features API Reference.
| Feature | Package | Description |
|---|---|---|
| WindowManager | .window |
Open/manage browser windows and tabs |
| BroadcastChannel | .communication |
Cross-tab real-time messaging |
| SyncedStorage | .storage |
Cross-tab reactive state persistence |
| FileDialog | .dialog |
Native file picker dialogs |
| MenuBar | .menu |
Application menu bar component |
| SystemTray | .tray |
Web notifications (tray icon stub) |
| DragCoordinator | .communication |
Cross-window drag and drop |
| PictureInPicture | .pip |
Floating PiP windows |
// Menu bar with keyboard shortcuts
MenuBar {
menu("File") {
item("New", shortcut = KeyboardShortcut("N", ctrl = true)) { createNew() }
item("Open", shortcut = KeyboardShortcut("O", ctrl = true)) { openFile() }
separator()
item("Exit") { exit() }
}
}
// Cross-tab synced state
@Composable
fun ThemeSwitcher() {
val theme = rememberSyncedString("theme", "light")
Button(onClick = { theme.value = if (theme.value == "light") "dark" else "light" }) {
Text("Theme: ${theme.value}")
}
}
// Cross-tab messaging
val channel = createBroadcastChannel("my-app")
channel.postMessage("Hello from this tab!")All components use the Modifier system for styling and behavior:
// Type-safe styling
Button(
onClick = { },
label = "Click Me",
modifier = Modifier()
.padding("16px")
.backgroundColor("#007bff")
.borderRadius("4px")
.hover(
Modifier().backgroundColor("#0056b3")
)
)Components include built-in accessibility features:
- ARIA attributes and roles
- Keyboard navigation support
- Screen reader compatibility
- Focus management
- Semantic HTML elements
All components work through the platform renderer system:
@Composable
fun MyComponent() {
val renderer = LocalPlatformRenderer.current
// Component uses renderer for platform-specific output
}Components support event handling through lambda callbacks:
Button(
onClick = { println("Clicked!") },
label = "Click Me"
)
TextField(
value = state.value,
onValueChange = { state.value = it }
)- Use semantic components: Choose the right component for the content (e.g.,
Labelfor form labels,Textfor general text) - Apply accessibility: Use ARIA attributes and semantic HTML when needed
- Style with Modifier: Use the type-safe Modifier system instead of inline styles
- Handle errors gracefully: Provide error states and validation feedback
- Keep components focused: Each component should have a single, clear purpose
- Use composition: Combine simple components to build complex UIs
- Test across platforms: Ensure components work on both JVM and JS targets
When upgrading from older versions:
- Replace deprecated
TextComponentclass usage withTextcomposable function - Update modifier chains to use type-safe enums where available
- Check component signatures for new required or optional parameters
- Modifier API - Type-safe styling system
- State API - State management for components
- Theme API - Theming and design system
- Accessibility API - Accessibility features and guidelines