Repository navigation
Typography
Typography helpers provide defaults for headings, body text, and short inline
fragments. They return Text. The exception is chained_text, which groups
fragments in a Div. Import the helpers through blinc::cn::cn or the
component prelude. Install cn_bundle() as Getting Started
describes.
Use a level that matches the content hierarchy. The named helpers and
heading(level, content) share these defaults. Application CSS can override
them.
| Helper | Default size / weight | CSS class |
|---|---|---|
cn::h1 |
32px / bold | .cn-h1 |
cn::h2 |
24px / bold | .cn-h2 |
cn::h3 |
20px / semibold | .cn-h3 |
cn::h4 |
18px / semibold | .cn-h4 |
cn::h5 |
16px / medium | .cn-h5 |
cn::h6 |
14px / medium | .cn-h6 |
use blinc::cn::cn;
use blinc::layout::prelude::*;
div().flex_col().gap(3.0)
.child(cn::h1("Project overview"))
.child(cn::h2("Recent activity"))
.child(cn::h3("Design reviews"))
.child(cn::h4("Comments"))
.child(cn::h5("Resolved"))
.child(cn::h6("Earlier updates"))cn::heading(2, content) selects the same heading level and .cn-h2 class as
cn::h2(content). Its level is a construction option from 1 to 6. Its content
also accepts a Signal or a Computed.
-
cn::p(content): body text that wraps, at 16px with line-height 1.5. Class:.cn-p. -
cn::muted(content): short secondary information, in the secondary text color, with no wrapping. Class:.cn-muted. -
cn::caption(content): captions and footnotes, at 12px in the tertiary text color, with no wrapping. Class:.cn-caption. -
cn::small(content): short fine print at 12px, with no wrapping. No automatic class.
use blinc::cn::cn;
use blinc::layout::prelude::*;
div().flex_col().gap(2.0)
.child(cn::p("Keep project notes, decisions and next steps together."))
.child(cn::muted("Updated a few minutes ago"))
.child(cn::caption("Figure 1: Workspace layout"))
.child(cn::small("Changes are saved automatically."))All of these helpers return Text and support its fluent methods. If supporting
text needs more than one line, enable wrapping with .wrap(true).
-
cn::span(content): neutral inline text fragment. -
cn::b(content): bold fragment. -
cn::strong(content): alias forb. -
cn::inline_code(content): monospace fragment, such as a filename or identifier. -
cn::chained_text([fragments]): aDivthat holds a row ofTextfragments, aligned on the baseline.
use blinc::cn::cn;
cn::chained_text([
cn::span("Saved to "),
cn::strong("Design system"),
cn::span(" as "),
cn::inline_code("theme.css"),
])Where you need spaces, include them in the fragments. Inline helpers do not wrap
by default, and chained_text lays out separate elements in a row. For a
paragraph that wraps mixed styles as flowing text, use
rich_text(). For code blocks with syntax
highlighting, use code().
The plain helper blinc::layout::typography::label(content) returns inline
Text at 14px and medium weight. blinc::cn::components::typography also
re-exports it. In contrast, cn::label(content) creates the themed
form Label component, with required and disabled options.
heading accepts impl IntoReactive<String>. The named helpers h1 to h6,
p, muted, caption, and the inline helpers take strings at construction
time. For other live text, bind a Signal or Computed with Text::bound, and
give it a CSS class:
use blinc::cn::cn;
use blinc::core::{computed, signal};
use blinc::layout::{binding::IntoReactive, prelude::*};
let title = signal("Project overview".to_string());
let pending = signal(3usize);
let summary = computed(move |g| {
format!("{} files awaiting review", g.get(pending).unwrap_or_default())
});
let header = div().class("project-copy")
.child(cn::heading(2, title))
.child(Text::bound(summary.into_reactive()).class("project-summary"));
pending.set(5);Create these bindings once. As an alternative, use ctx.use_signal(...) to
retain them across UI builds. An update to either source replaces the bound text
in place.
The classes listed above for headings, paragraphs, muted text, and captions are
hooks for your styles. span, b, strong, small, inline_code, and
chained_text do not add cn-* classes. Attach your own classes with
.class(...). The equivalent helpers in blinc::layout::typography have the
same text defaults without the CN classes.
Add your overrides after the component stylesheet, and use the root variables of the theme:
.cn-h2 {
font-size: 28px;
font-weight: 700;
color: var(--text-primary);
}
.cn-p {
font-size: var(--text-base);
line-height: 1.6;
}
.project-copy {
flex-direction: column;
gap: var(--space-2);
}
.project-summary {
font-size: var(--text-sm);
color: var(--text-secondary);
}If only one section must change, scope the shared classes to an application
container. For example, use .project-copy .cn-h2.
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