Layout Components
Below is a list of layout components available to help you compose your editor interface.
Rowβ
A component that arranges its child components in a horizontal row layout.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
layout: {
default: {
type: 'column',
style: { height: '100%' },
children: [
{
type: 'row',
className: 'custom-classname-row',
style: { color: 'white', padding: 3, height: 30, gap: 10 },
children: [
{ type: 'text', style: { backgroundColor: 'green' }, content: 'Text 1' },
{ type: 'text', style: { backgroundColor: 'green' }, content: 'Text 2' },
'Text 3'
]
},
{ type: 'canvas' },
{ type: 'row', children: 'Footer text' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
layout: {
default: {
type: 'column',
style: { height: '100%' },
children: [
{
type: 'row',
className: 'custom-classname-row',
style: { color: 'white', padding: 3, height: 30, gap: 10 },
children: [
{ type: 'text', style: { backgroundColor: 'green' }, content: 'Text 1' },
{ type: 'text', style: { backgroundColor: 'green' }, content: 'Text 2' },
'Text 3'
]
},
{ type: 'canvas' },
{ type: 'row', children: 'Footer text' }
]
},
}
})
You can easily customize the component, as with all layout components, by applying className and style properties.
Row propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | row | Type of the layout component. |
alignItems | string | The alignment of inner components along the cross axis. Example |
as | string | The HTML tag to use for the layout component. Example |
children | Layout component | The children layout components. Example |
className | string | The CSS class name(s) for the component. Example |
full | boolean | If true, the component will take up the full available space. Default |
gap | number | The gap between inner components. Example |
grow | boolean | If true, the component will grow to fill available space. Default |
height | string, number | The height of the component. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
justifyContent | string | The alignment of inner components along the main axis. Example |
style | object | The inline styles for the component. Example |
width | string, number | The width of the component. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioRow } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioRow />
</StudioEditor>
Columnβ
Similar to the row, the column component arranges its children in a vertical layout.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: '200px' },
children: ['Text 1', 'Text 2']
},
{ type: 'canvas' },
{
type: 'column',
style: { width: '200px' },
children: 'Text 1'
}
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: '200px' },
children: ['Text 1', 'Text 2']
},
{ type: 'canvas' },
{
type: 'column',
style: { width: '200px' },
children: 'Text 1'
}
]
},
}
})
Column propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | column | Type of the layout component. |
alignItems | string | The alignment of inner components along the cross axis. Example |
as | string | The HTML tag to use for the layout component. Example |
children | Layout component | The children layout components. Example |
className | string | The CSS class name(s) for the component. Example |
full | boolean | If true, the component will take up the full available space. Default |
gap | number | The gap between inner components. Example |
grow | boolean | If true, the component will grow to fill available space. Default |
height | string, number | The height of the component. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
justifyContent | string | The alignment of inner components along the main axis. Example |
style | object | The inline styles for the component. Example |
width | string, number | The width of the component. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioColumn } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioColumn />
</StudioEditor>
Textβ
A basic text element that can be added to components accepting children. Text can be included either directly as a string or as an object { type: 'text', content: '...' }. For usage examples, see the configurations above.
Text propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | text | Type of the layout component. |
content* | string | Content of the text. Example |
as | string | The HTML tag to use for the layout component. Example |
children | Layout component | The children layout components. Example |
className | string | The CSS class name(s) for the component. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
style | object | The inline styles for the component. Example |
Iconβ
An icon component that renders one of the built-in Studio icons or a custom SVG path.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'row',
style: { alignItems: 'center', gap: 10, padding: 10 },
children: [
{ type: 'icon', icon: 'layers', size: '20px' },
{ type: 'text', content: 'Layers' },
{ type: 'icon', icon: '<svg viewBox="0 0 24 24"><path d="M12 3L4 9L12 15L20 9L12 3Z" /></svg>', size: 18 }
]
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'row',
style: { alignItems: 'center', gap: 10, padding: 10 },
children: [
{ type: 'icon', icon: 'layers', size: '20px' },
{ type: 'text', content: 'Layers' },
{ type: 'icon', icon: '<svg viewBox="0 0 24 24"><path d="M12 3L4 9L12 15L20 9L12 3Z" /></svg>', size: 18 }
]
},
{ type: 'canvas' }
]
},
}
})
Icon propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | icon | Type of the layout component. |
as | string | The HTML tag to use for the layout component. Example |
children | Layout component | The children layout components. Example |
className | string | The CSS class name(s) for the component. Example |
horizontal | boolean | Whether to flip the icon horizontally. |
htmlAttrs | object | The HTML attributes for the component. Example |
icon | string | The icon to display. Can be an IconNames enum value or an SVG path string. Example |
id | string | The unique identifier for the component. Example |
rotate | number | Rotation angle in degrees. Example |
size | string, number | The size of the icon. Example |
style | object | The inline styles for the component. Example |
vertical | boolean | Whether to flip the icon vertically. |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioIcon } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioIcon icon="layers" size="20px" />
</StudioEditor>
Tabsβ
A component that organizes content into a tabbed layout, enabling users to switch between different sections.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Add dynamic tab by selecting the heading component</h1><div>Some content</div>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{ type: 'canvas' },
{
type: 'column',
style: { width: 300 },
children: {
type: 'tabs',
value: 'tab2', // default selected tab
tabs: [ // tab id and label are required
{ id: 'tab1', label: 'Tab 1', children: ['Content Tab 1'] },
{ id: 'tab2', label: 'Tab 2', children: 'Content Tab 2' }
],
editorEvents: { // Update tabs state based on editor events
'component:selected': ({ editor, state, setState }) => {
const customTabId = 'tabHeading';
const initialTabs = state.tabs?.filter(tab => tab.id !== customTabId) || [];
if (editor.getSelected()?.get('type') === 'heading') {
setState({
value: customTabId,
tabs: [...initialTabs, { id: 'tabHeading', label: 'Heading', children: ['Selected heading'] }]
});
} else {
setState({ tabs: initialTabs });
}
}
}
}
}
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Add dynamic tab by selecting the heading component</h1><div>Some content</div>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{ type: 'canvas' },
{
type: 'column',
style: { width: 300 },
children: {
type: 'tabs',
value: 'tab2', // default selected tab
tabs: [ // tab id and label are required
{ id: 'tab1', label: 'Tab 1', children: ['Content Tab 1'] },
{ id: 'tab2', label: 'Tab 2', children: 'Content Tab 2' }
],
editorEvents: { // Update tabs state based on editor events
'component:selected': ({ editor, state, setState }) => {
const customTabId = 'tabHeading';
const initialTabs = state.tabs?.filter(tab => tab.id !== customTabId) || [];
if (editor.getSelected()?.get('type') === 'heading') {
setState({
value: customTabId,
tabs: [...initialTabs, { id: 'tabHeading', label: 'Heading', children: ['Selected heading'] }]
});
} else {
setState({ tabs: initialTabs });
}
}
}
}
}
]
},
}
})
Each tab within the tabs property must include an id and label property. Additionally, the value property can be set to specify the default selected tab.
Tabs propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | tabs | Type of the layout component. |
tabs* | array | Tabs configuration. Example |
className | string | The CSS class name(s) for the component. Example |
editorEvents | object | Update layout component state based on editor events. Example |
id | string | The unique identifier for the component. Example |
onChange | function | The function to call when the field value changes. Example |
style | object | The inline styles for the component. Example |
value | string | Tab id value to select on initial render. Example |
variant | string | Variant of the tabs. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioTabs } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioTabs
tabs={[
{ id: 'tab1', label: 'Tab 1', children: <div>Content Tab 1</div> },
{ id: 'tab2', label: 'Tab 2', children: <div>Content Tab 2</div> }
]}
/>
</StudioEditor>
Buttonβ
A button component that can be used to trigger actions.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 100, justifyContent: 'center', alignItems: 'center', gap: 5 },
children: [
{
type: 'button',
label: 'Button',
variant: 'outline',
onClick: () => alert('Button clicked')
},
{
type: 'button',
label: 'Button',
icon: 'close',
size: 's',
tooltip: 'Button tooltip',
style: { padding: 5, backgroundColor: 'red', color: 'white' },
onClick: ({ editor }) => alert('Num of pages: ' + editor.Pages.getAll().length)
},
{
type: 'button',
icon: '<svg viewBox="0 0 24 24"><path d="M12 2C11.5 2 11 2.19 10.59 2.59L2.59 10.59C1.8 11.37 1.8 12.63 2.59 13.41L10.59 21.41C11.37 22.2 12.63 22.2 13.41 21.41L21.41 13.41C22.2 12.63 22.2 11.37 21.41 10.59L13.41 2.59C13 2.19 12.5 2 12 2M11 7H13V13H11V7M11 15H13V17H11V15Z" style="fill: currentcolor;"></path></svg>',
variant: 'primary',
onClick: () => alert('Icon only button')
},
{
type: 'button',
icon: 'check',
active: true,
onClick: ({ state, setState }) => {
const newActive = !state.active;
alert('Is to activate?: ' + newActive);
setState({ active: newActive });
}
}
]
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 100, justifyContent: 'center', alignItems: 'center', gap: 5 },
children: [
{
type: 'button',
label: 'Button',
variant: 'outline',
onClick: () => alert('Button clicked')
},
{
type: 'button',
label: 'Button',
icon: 'close',
size: 's',
tooltip: 'Button tooltip',
style: { padding: 5, backgroundColor: 'red', color: 'white' },
onClick: ({ editor }) => alert('Num of pages: ' + editor.Pages.getAll().length)
},
{
type: 'button',
icon: '<svg viewBox="0 0 24 24"><path d="M12 2C11.5 2 11 2.19 10.59 2.59L2.59 10.59C1.8 11.37 1.8 12.63 2.59 13.41L10.59 21.41C11.37 22.2 12.63 22.2 13.41 21.41L21.41 13.41C22.2 12.63 22.2 11.37 21.41 10.59L13.41 2.59C13 2.19 12.5 2 12 2M11 7H13V13H11V7M11 15H13V17H11V15Z" style="fill: currentcolor;"></path></svg>',
variant: 'primary',
onClick: () => alert('Icon only button')
},
{
type: 'button',
icon: 'check',
active: true,
onClick: ({ state, setState }) => {
const newActive = !state.active;
alert('Is to activate?: ' + newActive);
setState({ active: newActive });
}
}
]
},
{ type: 'canvas' }
]
},
}
})
The component accepts a label property for the button text, an icon that can be an SVG string or a default icon name and additional properties to customize the button layout (eg. variant, size).
Inside the onClick property, you have access to the GrapesJS editor instance, as well as the state and setState, which allow you to interact with the editor or modify the current button's state.
In the Layout Commands section, you'll find more examples of button usage for managing editor layouts.
Button propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | button | Type of the layout component. |
active | boolean | Indicates if the button is active. Default |
as | string | The HTML tag to use for the layout component. Example |
buttonType | string | HTML button type attribute. Example |
children | Layout component | The children layout components. Example |
className | string | The CSS class name(s) for the component. Example |
classNameBtn | string | Class name for the inner button element. Example |
disabled | boolean | Indicates whether the component is disabled. Default |
editorEvents | object | Events to be handled by the editor. Example |
icon | string | Icon to be displayed in the button. Example |
id | string | The unique identifier for the component. Example |
label | string | Label for the button, can be a ReactNode or a function returning a ReactNode. Example |
onClick | function | Click event handler for the button. Example |
size | string | Size of the button. Example |
style | object | The inline styles for the component. Example |
tooltip | string | Tooltip text for the button. Example |
variant | string | Variant of the button style. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioButton } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioButton />
</StudioEditor>
ButtonMenuβ
A button component with a dropdown menu, useful for creating toolbar actions with options or custom popover content.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 200, justifyContent: 'center', alignItems: 'center', gap: 10 },
children: [
// ButtonMenu with options - label auto-generated from selected option
{
type: 'buttonMenu',
size: 's',
value: 'left',
options: [
{ id: 'left', icon: '<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>' },
{ id: 'center', icon: '<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>' },
{ id: 'right', icon: '<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>' }
],
onOptionSelect: ({ option, setState }) => {
setState({ value: option.id });
alert('Selected: ' + option.id);
},
onClick: ({ state }) => alert('Current value: ' + state.value)
},
// ButtonMenu with options using labels
{
type: 'buttonMenu',
size: 's',
value: 'h1',
options: [
{ id: 'h1', label: 'Heading 1' },
{ id: 'h2', label: 'Heading 2' },
{ id: 'h3', label: 'Heading 3' }
],
onOptionSelect: ({ option, setState }) => {
setState({ value: option.id });
}
},
// ButtonMenu with custom label function
{
type: 'buttonMenu',
size: 's',
value: '#ff0000',
label: ({ state }) => ({
type: 'column',
style: { alignItems: 'center' },
children: [
{ type: 'icon', icon: '<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>', size: 16 },
{ type: 'row', style: { width: 16, height: 2, backgroundColor: state.value || 'currentColor', borderRadius: 1 } }
]
}),
children: ({ state, setState }) => ({
type: 'colorPicker',
value: state.value || '',
onChange: ({ value, setState: setStateColorPicker }) => {
setState({ value });
setStateColorPicker({ value });
}
}),
onClick: ({ state }) => alert('Apply color: ' + state.value)
}
]
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 200, justifyContent: 'center', alignItems: 'center', gap: 10 },
children: [
// ButtonMenu with options - label auto-generated from selected option
{
type: 'buttonMenu',
size: 's',
value: 'left',
options: [
{ id: 'left', icon: '<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>' },
{ id: 'center', icon: '<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>' },
{ id: 'right', icon: '<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>' }
],
onOptionSelect: ({ option, setState }) => {
setState({ value: option.id });
alert('Selected: ' + option.id);
},
onClick: ({ state }) => alert('Current value: ' + state.value)
},
// ButtonMenu with options using labels
{
type: 'buttonMenu',
size: 's',
value: 'h1',
options: [
{ id: 'h1', label: 'Heading 1' },
{ id: 'h2', label: 'Heading 2' },
{ id: 'h3', label: 'Heading 3' }
],
onOptionSelect: ({ option, setState }) => {
setState({ value: option.id });
}
},
// ButtonMenu with custom label function
{
type: 'buttonMenu',
size: 's',
value: '#ff0000',
label: ({ state }) => ({
type: 'column',
style: { alignItems: 'center' },
children: [
{ type: 'icon', icon: '<svg viewBox="0 0 24 24"><path d="M9.62,12L12,5.67L14.37,12M11,3L5.5,17H7.75L8.87,14H15.12L16.25,17H18.5L13,3H11Z" /></svg>', size: 16 },
{ type: 'row', style: { width: 16, height: 2, backgroundColor: state.value || 'currentColor', borderRadius: 1 } }
]
}),
children: ({ state, setState }) => ({
type: 'colorPicker',
value: state.value || '',
onChange: ({ value, setState: setStateColorPicker }) => {
setState({ value });
setStateColorPicker({ value });
}
}),
onClick: ({ state }) => alert('Apply color: ' + state.value)
}
]
},
{ type: 'canvas' }
]
},
}
})
The buttonMenu component provides two ways to define the dropdown content:
-
Using
options: Define an array of options withid,label, and/oricon. -
Using
children: For custom popover content, provide a function that returns any layout component configuration. This is useful for more complex interactions (eg. color picker).
The onClick callback is triggered when clicking the main button area (not the dropdown arrow), allowing you to apply the current value directly.
ButtonMenu propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | buttonMenu | Type of the layout component. |
active | boolean | Indicates if the button is active. Default |
as | string | The HTML tag to use for the layout component. Example |
buttonType | string | HTML button type attribute. Example |
children | Layout component | Children layout to render inside the popover menu. This is a function that receives state and returns a layout configuration. |
className | string | The CSS class name(s) for the component. Example |
classNameBtn | string | Class name for the inner button element. Example |
disabled | boolean | Indicates whether the component is disabled. Default |
editorEvents | object | Events to be handled by the editor. Example |
icon | string | Icon to be displayed in the button. Example |
iconMenu | string | Icon to display for the dropdown menu trigger. Default |
id | string | The unique identifier for the component. Example |
label | function | Label for the button. Can be a string or a function that receives state and returns label config. Example |
onClick | function | Click event handler for the button. Example |
onClickMenu | function | Callback function triggered when the menu icon is clicked. If provided, the default behavior will be skipped. |
onOptionChange | function | Callback function triggered when an option is selected (when using options). |
options | array | Optional predefined options for the menu. When provided, spawns a popover with menu items. |
size | string | Size of the button. Example |
style | object | The inline styles for the component. Example |
tooltip | string | Tooltip text for the button. Example |
value | string | Current value stored in the button menu state. |
variant | string | Variant of the button style. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioButtonMenu } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioButtonMenu />
</StudioEditor>
Devicesβ
Displays the available devices that users can switch between in the editor canvas for responsive style editing. The component is connected to the GrapesJS Devices API.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
layout: {
default: {
type: 'column',
style: { height: '100%' },
children: [
{
type: 'row',
style: { justifyContent: 'center', alignItems: 'center', gap: 5 },
children: [
{
type: 'button',
label: 'Add Random Device',
onClick: ({ editor }) => {
const width = `${Math.floor(Math.random() * (1000 - 500 + 1) + 500)}px`;
const name = `Random ${width}`;
editor.Devices.add({ id: `random-${width}`, name, width });
alert(`Created "${name}"`);
}
},
{ type: 'devices', style: { width: '100px' } }
]
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
layout: {
default: {
type: 'column',
style: { height: '100%' },
children: [
{
type: 'row',
style: { justifyContent: 'center', alignItems: 'center', gap: 5 },
children: [
{
type: 'button',
label: 'Add Random Device',
onClick: ({ editor }) => {
const width = `${Math.floor(Math.random() * (1000 - 500 + 1) + 500)}px`;
const name = `Random ${width}`;
editor.Devices.add({ id: `random-${width}`, name, width });
alert(`Created "${name}"`);
}
},
{ type: 'devices', style: { width: '100px' } }
]
},
{ type: 'canvas' }
]
},
}
})
Devices propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | devices | Type of the layout component. |
as | string | The HTML tag to use for the layout component. Example |
className | string | The CSS class name(s) for the component. Example |
id | string | The unique identifier for the component. Example |
style | object | The inline styles for the component. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioDevices } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioDevices />
</StudioEditor>
PanelPagesβ
Displays the pages of the project. The component is connected to the GrapesJS Pages API and the Pages configuration.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
children: {
type: 'panelPages',
style: { width: 300 },
header: { label: 'My pages', collapsible: false }
}
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
children: {
type: 'panelPages',
style: { width: 300 },
header: { label: 'My pages', collapsible: false }
}
},
{ type: 'canvas' }
]
},
}
})
PanelPages propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | panelPages | Type of the layout component. |
as | string | The HTML tag to use for the layout component. Example |
className | string | The CSS class name(s) for the component. Example |
header | object | Header of the panel. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
resizable | object | Resizable configuration of the panel. Example |
style | object | The inline styles for the component. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioPanelPages } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioPanelPages />
</StudioEditor>
PanelPageSettingsβ
Displays the Page Settings panel, allowing users to configure settings for individual pages.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 300 },
children: { type: 'panelPageSettings' }
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 300 },
children: { type: 'panelPageSettings' }
},
{ type: 'canvas' }
]
},
}
})
PanelPageSettings propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | panelPageSettings | Type of the layout component. |
as | string | The HTML tag to use for the layout component. Example |
className | string | The CSS class name(s) for the component. Example |
header | object | Header of the panel. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
page | Page | The page to display settings for. Example |
resizable | object | Resizable configuration of the panel. Example |
style | object | The inline styles for the component. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioPanelPageSettings } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioPanelPageSettings />
</StudioEditor>
PanelLayersβ
Displays the layers of the currently selected page. The component is connected to the GrapesJS Layers API. enabling users to manage and organize their design layers efficiently.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 300 },
children: {
type: 'panelLayers',
header: {
label: 'Layers label',
icon: '<svg viewBox="0 0 24 24"><path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"/></svg>'
}
}
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
style: { width: 300 },
children: {
type: 'panelLayers',
header: {
label: 'Layers label',
icon: '<svg viewBox="0 0 24 24"><path d="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z"/></svg>'
}
}
},
{ type: 'canvas' }
]
},
}
})
PanelLayers propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | panelLayers | Type of the layout component. |
as | string | The HTML tag to use for the layout component. Example |
className | string | The CSS class name(s) for the component. Example |
header | object | Header of the panel. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
resizable | object | Resizable configuration of the panel. Example |
style | object | The inline styles for the component. Example |
React componentβ
This component is also exported for React consumers. See React Layout Components for the complete setup.
import StudioEditor, { StudioPanelLayers } from '@grapesjs/studio-sdk/react';
<StudioEditor options={{...}} withComponents>
<StudioPanelLayers />
</StudioEditor>
PanelPagesLayersβ
Displays a combined panel that includes both the PanelPages and PanelLayers. This component provides a comprehensive view for managing project pages and their respective layers in a unified interface.
- React
- JS
- π Β Demo
import StudioEditor from '@grapesjs/studio-sdk/react';
import '@grapesjs/studio-sdk/style';
// ...
<StudioEditor
options={{
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
children: {
type: 'panelPagesLayers',
resizable: { right: true, width: 300, height: '100%', minWidth: 200, maxWidth: 300 },
panelPagesProps: { header: { label: 'My Pages' } },
panelLayersProps: { header: { label: 'My Layers' } }
}
},
{ type: 'canvas' }
]
},
}
}}
/>
import createStudioEditor from '@grapesjs/studio-sdk';
import '@grapesjs/studio-sdk/style';
// ...
createStudioEditor({
// ...
project: {
default: {
pages: [{ name: 'Home', component: '<h1>Home page</h1>'}]
}
},
layout: {
default: {
type: 'row',
style: { height: '100%' },
children: [
{
type: 'column',
children: {
type: 'panelPagesLayers',
resizable: { right: true, width: 300, height: '100%', minWidth: 200, maxWidth: 300 },
panelPagesProps: { header: { label: 'My Pages' } },
panelLayersProps: { header: { label: 'My Layers' } }
}
},
{ type: 'canvas' }
]
},
}
})
PanelPagesLayers propertiesβ
Show properties
| Property | Type | Description |
|---|---|---|
type* | panelPagesLayers | Type of the layout component. |
as | string | The HTML tag to use for the layout component. Example |
className | string | The CSS class name(s) for the component. Example |
header | object | Header of the panel. Example |
htmlAttrs | object | The HTML attributes for the component. Example |
id | string | The unique identifier for the component. Example |
panelLayersProps | PanelLayersProps | Properties for the panel layers. Example |
panelPagesProps | PanelPagesProps | Properties for the panel pages. Example |
resizable | object | Resizable configuration of the panel. Example |
style | object | The inline styles for the component. Example |