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.

ValueCorner
roundNormal circular arc (default — no visual change)
squircleSuperellipse (smooth “iOS-style” corner)
bevelStraight diagonal chamfer
scoopConcave arc cut into the corner
notchRight-angle step cut out of the corner
squareHard right angle (arc removed)

Three usage levels, mirroring border-radius:

json
// 1. Global — theme-config
"radius": { "cornerShape": "squircle" }
css
/* 2. Scoped — override the token on any container */
.hero {
  --fp-corner-shape: squircle;
}
html
<!-- 3. Per-instance — the corner-shape attribute mirrors the CSS property -->
<fp-button corner-shape="bevel">Submit</fp-button>

Border Tokens

Width Primitives

TokenDefault
--fp-border-none0px (full stylesheet only)
--fp-border-1 to --fp-border-41px to 4px (3 and 4: full stylesheet only)
--fp-border-basevar(--fp-border-1)

Named Widths (--fp-border-w-*)

TokenDefaultUse
--fp-border-w-hairline1pxSubtle dividers
--fp-border-w-thin1.5pxNo stroke role uses it (full stylesheet only)
--fp-border-w-medium2pxFocus states, emphasis
--fp-border-w-thick3pxDecorative 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.

TokenValueUse For
--fp-stroke-hairlinevar(--fp-border-w-hairline)Thinnest subtle borders
--fp-stroke-controlvar(--fp-border-base)Interactive controls
--fp-stroke-dividervar(--fp-border-w-hairline)Separators
--fp-stroke-strongvar(--fp-border-w-medium)Focus, active states
--fp-stroke-accentvar(--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.

TokenWidth + Color
--fp-border-semantic-defaulthairline + neutral-6
--fp-border-semantic-subtlehairline + neutral-4
--fp-border-semantic-strongmedium + neutral-7
--fp-border-semantic-focusmedium + primary-text
--fp-border-semantic-dangermedium + danger-text
--fp-border-semantic-successmedium + success-text
--fp-border-semantic-accentthick + primary-text
--fp-border-semantic-dividerhairline + 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:

TokenDescription
--fp-border-gradient-brandPrimary → secondary gradient
--fp-border-gradient-subtleNeutral → 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".

TokenUse
--fp-glow-focusFocus glow (from --fp-primary-text)
--fp-glow-successSuccess state glow
--fp-glow-dangerDanger state glow
--fp-glow-warningWarning 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

css
/* 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

css
/* 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)

css
/* 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

css
/* 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

css
/* 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:

text
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:

css
/* fp-button's default inline padding */
max(var(--fp-inset-control), var(--fp-size-inset-inline))

Tokens

TokenFormula
--fp-inset-controlmax(0px, calc(min(var(--fp-corner-control), calc(var(--fp-size-box) / 2)) * factor - var(--fp-stroke-control)))
--fp-inset-surfacemax(0px, calc(var(--fp-corner-surface) * factor - var(--fp-stroke-control)))
--fp-inset-overlaymax(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

PresetFactorCharacter
"tight"0.2929Default. The geometric minimum: a content corner at that inset just clears the arc
"balanced"0.5Halfway
"generous"1.0The 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:

css
/* 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

json
{
  "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

  1. Use --fp-corner-* semantics, not --fp-radius-* primitives. corner-control for buttons, corner-surface for cards, corner-overlay for modals — the token names the corner’s purpose, and a theme can retune each one.

  2. Use --fp-border-semantic-* for whole borders. Each holds width, style and colour in one token. They need the full stylesheet.

  3. Use glow tokens instead of custom box-shadow rings. 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.

  4. Match radius to context. Interactive controls (buttons) get corner-control. Containers (cards, panels) get corner-surface. Top-level overlays (modals) get corner-overlay.

  5. Set glowEnabled: false in config if you don’t want glow tokens. Animated gradient tokens are already off unless you set animatedEnabled: true.

  6. 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-control with corner-control, and so on.