Module radius

Source
Expand description

§Semantic Border Radius Tokens

This module provides border radius tokens with semantic names and component-specific validity constraints.

§Design Rationale

Border radius affects the visual character of UI elements. Rather than allowing arbitrary pixel values, we define semantic names that can be customized while maintaining consistent meaning.

ⓘ
// ❌ Bad: Magic numbers
button.radius = 4;
card.radius = 8;
pill.radius = 9999;

// ✅ Good: Semantic names
button.radius = RadiusSm;   // "Small" - for compact elements
card.radius = RadiusMd;     // "Medium" - for cards/modules
pill.radius = RadiusFull;   // "Full" - for pill shapes

§Component Constraints

Not all radii make sense for all components. A button with RadiusFull looks like a pill — probably not intended. The type system prevents this:

ⓘ
// ButtonSpec requires R: ButtonRadius
struct ButtonSpec<R: ButtonRadius> { ... }

// RadiusSm implements ButtonRadius
ButtonSpec::<RadiusSm>::new()  // ✓ Compiles

// RadiusFull does NOT implement ButtonRadius
ButtonSpec::<RadiusFull>::new()  // ✗ Error!

§Customizable Values

While the semantic names are fixed, the actual pixel values can be customized via configuration:

[appearance.radius]
sm = 4   # Could be changed to 2 for sharper corners
md = 8   # Could be changed to 12 for rounder corners

Modules§

private 🔒

Structs§

RadiusFull
Full border radius (pill shape).
RadiusLg
Large border radius.
RadiusMd
Medium border radius.
RadiusNone
No border radius (sharp corners).
RadiusScale
A complete radius scale with customizable pixel values.
RadiusSm
Small border radius.

Enums§

RadiusValue
A runtime radius value for when const generics aren’t suitable.

Traits§

ButtonRadius
Marker trait for radii valid on buttons.
InputRadius
Marker trait for radii valid on inputs.
ModuleRadius
Marker trait for radii valid on modules/cards.
RadiusSemantic
Marker trait for all radius semantics.

Functions§

default_full 🔒
default_lg 🔒
default_md 🔒
default_sm 🔒