Default components
Add a component to the shared @olgax.com/components library - a 15 minute walkthrough that builds a Spacer block with registerComponent and CSS tokens.
This page is for contributors adding to the shared library that every site can install. To build blocks for one site, see Custom components.
Rules for library components
- A typed props interface and a
registerComponent("Name", { fields, defaultProps, render })call. SeeHero.tsx. - A co-located
.cssfile that uses--olgax-*custom properties (seetokens.css) and no hard-coded colors or spacing, so it stays themeable. - Imported from
src/index.tsfor its registration side effect. - No client-only hooks (
useStateand similar) inrender. Components must work in the Puck editor (client) and in<Render>(which can run on the server).
Walkthrough: a Spacer block
Create the component
packages/components/src/blocks/Spacer.tsx:
import { registerComponent } from "@olgax.com/sdk";
export type SpacerProps = {
height: number;
};
const Spacer = ({ height }: SpacerProps) => <div style={{ height }} />;
registerComponent<SpacerProps>("Spacer", {
fields: {
height: { type: "number" },
},
defaultProps: {
height: 32,
},
render: (props) => <Spacer {...props} />,
});Register it in the package index
Add one line to packages/components/src/index.ts, next to the other blocks:
import "./blocks/Spacer";Run it locally
pnpm --filter demo devOpen http://localhost:3000/home/edit. Spacer is in the block list. Next transpiles
@olgax.com/components straight from source, so there is no build step. Drag it onto the canvas and check the
height field.
Document it
Add a short section to packages/components/README.md showing the props as a Data.content item, following the
existing entries.
Check types
pnpm --filter demo buildPuck's config types are stricter than editor diagnostics, so a full build is the reliable check.
Add a changeset for your change. See Releasing.
Need a review or a second opinion?
Share your branch in the Olgax Discord and ask for feedback.
Questions, ideas or something not working?
Ask in our official Discord, open an issue on GitHub, or edit this page.
Local development
Set up the Olgax DXP monorepo locally - pnpm and Turborepo workspace layout, running the demo site, tests, lint and build, and how to open a good pull request.
Releasing
How Olgax DXP packages are versioned and published to npm with Changesets, the automated Version Packages pull request and npm Trusted Publishing.