Examples
Runnable photonic layout examples with source code and rendered layouts.
These examples show the complete path from a laylight device to a layout file and a PNG preview. Each example has the same building blocks:
- Create a layout, top-level cell, and technology definition.
- Construct a device with parameters.
- Place the device into the top-level cell with
laylight.Placer. - Export the layout to GDS and PNG.
Available examples
Straight waveguide
Create a straight waveguide with a slab and slab converters.
![]()
See Straight Waveguide for the complete code.
Ring coupler
Create a coupled ring resonator with an integrated heater.

See Ring Coupler for the complete code.
MMI splitter
Create a 1×2 multimode interference splitter with two output ports.

See MMI Splitter for the complete code.
Directional coupler
Bring two waveguides together for a defined coupling length, then separate them again.

See Directional Coupler for the complete code.
Spiral delay
Pack a long optical path into a compact spiral footprint.

See Spiral Delay for the complete code.
Mach–Zehnder interferometer
Assemble a 1×2 MZI from MMI splitters, S-bends, and waveguide arms.

See Mach–Zehnder Interferometer for the complete code.
Run the package examples
The repository also includes a small command-line package that writes all six GDS examples to a directory:
uv run --package laylight-examples laylight-examples --output-dir build/examplesThe page-specific snippets additionally export a PNG preview, which is useful when checking the result without opening KLayout.