The snippet library.
Small, practical examples. Search by task or narrow things down below.
Protect a shared counter
Protect a shared counter using a complete Go program with explicit sample inputs.
Go✓ Tested
Protect shared mutable state with a mutex
Protect shared mutable state with a mutex in a complete Rust program using the standard library.
Rust✓ Tested
Provide a concise page description
HTML: A description meta element summarizes a document for clients that use that metadata.
HTML✓ Tested
Provide a configuration value with a token
Provide a configuration value with a token with a standalone Angular component and explicit browser behavior.
Angular✓ Tested
Provide a default environment value
Set a runtime default that can be overridden at startup.
Dockerfile✓ Tested
Provide a default for a missing value
Provide a default for a missing value in a complete Rust program using the standard library.
Rust✓ Tested
Provide a fallback for a nullable value
C#: The null-coalescing operator supplies a default only when the left side is null.
C#✓ Tested
Provide a fallback for an unset custom property
CSS: The second var argument supplies a value when the custom property is unavailable.
CSS✓ Tested
Provide a list of selectable options
HTML: Learn how to provide a list of selectable options in a complete browser example.
HTML✓ Tested
Provide a skip link
Let keyboard users jump directly to focusable main content.
HTML✓ Tested
Provide alternative text for an informative image
Provide alternative text for an informative image with a standalone Angular component and explicit browser behavior.
Angular✓ Tested
Provide an @empty list state
Provide an @empty list state with a standalone Angular component and explicit browser behavior.
Angular✓ Tested