Repository navigation
Card
Cards group related content and actions.
use blinc::cn::prelude::*;
use blinc::layout::prelude::{div, img, text};
card()
.child(card_header()
.title("Card Title")
.description("Card description text"))
.child(card_content()
.child(text("Card content goes here.")))
.child(card_footer()
.child(button("Action")))card() is the container that wraps all card content.
card()
.w(400.0) // Custom width
.child(text("Card content"))The header contains the title and the description.
card_header()
.title("Title")
.description("Description")The title has the class .cn-card-title, and the description has the class
.cn-card-description. The rules for these classes set their colors. The title
and the description each take a string or a signal. When a signal changes, it
replaces the text in place.
This is the main content area.
card_content()
.child(text("Any content"))The footer holds actions and secondary information at the bottom.
card_footer()
.child(button("Cancel").variant(ButtonVariant::Outline))
.child(button("Save"))use blinc::prelude::signal;
let email = signal(true);
let push = signal(false);
card()
.child(card_header()
.title("Notifications")
.description("Configure notification settings"))
.child(card_content()
.child(
div()
.flex_col()
.gap_px(12.0)
.child(checkbox(email).label("Email notifications"))
.child(checkbox(push).label("Push notifications"))
))card()
.child(
img("cover.jpg")
.w_full()
.h(200.0)
.cover()
)
.child(card_header()
.title("Beautiful Sunset")
.description("Photo by @photographer"))
.child(card_footer()
.child(button("View").variant(ButtonVariant::Outline))
.child(button("Download")))With .w_full().max_w(350.0), a card is 350 px wide where there is room. In a
smaller container, it is narrower. .w(350.0) keeps the card at 350 px.
use blinc::layout::widgets::text_input::text_input_state;
let email = text_input_state();
let password = text_input_state();
card()
.w_full()
.max_w(350.0)
.child(card_header()
.title("Login")
.description("Enter your credentials"))
.child(card_content()
.child(
div()
.flex_col()
.gap_px(16.0)
.child(input(&email).label("Email").placeholder("name@example.com"))
.child(input(&password).label("Password").password())
))
.child(card_footer()
.child(button("Sign in")))The cards sit in a row. If the space is too narrow, they wrap onto new rows.
let plan = |name: &'static str, price: &'static str| {
card()
.w(220.0)
.child(card_header().title(name))
.child(card_content().child(text(price)))
.child(card_footer().child(button("Select")))
};
div()
.flex_row()
.flex_wrap()
.gap_px(16.0)
.child(plan("Plan A", "$9/month"))
.child(plan("Plan B", "$19/month"))
.child(plan("Plan C", "$29/month"))A card has no click handler of its own. To make the whole card clickable, put it in a div that has
one.
div()
.cursor_pointer()
.on_click(|_| {
// Open the details here.
})
.child(card()
.child(card_header()
.title("Click Me")
.description("This entire card is clickable"))
.child(card_content()
.child(text("Card content..."))))Cards take their colors from the theme. The .cn-card rule sets these:
- Background:
--cn-card-bg, with--surfaceas the default - Border:
--cn-card-border, with--borderas the default - Radius:
--cn-card-radius, with--radius-xlas the default - Shadow:
--shadow-sm
To change the look, write rules for .cn-card in your CSS:
.cn-card {
background: var(--surface-elevated);
border-color: var(--primary);
border-radius: var(--radius-lg);
box-shadow: var(--shadow-lg);
}In Rust, .bg(color) sets the background, and .shadow_md() or .shadow_lg() sets a larger shadow.
card()
.bg(Color::rgb(0.1, 0.1, 0.1))
.shadow_lg()| Method | Description |
|---|---|
child |
Adds content |
w, h, w_full, max_w
|
Set the size |
p, px, py, m
|
Set padding and margin, in units of 4 px |
bg, shadow_md, shadow_lg
|
Set the background and the shadow |
class, id
|
Name the card for CSS |
Other div methods, for example rounded or on_click, are not on a card. Use CSS, or put the card
in a div.
| Method | Description |
|---|---|
title |
The main heading. A string or a signal |
description |
The text below the title. A string or a signal |
| Method | Description |
|---|---|
child |
Adds an element |
Getting Started
Migrating
Mobile Development
Example Gallery
- Example Gallery
- Canvas Element
- Canvas Kit Interactive
- Carousel Demo - Selector API Showcase
- Chrome-Style Tabs
- blinc_cn Components
- Run with
cargo run -p blinc_app_examples --features cn --example cn_pickers_demo. - Code Element
- Complex SVG
- CSS Debug
- CSS Visual Features
- Layer Effects
- Emoji and HTML Entities
- @flow Shader
- Fluid Surface
- Skeleton animation with glTF +
blinc_canvas_kit. - Gpu Pass Demo
- Image CSS Styling
- Image Layer Test
- Keyframe Animation Canvas
- Markdown Editor
- 3D Mesh Demo — renders the Khronos glTF
DamagedHelmetsample model - Motion Demo
- Music Player Glass Card
- Node-editor demo — pre-wired graph with three node types, typed
- Notch Menu Bar
- Overflow Fade
- Overlay System
- Pointer Query
- Rich Text Element
- Rich Text Editor
- Scroll Container
- Semantic @flow
- Sortable
- Stateful API + Signal-bound modifiers demo.
- End-to-end 3D demo wiring Blinc's SceneKit3D renderer up to
- Unified Styling API
- SVG Animation
- Table Builder
- Tabler Icons
- Minimal text positioning test
- Text Input Widgets
- KHR_texture_transform
- Theme System
- Timeline Animation
- Typography
- Wet Glass
- Windowed Application
Web Development
Core Concepts
- Elements & Layout
- Styling & Materials
- CSS Styling
- Theming
- Event Handling
- Accessibility
- State Management
- Lists & Conditional Content
- Element Refs
Animation
Components
Component Library (blinc_cn)
- Overview
- Button
- Card
- Icons
- Typography
- Dialog
- Form Components
- Date, Time and Colour Pickers
- Rich Text Editor
- Code Editor
- Navigation
- Feedback
- Layout
- Data Display
Widgets
- Buttons & Inputs
- Text & Rich Text
- Code Editor
- Scroll Containers
- Virtualized List
- Canvas Drawing
- Gestures
- Notched Surfaces
- Images & SVG
- Audio & Video
- Markdown Rendering
Canvas Kit
Advanced
- Routing & Navigation
- Multi-Window
- System Integration
- Element Query API
- Overlay System
- Custom State Machines
- Pointer Query
- Performance Tips
- Flow Shaders
- 3D Rendering
- Custom GPU Passes
- Hot reloading
Architecture
Contributing