Create your first component

Learn how to create a component in Parcel.

Creating a component

You can create a new component by clicking the + button in the file explorer, and clicking New component (just as you would a new file or folder).

Up close image of the file explorer, which contains one file. The + button at the top has been clicked, revealing a menu with four options: "New Email", "New Component", "New Folder", and "Upload". The "New Component" option is selected.
Screenshot showing how to create a new component

Component filename

Give the component a descriptive filename. Component filenames cannot contain /,\,|, <, >, :. ",?,*, . and must be less than 100 characters. You can differentiate files, folders, and components in the file explorer by their icon.

Up close image of the file explorer, which contains a folder, an email, and a component.
Screenshot showing the different icons for folders, files, and components

The component filename (as seen in the file explorer) is unimportant for component use.

Component name

When you create a component, the HTML editor window will be replaced by the component editor window. At the top of this window is the Component Name. The Component Name is the same as the component filename by default, but can be changed independent of the component filename. Component names must only contain letters, numbers, and hyphens - no other characters are permitted. Component names must start with a letter. They cannot contain consecutive hyphens (--) or exactly match HTML reserved keywords (ex: 'button').

Up close image of the file tree and editor, with a component open. The component filename (in the file tree on the left) is labeled with an annotation to clarify the difference between it and the component name (in the top of the editor), which is similarly annotated.
Screenshot showing the component filename and component name

Getting started

Only <component>, <fieldset>, and <style> tags are allowed at the top level in a component. Attempting to use other tags at the top level will result in a warning.

Everything inside a <component> </component> tag will be rendered when the component is used. Let's start with a simple component called my-first-component:

<component> This will get rendered when this component is used. </component>

Use this component in an email:

<html>
<body>
A simple email
<my-first-component></my-first-component>
</body>
</html>

The resulting source code will be:

<html>
<body>
A simple email
This will get rendered when this component is used.
</body>
</html>

Any changes made to the component will propagate to every instance of the component's use.

Jumping back to the component

When you use a component you may want to quickly jump back to it. You can do so by pressing CMD/CTRL + Click on a component to jump to the component file.

Silent video of the full Parcel window. An email containing several custom components is open. The cursor moves to and command clicks on the component's tag in the HTML, and that component is opened in a new editor tab.
Screen recording demonstrating pressing CMD/CTRL + Click to jump to a component file