w

The Slim element. w.div, w.button, w.svg and every other HTML and SVG tag are each a component that takes the element's own props and Wardic's motion props.

import { w } from "@wardic/solid" // Solid 2
import { w } from "@wardic/solid/v1" // Solid 1

<w.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} whileHover={{ scale: 1.05 }} />

It animates values with nothing else: initial, animate, exit, variants and transitions. Gestures, drag, layout and the wider colour spaces are Features. An app usually takes its w from a Wardic instance, makeWard({ features, elements }) (on Solid 1, createWardic(features)), whose elements bring those Features and take their props alone. The binding's own w, imported from @wardic/solid or @wardic/solid/v1, has those its WardicProvider and, on Solid 1, any LazyWardic above it give, and a prop whose Feature isn't there does nothing, with a warning in development. A strict section allows either, where it throws for wardic.

Its forms

FormWhat it is
w.<tag>The element for that tag.
w.create(Component, options?)Your own component as a Wardic element. It must forward ref to its root element, and pass its other props there, style among them.
w.ward(config, options?)Solid 2: a ward to spread on an element of your own, or to give a component's wardRef.
w.createWard(config)Solid 1: a ward to spread on an element of your own.
use:w={config}Solid 1: the same, as a directive. It attaches in the browser only, so on a server-rendered page its element can flash.

w.create

const Card = (props: { ref?: (el: HTMLElement) => void }) => <article ref={props.ref} {...props} />
const WCard = w.create(Card)

<WCard animate={{ opacity: 1 }} />

Its options, WardicCreateOptions:

Option
forwardMotionPropsHand the motion props on to the component as well, as Motion's does. They still drive the element. Default false.
type"svg" for an element inside an <svg>, whose attribute keys (d, cx, pathLength) render as attributes on the server; "html" renders every key as style. Left out, a tag's own name decides, and a component's element is HTML.

Coming from Motion

w.div is Motion's m.div under LazyMotion, and w.create its motion.create. Motion's Features load for the whole page; Wardic's are its Wardic instance's, or the section's that gives them.

Types

  • W: the type of w.
  • WardicCreateOptions: w.create's and wardic.create's options, above.