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 cornersModules§
- private 🔒
Structs§
- Radius
Full - Full border radius (pill shape).
- Radius
Lg - Large border radius.
- Radius
Md - Medium border radius.
- Radius
None - No border radius (sharp corners).
- Radius
Scale - A complete radius scale with customizable pixel values.
- Radius
Sm - Small border radius.
Enums§
- Radius
Value - A runtime radius value for when const generics aren’t suitable.
Traits§
- Button
Radius - Marker trait for radii valid on buttons.
- Input
Radius - Marker trait for radii valid on inputs.
- Module
Radius - Marker trait for radii valid on modules/cards.
- Radius
Semantic - Marker trait for all radius semantics.
Functions§
- default_
full 🔒 - default_
lg 🔒 - default_
md 🔒 - default_
sm 🔒