Skip to content

Typography

github-actions[bot] edited this page Nov 26, 2026 · 5 revisions

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.

Headings

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.

Body and supporting text

  • 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).

Inline helpers and composition

  • cn::span(content): neutral inline text fragment.
  • cn::b(content): bold fragment.
  • cn::strong(content): alias for b.
  • cn::inline_code(content): monospace fragment, such as a filename or identifier.
  • cn::chained_text([fragments]): a Div that holds a row of Text fragments, 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.

Reactive text

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.

Restyling

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.

Navigation

Getting Started

Migrating

Mobile Development

Example Gallery

Web Development

Core Concepts

Animation

Components

Component Library (blinc_cn)

Widgets

Canvas Kit

Advanced

Architecture

Contributing

Clone this wiki locally