ContentKit
Learn how to build components with GitBook’s UI kit
Creating components
import { createIntegration, createComponent } from '@gitbook/runtime';
const helloWorldBlock = createComponent({
componentId: 'hello-world',
initialState: {
message: 'Say hello!'
},
action: async (previous, action) => {
switch (action.action) {
case 'say':
return { state: { message: 'Hello world' } };
}
},
render: async ({ props, state }) => {
return (
<block>
<button label={state.message} onPress={{ action: 'say' }} />
</block>
);
}
});
export default createIntegration({
components: [helloWorldBlock]
});Define a custom block
Props
State
Actions
@editor.node.updateProps
@editor.node.updateProps@ui.url.open
@ui.url.open@ui.modal.open
@ui.modal.open@ui.modal.close
@ui.modal.close@webframe.ready
@webframe.ready@webframe.resize
@webframe.resize@link.unfurl
@link.unfurlCustom Actions
Last updated
Was this helpful?