Documentation Index
Fetch the complete documentation index at: https://mintlify.com/danielitoCode/compose_svelted/llms.txt
Use this file to discover all available pages before exploring further.
These examples demonstrate two production-ready login screen patterns built entirely with Compose Svelted components. The Simple Login follows a clean Material-style card layout centred on the viewport, while the Rich Login layers a full-screen background image behind a translucent overlay and a frosted-glass card — both using the same declarative component model.
The simple login screen uses a minimal set of components to produce a focused, accessible form. A Box centres everything on screen, a Surface provides the card background, and a Column stacks the header, form fields, and action button with consistent spacing.<script>
import {
Alignment,
Arrangement,
Box,
Button,
ColorScheme,
Column,
Icon,
Modifier,
Row,
Surface,
Text,
TextField,
TextStyle,
} from "@danielito1996/compose-svelted";
let name = "";
let pass = "";
</script>
<Box
contentAlignment={Alignment.Center}
modifier={Modifier.fillMaxSize().background(ColorScheme.Background)}
>
<Surface color={ColorScheme.Surface}>
<Column
horizontalAlignment={Alignment.CenterVertically}
verticalArrangement={Arrangement.spacedBy(20)}
modifier={Modifier.padding(32)}
>
<!-- Header -->
<Column
horizontalAlignment={Alignment.CenterVertically}
verticalArrangement={Arrangement.spacedBy(8)}
>
<Text textStyle={TextStyle.HeadlineMedium}>Bienvenido 👋</Text>
<Text textStyle={TextStyle.BodyMedium}>
Accede a tu cuenta para continuar
</Text>
</Column>
<!-- Form -->
<Column
verticalArrangement={Arrangement.spacedBy(16)}
modifier={Modifier.fillMaxWidth()}
>
<TextField
value={name}
onValueChange={value => (name = value)}
label="Email"
/>
<TextField
value={pass}
onValueChange={value => (pass = value)}
label="Contraseña"
/>
</Column>
<!-- Action -->
<Button modifier={Modifier.fillMaxWidth()}>
<Row
horizontalArrangement={Arrangement.spacedBy(10)}
verticalAlignment={Alignment.CenterVertically}
>
<Icon
painter="https://cdn.jsdelivr.net/npm/@mdi/svg/svg/login.svg"
tint={ColorScheme.OnPrimary}
modifier={Modifier.size(18)}
/>
<Text color={ColorScheme.OnPrimary}>Iniciar sesión</Text>
</Row>
</Button>
<!-- Footer -->
<Text textStyle={TextStyle.BodyMedium}>
compose-svelted · UI declarativa
</Text>
</Column>
</Surface>
</Box>
How each piece fits together:| Component | Role |
|---|
Box with contentAlignment={Alignment.Center} | Full-screen centering container; fills the viewport and places its single child in the exact middle |
Modifier.fillMaxSize().background(ColorScheme.Background) | Stretches the Box to the full viewport and paints it with the active theme’s background colour |
Surface | Elevated card that inherits ColorScheme.Surface; provides the card’s background and Material elevation |
Column with Arrangement.spacedBy(20) | Stacks header, form, and button vertically with 20 px gaps between each group |
TextField with onValueChange | Controlled text input — each keystroke calls the handler and updates the bound $state variable |
Button + Row inside | The action button uses an inner Row to align an Icon and Text side by side with a 10 px gap |
The rich login screen uses the overlay pattern: a full-bleed Box stacks an Image (background) and a second Box (dark overlay) on top of each other. The login card sits at the centre of the overlay, making the form readable regardless of the background content.<script lang="ts">
import {
Alignment,
Arrangement,
Box,
Button,
ColorScheme,
Column,
ContentScale,
Image,
Modifier,
RoundedCornerShape,
Row,
Surface,
Text,
TextField,
TextStyle,
} from "@danielito1996/compose-svelted";
let email = "";
let password = "";
</script>
<Box modifier={Modifier.fillMaxSize()}>
<!-- Background image — fills and crops to fill the full viewport -->
<Image
painter="https://images.unsplash.com/photo-1519389950473-47ba0277781c"
contentDescription="Background"
contentScale={ContentScale.Crop}
modifier={Modifier.fillMaxSize()}
/>
<!-- Dark overlay + centred card -->
<Box
contentAlignment={Alignment.Center}
modifier={Modifier
.fillMaxSize()
.background("rgba(0,0,0,0.45)")
.align(Alignment.Center)}
>
<Surface
color={ColorScheme.Surface}
modifier={Modifier.padding(24).clip(RoundedCornerShape(30))}
>
<Column
horizontalAlignment={Alignment.CenterVertically}
verticalArrangement={Arrangement.spacedBy(28)}
modifier={Modifier.padding(36)}
>
<!-- Brand -->
<Column
horizontalAlignment={Alignment.CenterVertically}
verticalArrangement={Arrangement.spacedBy(12)}
>
<Image
painter="https://upload.wikimedia.org/wikipedia/commons/3/33/Figma-logo.svg"
contentDescription="Logo"
contentScale={ContentScale.Fit}
modifier={Modifier.size(56)}
/>
<Text textStyle={TextStyle.HeadlineMedium}>Iniciar sesión</Text>
<Text textStyle={TextStyle.BodyMedium}>Accede a tu cuenta</Text>
</Column>
<!-- Form -->
<Column
verticalArrangement={Arrangement.spacedBy(16)}
modifier={Modifier.fillMaxWidth()}
>
<TextField
value={email}
onValueChange={v => (email = v)}
label="Email"
/>
<TextField
value={password}
onValueChange={v => (password = v)}
label="Contraseña"
/>
</Column>
<!-- Action -->
<Button modifier={Modifier.fillMaxWidth()}>
<Row
horizontalArrangement={Arrangement.spacedBy(10)}
verticalAlignment={Alignment.CenterVertically}
>
<Image
painter="https://cdn.jsdelivr.net/npm/@mdi/svg/svg/login.svg"
contentDescription="Login"
contentScale={ContentScale.Fit}
modifier={Modifier.size(18)}
/>
<Text>Acceder</Text>
</Row>
</Button>
<Text textStyle={TextStyle.BodyMedium}>
compose-svelted · UI declarativa
</Text>
</Column>
</Surface>
</Box>
</Box>
The overlay pattern explained:The outermost Box stacks its children like layers in a design tool — each child is drawn on top of the previous one, both filling Modifier.fillMaxSize().
Image (layer 1) — ContentScale.Crop ensures the image always fills the full viewport without letterboxing, regardless of the image’s aspect ratio.
Box with rgba(0,0,0,0.45) (layer 2) — A semi-transparent black overlay dims the background just enough to guarantee contrast for white text and the card.
Surface inside the overlay — RoundedCornerShape(30) gives the card rounded corners, and Modifier.padding(24) adds breathing room between the overlay edge and the card border.
Both screens are taken directly from the Compose Svelted playground and represent real-world usage patterns. You can find the originals at playground/src/samples/CustomLogin.svelte and playground/src/samples/ProfesionalLogin.svelte in the repository.
Wrap the Surface card in AnimatedVisibility to animate it appearing when the page loads. Import fadeIn and fadeOut alongside AnimatedVisibility and bind the visible prop to a boolean — set it to true so the enter animation plays immediately on mount:<script>
import {
AnimatedVisibility,
fadeIn,
fadeOut,
} from "@danielito1996/compose-svelted";
let showLogin = true;
</script>
<AnimatedVisibility visible={showLogin} enter={fadeIn()} exit={fadeOut()}>
<Surface ...>
<!-- form fields -->
</Surface>
</AnimatedVisibility>
See ProfesionalLoginWithAnimation.svelte in the playground for a complete working example.