Repository navigation
Writing Component Styles
The default look of the cn components is written in SCSS and compiled when the crate is built. The
result is the CN_STYLES constant, which is plain CSS. Nothing is compiled when an application
runs, and an application's own CSS stays plain CSS.
crates/blinc_cn/styles/
index.scss the order of the components
components/_button.scss one partial for each component
components/_card.scss
...
crates/blinc_sass/scss/
_mixins.scss shared by every stylesheet
index.scss lists the partials with @use. The compiled rules come out in that order, so a later
component can override an earlier one when both match. The build wraps the whole result in
@layer components, so every rule sits below an application's own rules. You do not write the
layer in a partial.
crates/blinc_layout/src/ua_styles.rs is the stylesheet of the layout widgets. It is short, so it
stays a Rust string and is not compiled.
- Add
components/_name.scssfor a new component, and add@use "components/name";toindex.scss. - Write the rules. A partial is plain SCSS at the top level. Colours, radii, durations and
easings are
var(--theme-token)references, as before. - Run
cargo build -p blinc_cn. A mistake stops the build and the message names the file, the line and the column.
A name that Windows reserves (aux, con, prn, nul, com1 to com9, lpt1 to lpt9)
cannot be a file name, so do not use one for a partial.
A partial starts with the modules it needs:
@use "blinc/mixins" as *;| Name | What it gives |
|---|---|
transition($props, $duration, $easing) |
A transition over the space-separated properties, at fast and state unless you name others |
focus-ring($offset) |
The focus outline, 2px from the edge unless you give another offset |
tint($percent, $into) |
The text colour mixed into $into, as a hover or press tint is |
blend($color, $percent, $into) |
Any colour mixed into $into
|
.cn-toggle {
@include transition(background-color color);
&:hover:not(:disabled) { background: tint(5%); }
&:focus-visible { @include focus-ring; }
}A rule that does not fit a mixin stays plain CSS. Write the property out where a mixin would hide
what the rule does.
Blinc's own CSS passes through the compiler unchanged: custom properties, color-mix(),
var() with fallbacks, overflow-fade, @keyframes, and the pseudo-classes and attribute
selectors the engine reads. The one visible change is that an attribute selector loses the quotes
where the value is a plain word: [data-state="on"] is written [data-state=on], which means the
same.
The compiled sheet is in target/debug/build/blinc_cn/<hash>/out/cn.css. The tests in
blinc_cn and blinc_recorder read CN_STYLES, so they check the compiled text.
The web component pages cut their code examples from the compiled sheet, and the fixture digest that decides whether a preview must be recorded again is taken from it too. A change to how a sheet is written that leaves the CSS alone does not make the previews stale.
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