Slint · Slint components

This page shows the Slint implementation. Slint components written for native Rust applications and the browser. Browse the catalog, run each live example, and copy the .slint source into your own app.

Card

Card is a presentational container for grouping related content: a heading, supporting text, a body, and an optional footer.

Install

Use GroupBox when the region is a labeled cluster of controls. Use Card when the region is a content surface with a heading and actions.

#Import

use gpui_kit::component::card::{
    Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle,
};
// Installed in ui/components. That directory is on the Slint include path, so import by file name:
import { Card, CardFooter } from "card.slint";
use iced::widget::{column, container, mouse_area, row, scrollable, svg, text};
use iced::{Alignment, Element, Length, Task, Theme};
import { signal, Text, View } from "nsh";
import { Avatar } from "./avatar";
import { Badge } from "./badge";
import { Button } from "./button";
import { Card } from "./card";
import { Icon } from "./icon";
import { Input } from "./input";
import { Menu, type MenuItem } from "./menu";
import { MenuButton } from "./menu";
import { alpha, tokens } from "./theme";

#Usage

GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const usage = (
  <Card
    title="Project update"
    description="The weekly summary is ready to review."
    badge="New"
    style={{ maxWidth: 360 }}
  >
    <Text style={{ fontSize: 14, color: tokens.foreground }}>
      You walked 42 km this week, eight more than last week.
    </Text>
  </Card>
);

#Default

Card::new()
    .child(
        CardHeader::new()
            .child(CardTitle::new().child("Team"))
            .child(CardDescription::new().child("Invite members and set their roles.")),
    )
    .child(CardContent::new().child("Twelve seats remaining on this workspace."))
    .child(
        CardFooter::new()
            .child(Button::new("cancel").label("Cancel"))
            .child(Button::new("invite").primary().label("Invite")),
    )
Card {
    title: "Team";
    description: "Invite members and set their roles.";
    Text {
        text: "Twelve seats remaining on this workspace.";
        color: Theme.muted-foreground;
    }
    CardFooter {
        Button {
            text: "Cancel";
        }
        Button {
            text: "Invite";
            variant: ButtonVariant.primary;
        }
    }
}
// The page's first documented sample and the Slint example's first
// `GroupBox`: a header, a body, and an end-aligned footer of actions.
let default = body_box(
    Card::new()
        .title("Team")
        .description("Invite members and set their roles.")
        .body(
            column![
                muted("Twelve seats remaining on this workspace."),
                card::footer(
                    row![
                        Button::new("Cancel")
                            .variant(Variant::Ghost)
                            .on_press(Message::Nothing),
                        Button::new("Invite")
                            .variant(Variant::Primary)
                            .on_press(Message::Saved),
                    ]
                    .spacing(theme::SPACING_SM),
                ),
            ]
            .spacing(theme::SPACING_LG),
        ),
);
const normal = (
  <Card
    title="Design system"
    description="A shared foundation for every framework."
    badge="Updated"
    footer={
      <Button label="Open" size="small" onPress={() => action.set("Opened design system")} />
    }
    style={{ maxWidth: 360 }}
  >
    <Text style={{ fontSize: 14, lineHeight: 20, color: tokens.foreground }}>
      Tokens, controls and documentation in one place.
    </Text>
  </Card>
);

#Stacked

h_flex()
    .gap_4()
    .items_start()
    .child(
        Card::new()
            .flex_1()
            .child(CardHeader::new().child(CardTitle::new().child("Usage")))
            .child(CardContent::new().child("4.2 GB of 10 GB used.")),
    )
    .child(
        Card::new()
            .flex_1()
            .child(CardHeader::new().child(CardTitle::new().child("Plan")))
            .child(CardContent::new().child("Team · billed monthly.")),
    )
HorizontalLayout {
    spacing: 16px;
    Card {
        title: "Usage";
        Text {
            text: "4.2 GB of 10 GB used.";
            color: Theme.muted-foreground;
        }
    }
    Card {
        title: "Plan";
        Text {
            text: "Team · billed monthly.";
            color: Theme.muted-foreground;
        }
    }
}
// Two cards side by side, each filling its half: the Slint example's
// `horizontal-stretch: 1` pair.
let stacked = body_box(
    row![
        Card::new()
            .title("Usage")
            .body(muted("4.2 GB of 10 GB used.")),
        Card::new()
            .title("Plan")
            .body(muted("Team · billed monthly.")),
    ]
    .spacing(theme::SPACING_LG),
);
const stacked = (
  <Column gap={12} style={{ maxWidth: 360 }}>
    <Card title="Design system" description="Tokens, controls and documentation.">
      <Text style={{ fontSize: 14, color: tokens.foreground }}>Shared by every framework.</Text>
    </Card>
    <Card title="Native shell" description="The same controls written in TSX." badge="Draft">
      <Text style={{ fontSize: 14, color: tokens.foreground }}>Runs on every NSH platform.</Text>
    </Card>
  </Column>
);

#Login

