Skip to Content
sdeck docs

Looks

The helpers that build a look.

A look is a background and layers (text, images, bars and rectangles) that sdeck draws. Users can change any of it in the composer. @sdeck/schema has the two that most keys need:

// An icon, with a caption under it if there is one.
look: (s) => iconLook({ icon: "lucide/rocket", color: "#60a5fa", caption: s.text }),

// Something that is on or off: white on a colored panel while on, gray while off.
look: () => switchLook({ icon: "lucide/mic-off", offIcon: "lucide/mic", on: muted.key, color: "#dc2626" }),

For anything else, put layers together:

FunctionGives
iconLayer, textLayeran icon or image, and text
captionLayer, iconSizethe small text under an icon, and how large the icon is then
meterLayera rounded level along the bottom, from an expression that gives 0–100
rectLayera panel, pill or dot
volumeStepLayersa speaker with a plus or minus
surface(color)a background with a little depth, as the looks above have
surfaceStyle(color)the same as CSS, for components
readable(color, background)the color, or white or black where it could not be seen
KEY, OFFthe usual dark background, and the gray of something that is off

Text can read live values: textLayer("cpu", "{{system.cpu}}%"). A layer's visible takes an expression: visible: "spotify.playing". Layers in the same position are stacked and centered together, which keeps an icon and its text in the middle of the key; row puts them side by side.

look gets the slot as its second argument. The window (248 × 58) is much wider than a key (96 × 96), so what reads well on one rarely does on the other:

look: (_, slot) => (slot === "window" ? wideLook() : keyLook()),

With a frame, a layer goes exactly where you want it:

// A red pill while live.
const look = {
  background: "#18181b",
  layers: [
    rectLayer("pill", {
      frame: { x: 15, y: 10, width: 70, height: 24 }, // in percent of the button
      fill: "#eb0400", // or a gradient
      radius: 6,
      visible: live.key,
    }),
    textLayer("live", "LIVE", {
      size: 12,
      frame: { x: 15, y: 10, width: 70, height: 24 },
      visible: live.key,
    }),
  ],
};

A look can also react to being pressed: self.held is true while its button is down.