Shape (Corners & Borders)
Radius, border width, semantic borders, gradient presets, and glow tokens — from two base values.
The Shape System controls border radius, border width, semantic border shorthands, gradient borders, and glow effects. Its tokens come from the radius and border sections of the config (mainly radius.base, radius.scale, border.base and border.scale), plus the inset factor for corner-safe padding.
Radius Tokens
This site's theme: base radius 8px, 7 steps. The engine
default is a 4px base and 6 steps (2, 4, 6, 8, 12, 16 px).
Radius primitives
| Step | px | rem | CSS variable |
|---|---|---|---|
| 1 | 2 | 0.125 | --fp-radius-1 |
| 2 | 4 | 0.25 | --fp-radius-2 |
| 3 | 6 | 0.375 | --fp-radius-3 |
| 4 | 8 | 0.5 | --fp-radius-4 |
| 5 | 12 | 0.75 | --fp-radius-5 |
| 6 | 16 | 1 | --fp-radius-6 |
| 7 | 24 | 1.5 | --fp-radius-7 |
Semantic corners
| Key | Resolves to | Use |
|---|---|---|
--fp-corner-control | var(--fp-radius-base) | Buttons, inputs, switches, list and menu items |
--fp-corner-surface | var(--fp-radius-6) | Cards, alerts, dropdown and context menus |
--fp-corner-overlay | var(--fp-radius-7) | Modals, drawers, popovers, toasts |
--fp-corner-circle | var(--fp-radius-full) | Avatars, badges, chips, slider track and thumb |
Use semantic --fp-corner-* tokens in component code; the primitive --fp-radius-* ladder is for building new semantic tokens.
The default theme.css keeps only the radius steps the corner tokens and components read. In the theme @flexpixels/ui ships (the same radius settings as this site), --fp-radius-3 and --fp-radius-5 are in the full stylesheet only (generateFullThemeCSS, or output.tokens: "full").
Corner Shape
border-radius sizes a corner; the CSS corner-shape property sets its character. The radius.cornerShape config field emits a --fp-corner-shape token; cortex does not apply it to anything. In your own CSS, set corner-shape: var(--fp-corner-shape) beside border-radius. The theme stylesheet in @flexpixels/ui (not published yet) applies it through ::part() to the common radius-bearing parts (surface, base, button, thumb, track and about 35 more) of the components in your page. A component inside another component’s shadow root is not reached by that rule, and neither is a part with another name.
| Value | Corner |
|---|---|
round | Normal circular arc (default — no visual change) |
squircle | Superellipse (smooth “iOS-style” corner) |
bevel | Straight diagonal chamfer |
scoop | Concave arc cut into the corner |
notch | Right-angle step cut out of the corner |
square | Hard right angle (arc removed) |
Three usage levels, mirroring border-radius:
// 1. Global — theme-config
"radius": { "cornerShape": "squircle" }/* 2. Scoped — override the token on any container */
.hero {
--fp-corner-shape: squircle;
}<!-- 3. Per-instance — the corner-shape attribute mirrors the CSS property -->
<fp-button corner-shape="bevel">Submit</fp-button>Border Tokens
Width Primitives
| Token | Default |
|---|---|
--fp-border-none | 0px (full stylesheet only) |
--fp-border-1 to --fp-border-4 | 1px to 4px (3 and 4: full stylesheet only) |
--fp-border-base | var(--fp-border-1) |
Named Widths (--fp-border-w-*)
| Token | Default | Use |
|---|---|---|
--fp-border-w-hairline | 1px | Subtle dividers |
--fp-border-w-thin | 1.5px | No stroke role uses it (full stylesheet only) |
--fp-border-w-medium | 2px | Focus states, emphasis |
--fp-border-w-thick | 3px | Decorative accents |
Stroke Semantics (--fp-stroke-*)
Each rung aliases the named width scale (single source of truth); control tracks the configurable base width so a theme can thicken every control border at once.
| Token | Value | Use For |
|---|---|---|
--fp-stroke-hairline | var(--fp-border-w-hairline) | Thinnest subtle borders |
--fp-stroke-control | var(--fp-border-base) | Interactive controls |
--fp-stroke-divider | var(--fp-border-w-hairline) | Separators |
--fp-stroke-strong | var(--fp-border-w-medium) | Focus, active states |
--fp-stroke-accent | var(--fp-border-w-thick) | Decorative borders |
Semantic Border Shorthands (--fp-border-semantic-*)
width solid color shorthands to use as border values. Full stylesheet only: they are in theme-full.css (or output.tokens: "full"), not in the default theme.css.
| Token | Width + Color |
|---|---|
--fp-border-semantic-default | hairline + neutral-6 |
--fp-border-semantic-subtle | hairline + neutral-4 |
--fp-border-semantic-strong | medium + neutral-7 |
--fp-border-semantic-focus | medium + primary-text |
--fp-border-semantic-danger | medium + danger-text |
--fp-border-semantic-success | medium + success-text |
--fp-border-semantic-accent | thick + primary-text |
--fp-border-semantic-divider | hairline + neutral-6 |
The coloured borders use each role’s -text colour, which is measured to stay readable against the page.
Gradient Presets (--fp-border-gradient-*)
Two seed-derived gradients are always emitted:
| Token | Description |
|---|---|
--fp-border-gradient-brand | Primary → secondary gradient |
--fp-border-gradient-subtle | Neutral → primary → neutral |
Setting border.gradient.preset (anything but "none") or border.gradient.custom in the config adds --fp-border-gradient-active, built at border.gradient.angle. Animated beam / shimmer presets are opt-in — set border.animatedEnabled: true to emit --fp-border-gradient-animated-{beam,shimmer}.
A FlexPixels component that exposes a surface part draws a gradient border when it carries the border-gradient attribute: border-gradient="brand" or "subtle" picks a preset, and --fp-border-gradient on the element sets any other gradient.
Glow Tokens (--fp-glow-*)
Semantic state glows — a soft 3px coloured ring at 25% opacity. Emitted while border.glowEnabled is true (the default), in the full stylesheet only: theme-full.css or output.tokens: "full".
| Token | Use |
|---|---|
--fp-glow-focus | Focus glow (from --fp-primary-text) |
--fp-glow-success | Success state glow |
--fp-glow-danger | Danger state glow |
--fp-glow-warning | Warning state glow |
How to Use
The samples that use --fp-border-semantic-* or --fp-glow-* need the full stylesheet (generateFullThemeCSS, or output.tokens: "full"); with the default theme.css those tokens are undefined.
Button with border
/* Needs theme-full.css: the default theme.css does not declare these tokens. */
.button-outline {
border: var(--fp-border-semantic-default);
border-radius: var(--fp-corner-control);
}
.button-outline:focus-visible {
border-color: var(--fp-focus-ring-color);
box-shadow: var(--fp-glow-focus);
}Card with subtle border
/* Needs theme-full.css: the default theme.css does not declare these tokens. */
.card {
border: var(--fp-border-semantic-subtle);
border-radius: var(--fp-corner-surface);
}Gradient border (using border-image)
/* border-image ignores border-radius: the corners come out square */
.gradient-card {
border: 2px solid transparent;
border-image: var(--fp-border-gradient-brand) 1;
}For rounded gradient borders on FlexPixels components, use the border-gradient attribute instead.
Divider line
/* Needs theme-full.css: the default theme.css does not declare these tokens. */
hr {
border: none;
border-top: var(--fp-border-semantic-divider);
}Glow on focus
/* Needs theme-full.css: the default theme.css does not declare these tokens. */
.input:focus-visible {
outline: none;
border-color: var(--fp-focus-ring-color);
box-shadow: var(--fp-glow-focus);
}
.input[aria-invalid="true"]:focus-visible {
border-color: var(--fp-danger-9);
box-shadow: var(--fp-glow-danger);
}Corner-Safe Inset (--fp-inset-*)
When a box has a large border-radius, content placed too close to a corner looks clipped — not because CSS clips it, but because the eye reads the arc as the edge. A border moves that edge further in.
The inset tokens give the least padding that clears the corner, from the corner radius and the control stroke:
inset = max(0px, corner_radius × factor − stroke)They are a floor, not a padding. FlexPixels components take the larger of the inset and their size-axis padding, so the size axis decides the padding and the inset only steps in for an unusually round corner:
/* fp-button's default inline padding */
max(var(--fp-inset-control), var(--fp-size-inset-inline))Tokens
| Token | Formula |
|---|---|
--fp-inset-control | max(0px, calc(min(var(--fp-corner-control), calc(var(--fp-size-box) / 2)) * factor - var(--fp-stroke-control))) |
--fp-inset-surface | max(0px, calc(var(--fp-corner-surface) * factor - var(--fp-stroke-control))) |
--fp-inset-overlay | max(0px, calc(var(--fp-corner-overlay) * factor - var(--fp-stroke-control))) |
With the default factor (0.2929), a 16px surface corner and a 1px stroke give an inset of about 3.7px, and a 40px overlay corner about 10.7px.
Only the control’s corner is read at no more than half the control box (--fp-size-box): a control cannot round further than that, so a pill corner (9999px) asks for half a box’s inset, not thousands of pixels. A surface or an overlay is as tall as its content, so its corner is read as stated. --fp-inset-control is declared again in every [data-size] / size="" rule, so a pill’s inset follows the box of the size it is used at.
Factor presets
| Preset | Factor | Character |
|---|---|---|
"tight" | 0.2929 | Default. The geometric minimum: a content corner at that inset just clears the arc |
"balanced" | 0.5 | Halfway |
"generous" | 1.0 | The whole radius rather than the curve |
inset.factor also takes any number from 0 to 1. A factor above the default does more than add air: on large corners the inset can exceed the size-axis padding and set the padding itself, which can make overlays look padded out.
Usage
Use the same max() pattern in your own rounded elements:
/* Needs theme-full.css: the default theme.css does not declare these tokens. */
.card {
border: var(--fp-border-semantic-subtle);
border-radius: var(--fp-corner-surface);
padding: max(var(--fp-inset-surface), var(--fp-s-6));
}To change one component’s padding, use its own hooks, for example --fp-button-padding-inline and --fp-button-padding-block.
Configuration
{
"radius": { "base": 4, "scale": [2, 4, 6, 8, 12, 16] },
"border": {
"base": 1,
"scale": [1, 2, 3, 4],
"glowEnabled": true,
"animatedEnabled": false,
"widthScale": { "hairline": 1, "thin": 1.5, "medium": 2, "thick": 3 }
},
"inset": {
"factor": "tight"
}
}Best Practices
-
Use
--fp-corner-*semantics, not--fp-radius-*primitives.corner-controlfor buttons,corner-surfacefor cards,corner-overlayfor modals — the token names the corner’s purpose, and a theme can retune each one. -
Use
--fp-border-semantic-*for whole borders. Each holds width, style and colour in one token. They need the full stylesheet. -
Use glow tokens instead of custom
box-shadowrings.var(--fp-glow-focus)follows the theme colours. Like the shorthands, the glows need the full stylesheet. A glow at 25% opacity is decoration, not a focus indicator on its own — keep a visible outline or border change with it. -
Match radius to context. Interactive controls (buttons) get
corner-control. Containers (cards, panels) getcorner-surface. Top-level overlays (modals) getcorner-overlay. -
Set
glowEnabled: falsein config if you don’t want glow tokens. Animated gradient tokens are already off unless you setanimatedEnabled: true. -
Floor padding on rounded elements with
--fp-inset-*.max(var(--fp-inset-surface), <your padding>)keeps content clear of a large corner without changing normal padding. Pair each inset with its corner —inset-controlwithcorner-control, and so on.