Color & Effects

Lighting & Depth

Lighting & Depth gives a thing believable height with one control. Set its elevation and Nox draws a soft shadow of five layers, each further, wider and fainter than the last, the way real light falls. Add a rim and the edge that faces the light catches it. It is the fastest way to make cards, buttons and floating panels look as if they belong to one lit world, and it keeps every shadow in a design consistent.

The same card at elevation 8, 24, 48 and 80
The same card at elevation 8, 24, 48 and 80

The control#

FieldIn the toolsRangeDefaultWhat it does
Elevationelevation0–1000How far the thing stands off what is under it
Softnesssoftness0–10050How diffuse the shadow is
Tinttint0–1000How much of the thing's own color is in its shadow
Angleangle0–3600Where the light is, in degrees clockwise from straight above
Rimrim0–1000How bright the lit edge is
Widthrim_width0.5–81How wide the lit edge is
Intensityintensity0–10050How dark the shadow is: 50 is a card on a light ground, 100 twice as dark
Offsetoffset0–10050How far the shadow is cast: 0 straight under, all round; 50 a quarter of the elevation
Each field at two values; the rim on a dark ground, where a lit edge is what tells height
Each field at two values; the rim on a dark ground, where a lit edge is what tells height

Some things to know about each:

  • Elevation is the one to set first. Under 10 for rows and chips, about 16–24 for cards, 48–64 for menus and popovers, 80 and above for sheets and dialogs.
  • Softness high reads as a large, distant light; low as a near, hard one. Keep one softness across a screen.
  • Tint at 60–80 on a colored button puts its own hue in the shadow, which looks richer than gray under a saturated color.
  • Angle 0 lights from above, so the shadow falls down. 90 is light from the right, so the shadow falls left.
  • Rim is a white edge on the side facing the light, with a faint line all round. On a dark ground a shadow has little to darken, and the rim is what shows height: use 40–80 there.
  • Intensity and Offset are for when the defaults are wrong for the ground: raise intensity on a mid-gray background, lower offset for a thing that floats straight up, such as a modal.

Set it by hand#

By hand
  1. Select a frame or a shape. In the inspector, open Lighting & Depth with the + at the right of its title. (Shut, its title says what the selection uses, as · elevation 24, rim.)
  2. Drag on a field's label to scrub it, or click the field and type. Each change is one step of undo.
  3. Copy SwiftUI and Copy CSS, at the foot of the section, copy the thing with its depth as code.
The Lighting & Depth section, open
The Lighting & Depth section, open

The shadows of a depth are not listed under Effects. They are drawn from these eight numbers, in the canvas, in every export and in the code, so they never drift from the control. You can still add your own effects beside a depth.

With an agent
Give the stats card the depth of a resting card, and the Upgrade button a lifted, tinted look with a light rim.

The agent calls update_nodes:

{
  "changes": [
    {"id": "3:2", "depth": {"elevation": 16, "softness": 60}},
    {"id": "3:3", "depth": {"elevation": 20, "softness": 40, "tint": 70, "rim": 30}}
  ]
}

depth is given whole: a field left out goes back to its default, it is not kept from before. null removes the depth.

One light for a whole screen#

A screen looks lit when all its shadows agree about where the light is. Make that a fact rather than a habit: put the angle in a number variable and have every card follow it. Change the variable, or switch the mode, and every shadow and rim on the screen turns together.

Two copies of a screen, their cards following one light: the angle at 315 in the morning, at 60 with a rim in the evening
Two copies of a screen, their cards following one light: the angle at 315 in the morning, at 60 with a rim in the evening
By hand
  1. In Variables on the rail, add a number named light/angle, with a value for each mode you need (see Variables and modes).
  2. Select the cards, right-click the Angle field in Lighting & Depth, and choose the variable under Follow a Variable.
With an agent
Make a Light set with Day and Night modes and a light/angle of 0 by day and 60 at night. Make the two cards follow it.

The agent calls set_variables:

{"set": "Light", "modes": ["Day", "Night"], "variables": [{"name": "light/angle", "values": {"Day": 0, "Night": 60}}]}

Then update_nodes, binding each card's angle:

{
  "changes": [
    {"id": "3:2", "bindings": {"depth_angle": "light/angle"}},
    {"id": "3:3", "bindings": {"depth_angle": "light/angle"}}
  ]
}

Elevation, softness, tint, angle, rim and width can each follow a variable (depth_elevation through depth_rim_width). A variable for elevation is a good way to keep one height per kind of thing: depth/card, depth/menu, depth/dialog.

Recipes#

A card, a button and a floating menu with the numbers each uses
A card, a button and a floating menu with the numbers each uses
ForDepthWhy
A card on a light groundelevation 16, softness 60Lifted enough to separate from the page
A primary buttonelevation 20, softness 40, tint 70, rim 30Its color in the shadow, a crisp edge on top
A menu or popoverelevation 64, softness 80, intensity 60Clearly above everything, but soft and not heavy
A card on a dark groundelevation 24, rim 50The rim does the work; the shadow barely shows

inspect writes a depth as CSS (box-shadow, five layers and two inset ones for the rim) and SwiftUI (five .shadow modifiers and a strokeBorder along the light). Where a game needs the shadow in its texture, see Export for engines.

Note

Use Lighting & Depth for anything that should feel raised, and keep hand-made shadows for special cases such as a colored glow or an inner shadow. See Shadows.