GPUINo GPUI version of this example yet.
Card {
    title: "Login to your account";
    description: "Enter your email below to login to your account";
    Input {
        placeholder: "m@example.com";
    }
    Button {
        text: "Forgot your password?";
        variant: ButtonVariant.link;
        horizontal-stretch: 0;
    }
    Button {
        text: "Login";
        variant: ButtonVariant.primary;
        horizontal-stretch: 1;
    }
}
// A field and two actions in the card body: the Slint example's login form,
// with the input's placeholder and a link variant for the secondary action.
let login = body_box(
    Card::new()
        .title("Login to your account")
        .description("Enter your email below to login to your account")
        .body(
            column![
                Input::new("card-login-email")
                    .placeholder("m@example.com")
                    .value(app.email.clone())
                    .width(Length::Fill)
                    .on_input(Message::Email),
                Button::new("Forgot your password?")
                    .variant(Variant::Link)
                    .on_press(Message::Nothing),
                Button::new("Login")
                    .variant(Variant::Primary)
                    // .width(Length::Fill)
                    .on_press(Message::Saved),
            ]
            .spacing(theme::SPACING_MD),
        ),
);
const login = (
  <Card
    title="Welcome back"
    description="Sign in to continue to your workspace."
    footer={
      <>
        <Button label="Cancel" variant="ghost" onPress={() => action.set("Cancelled")} />
        <Button label="Sign in" variant="primary" onPress={() => action.set("Signed in")} />
      </>
    }
    style={{ maxWidth: 380 }}
  >
    <View style={{ gap: 10 }}>
      <Input
        value={email()}
        placeholder="Email"
        prefixIcon="mail"
        onChangeText={(next) => email.set(next)}
      />
      <Input
        value={password()}
        placeholder="Password"
        prefixIcon="lock"
        masked
        maskToggle
        onChangeText={(next) => password.set(next)}
      />
    </View>
  </Card>
);

#Size

GPUINo GPUI version of this example yet.
Card {
    title: "Default";
    description: "The standard inset and title size.";
}
Card {
    title: "Small";
    description: "A compact card for dense layouts.";
    size: ControlSize.small;
}
// The two sizes: medium keeps the 16px inset and the text-md title, small
// tightens both.
let size = body_box(
    column![
        Card::new()
            .title("Default")
            .description("The standard inset and title size."),
        Card::new()
            .title("Small")
            .description("A compact card for dense layouts.")
            .size(ControlSize::Small),
    ]
    .spacing(theme::SPACING_LG),
);
const size = (
  <Row gap={12}>
    <Card size="small" title="Small card" description="A tighter inset and title." style={{ width: 250 }}>
      <Text style={{ fontSize: 13, color: tokens.foreground }}>Small is 12 pt of padding.</Text>
    </Card>
    <Card size="medium" title="Medium card" description="The default inset." style={{ width: 250 }}>
      <Text style={{ fontSize: 13, color: tokens.foreground }}>Medium is 16 pt of padding.</Text>
    </Card>
  </Row>
);

#Spacing

GPUINo GPUI version of this example yet.
Card {
    title: "16 px";
    description: "Inset and the gap between sections.";
    inset: 16px;
}
Card {
    title: "20 px";
    description: "Inset and the gap between sections.";
    inset: 20px;
}
Card {
    title: "24 px";
    description: "Inset and the gap between sections.";
    inset: 24px;
}
Card {
    title: "32 px";
    description: "Inset and the gap between sections.";
    inset: 32px;
}
// The inset is the card's padding and the gap between the header, the body
// and the footer at once. Slint lets the sample set it freely; this
// component derives it from `size`, so the sample shows the two it has —
// 16px at the medium size and 12px at the small size — rather than four it
// cannot.
let spacing = body_box(
    column![
        Card::new()
            .title("16 px")
            .description("The medium inset and the gap between sections.")
            .body(muted("A body at the same inset.")),
        Card::new()
            .title("12 px")
            .description("The small inset and the gap between sections.")
            .size(ControlSize::Small)
            .body(muted("A body at the same inset.")),
    ]
    .spacing(theme::SPACING_LG),
);
const spacing = (
  <Row gap={12}>
    <Card title="Inset 8" inset={8} style={{ width: 220 }}>
      <Text style={{ fontSize: 13, color: tokens.foreground }}>A compact card.</Text>
    </Card>
    <Card title="Inset 24" inset={24} style={{ width: 240 }}>
      <Text style={{ fontSize: 13, color: tokens.foreground }}>A roomy card.</Text>
    </Card>
  </Row>
);

#Image

GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const image = (
  <Card
    cover={cover}
    title="Mountain light"
    description="A cover image above the header."
    style={{ maxWidth: 360 }}
  >
    <Text style={{ fontSize: 14, color: tokens.foreground }}>
      The cover is clipped by the card's rounded corner.
    </Text>
  </Card>
);
GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const link = (
  <Card
    title="Need a help in Claim?"
    description="Go to this step by step guideline process on how to certify for your weekly benefits:"
    footer={
      <Button
        label="See our guideline"
        suffixIcon="external-link"
        variant="ghost"
        size="small"
        onPress={() => action.set("Opened guideline")}
      />
    }
    footerAlign="start"
    footerBordered
    style={{ maxWidth: 340 }}
  />
);

