The snippet library.
Small, practical examples. Search by task or narrow things down below.
Compose a component with named content slots
Compose a component with named content slots with a small React component and explicit browser behavior.
React✓ Tested
Connect a reusable label using useId
Connect a reusable label using useId with a small React component and explicit browser behavior.
React✓ Tested
Customize a renderer through a function prop
Customize a renderer through a function prop with a small React component and explicit browser behavior.
React✓ Tested
Destructure nested data in a component
Destructure nested data in a component with a small React component and explicit browser behavior.
React✓ Tested
Forward input props to a reusable field
Forward input props to a reusable field with a small React component and explicit browser behavior.
React✓ Tested
Notify a parent with a callback prop
Notify a parent with a callback prop with a small React component and explicit browser behavior.
React✓ Tested
Pass an input ref as a React 19 prop
Pass an input ref as a React 19 prop with a small React component and explicit browser behavior.
React✓ Tested
Reset child state by changing its key
Reset child state by changing its key with a small React component and explicit browser behavior.
React✓ Tested
Select a component variant explicitly
Select a component variant explicitly with a small React component and explicit browser behavior.
React✓ Tested