Jedd Icons

Options

Every option accepted by the vanilla helpers.

The vanilla package exposes the shared styling model as createElement options, plus a couple specific to imperative rendering and the createIcons helper.

createElement options

Prop

Type

createIcons options

Prop

Type

Both packages share the same styling model: four knobs — size, color, strokeWidth, and absoluteStrokeWidth. Only the surface syntax differs (React props vs createElement options).

How color works

color sets the stroke attribute; the interior stays transparent (fill: none).

How absoluteStrokeWidth works

Normally a stroke scales with the icon: a strokeWidth of 2 looks thicker at size={48} than at size={24}. With absoluteStrokeWidth, the rendered stroke is computed as:

renderedStrokeWidth = strokeWidth × 24 / size

So the visual thickness matches your strokeWidth value at any size — handy when icons of different sizes need to read as the same weight.

CSS hooks

Icons rendered by the React components or by createIcons carry two class names you can target globally: jedd (on every icon) and jedd-<name> (per icon, in kebab-case). Any class name you pass is appended to these. createElement only receives the icon's data, not its name, so it adds no classes: pass your own with the class option.

.jedd {
  vertical-align: middle;
}
.jedd-arrow-down-left {
  /* style one specific icon */
}

You can also set defaults for every icon this way, for example a lighter stroke:

.jedd {
  stroke-width: 1.5;
}

CSS takes precedence over the attributes the options set, so where a rule like this applies, setting strokeWidth on a single icon has no effect.

To keep the stroke the same visual thickness at any size with CSS — the equivalent of absoluteStrokeWidth, but also when the size comes from CSS width / height — add vector-effect to the icon's shapes:

.jedd * {
  vector-effect: non-scaling-stroke;
}

Exported helpers and types

import {
  createElement,
  createIcons,
  defaultAttributes,
  variantDefaults,
  resolveStrokeWidth,
} from "@jedd-icons/core";
import type {
  IconNode,
  Variant,
  CreateElementOptions,
  CreateIconsOptions,
} from "@jedd-icons/core";
  • createElement(iconNode, options?) — builds an <svg> element from an icon's data.
  • createIcons(options?) — replaces data-jedd placeholders in the page with icons. Returns a function that stops watch (a no-op without it).
  • variantDefaults — the attributes set on the root <svg> for each variant (only stroke today): viewBox, size, fill / stroke, the stroke width, line caps and joins. createElement starts from these before applying its options; use them to render icons yourself, for example as an SVG string.
  • defaultAttributes — the same as variantDefaults.stroke, kept for backward compatibility.
  • resolveStrokeWidth(strokeWidth, size, absolute) — the stroke width an icon renders with: strokeWidth × 24 / size when absolute is true, otherwise strokeWidth unchanged (see How absoluteStrokeWidth works).
  • IconNode — the raw icon geometry tuple.
  • Variant — "stroke".
  • CreateElementOptions / CreateIconsOptions — the options above.

On this page