#Card with dropdown menu

GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const dropdown = (
  <Card
    title="Need a help in Claim?"
    description="Go to this step by step guideline process on how to certify for your weekly benefits:"
    actions={
      <MenuButton
        label="Card actions"
        items={menuItems}
        width={180}
        trigger={
          <View
            accessibilityLabel="Card actions"
            style={{ width: 26, height: 26, alignItems: "center", justifyContent: "center", borderRadius: 6 }}
          >
            <Icon name="ellipsis" size={16} color={tokens.mutedForeground} />
          </View>
        }
      />
    }
    footer={
      <Badge
        label="@shadcn"
        variant="secondary"
        leading={<Avatar name="shadcn" size="xs" />}
      />
    }
    footerAlign="start"
    footerBordered
    style={{ maxWidth: 340 }}
  />
);

#Card with image

GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const imageCard = (
  <Card
    cover={cover}
    coverHeight={150}
    badges={
      <View style={{ flexDirection: "row", alignItems: "center", justifyContent: "space-between", width: "100%" }}>
        <Badge label="Trending" icon="trending-up" variant="secondary" />
        <Badge label="Featured" icon="sparkles" variant="outline" />
      </View>
    }
    title="Simplifying your workflow from day one."
    description="Manage your tasks, projects, and team in one place."
    footer={
      <Button
        label="Get Started"
        suffixIcon="arrow-right"
        style={{ width: "100%" }}
        onPress={() => action.set("Get started")}
      />
    }
    style={{ maxWidth: 340 }}
  />
);

#Image scale hover effect

GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const imageHover = (
  <Card
    cover={cover}
    coverHeight={300}
    imageHoverScale
    inset={0}
    coverOverlay={
      <View style={{ gap: 4 }}>
        <Text style={{ fontSize: 22, lineHeight: 28, fontWeight: "700", color: tokens.foreground }}>
          Image Scale Effect
        </Text>
        <Text style={{ fontSize: 13, lineHeight: 18, color: alpha(tokens.foreground, 0.8) }}>
          This card features a smooth image scaling effect and background overlay on hover.
        </Text>
      </View>
    }
    style={{ width: 340 }}
  />
);

#Profile card

GPUINo GPUI version of this example yet.
SlintNo Slint version of this example yet.
const profile = (
  <Card style={{ maxWidth: 340 }}>
    <View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
      <Avatar name="Lena Ortiz" size="lg" />
      <View style={{ flex: 1, gap: 2 }}>
        <Text style={{ fontSize: 14, fontWeight: "600", color: tokens.foreground }}>Lena Ortiz</Text>
        <Text style={{ fontSize: 12, color: tokens.mutedForeground }}>Billing support · online</Text>
      </View>
      <Badge label="Pro" variant="info" />
    </View>
    <Text style={{ fontSize: 13, lineHeight: 19, color: tokens.mutedForeground }}>
      Replies in a few minutes. Handles billing, refunds and plan changes.
    </Text>
    <Row gap={8}>
      <Button label="Message" size="small" onPress={() => action.set("Message Lena")} />
      <Button label="View profile" size="small" variant="ghost" onPress={() => action.set("View Lena")} />
    </Row>
  </Card>
);

#Stats card

GPUINo GPUI version of this example yet.
Card {
    cover: @image-url("assets/attachment-preview.svg");
    badge: "Featured";
    title: "Design systems meetup";
    description: "A practical talk on component APIs and shipping faster.";
}
// Slint's card has a `cover` image slot above the header. This one draws
// the header first and has no slot above it, so the caller's media element
// is the body — an application passes `image(handle)` or `svg(handle)`
// here — and the badge rides above the title as it does in Slint.
let image = body_box(
    Card::new()
        .badge("Featured")
        .title("Design systems meetup")
        .description("A practical talk on component APIs and shipping faster.")
        .body(cover("attachment-preview.svg")),
);
const stats = (
  <Card style={{ maxWidth: 260 }}>
    <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
      <Text style={{ flex: 1, fontSize: 12, fontWeight: "500", color: tokens.mutedForeground }}>
        Revenue this month
      </Text>
      <Badge label="+12.4%" variant="success" icon="trending-up" />
    </View>
    <Text style={{ fontSize: 30, lineHeight: 36, fontWeight: "700", color: tokens.foreground }}>
      $48,290
    </Text>
    <Text style={{ fontSize: 11, color: tokens.mutedForeground }}>Compared with $42,960 last month.</Text>
  </Card>
);

#Parts

  • Card — bordered surface, padding, and vertical gap.
  • CardHeader — title and description stack.
  • CardTitle — primary heading.
  • CardDescription — supporting copy in the muted foreground.
  • CardContent — main body.
  • CardFooter — action row.

All parts implement [ParentElement] and [Styled], so you can add children and refine layout without a sealed API.

#Copy source

This is a GPUI-target registry component. The CLI copies crates/component/src/card.rs. There is no gpui-base Card primitive; keep gpui-base as the dependency for behavior used by other copied components.