Components are groups of cells that can be reused across Hex projects.
Components are available to workspaces on the Professional, Teams, and Enterprise plans. Workspaces on the Professional plan can share up to three components with members of their workspace. Teams and Enterprise plan can create and share unlimited components.
Components are reusable groups of cells that can be imported across projects, making it easy for your team to implement DRY practices in your Hex workflows. Changes to a component can be made once, and then propagate down into projects that rely on it. Create components from within projects or from the Components tab in your home page.
Create components from within projects
There are a few different ways to create a component from within the logic of a project. Each of the following methods begin by selecting multiple cells:
- From the graph view, select multiple cells with
command + clickor
shift+ dragging your mouse around the desired cells.
- From the logic view, select multiple cells with
command + clickor by entering command mode (
esc) and selecting additional cells (
shift + up/down arrowor
shift + j/kto select adjacent cells, or
command + clickto select any assortment of cells).
- From the 3-dot menu of a given cell, click Select cell and… to select multiple cells (all upstream, all downstream, or all upstream + downstream).
Each of these methods will result in a pop-up with an option to create a New component.
It’s also possible to create a new component from a single cell by clicking the cell’s 3-dot menu and selecting New component from cell.
Clicking New component will open a modal where you can name your component, add a description, and update which cells are selected.
The option Replace cells with component will be enabled by default; this will replace the selected cells with the component upon creation. If this option is disabled, the selected cells will remain cells and the component will not be added to the project upon creation.
Creating components from the home page
To create a component from the home page, click on the Components page in the left sidebar. This will bring you to the components explorer, where you can view existing components and create new ones. To create a component, click the + New component button.
Writing the logic of a component is very similar to writing the logic of a project. All cell types available in projects can be used in components.
Once you've written out the logic for your component, you’ll need to publish it to make it accessible within projects. The publishing flow for components is akin to project publishing — click the green Publish button in the top lefthand corner to start the process. The publish modal will display a diff view that shows the logic changes you've made since the last publish. Click Publish version to update the published version of the component.
If you update the published version of a component that's been imported in one or more projects, republishing will not force update the component in those projects. See the Update components section to learn more.
Import and use components
Components can be added to a project just like any other cell type. Use the Component button from the Add cell menu.
This will bring up an import modal that lists all the published components you have access to. From here you can preview components and import them into your project.
If you can't find a component in the import modal, double check that it's been published. Only published components appear here!
After a component has been imported into a project, its cells can be run just like any other cells. All dataframes, variables, and other outputs of a component can be referenced and used anywhere downstream of the imported component.
It's possible to view component logic from within the project, but any changes must be made within the component itself. If a user has access to the component, they'll be able to navigate to its source via the arrow next to the component's name, or via the its three-dot menu.
Component permissions are handled similarly to project permissions. See the table below for details:
|Full Access||Grants full permissions on a component, including renaming, deleting, and editing, as well as sharing and managing permissions.|
|Can Edit||Grants permission to edit, comment on, and import the component. Also grants ability to manage permissions (unless this has been disabled by a "Full Access" user).|
|Can Import||Grants permission to view, comment on, and import the component. Cannot edit or manage permissions.|
These permissions can be managed from the Share button in a Component's logic.
If a user does not have access to a component, but does have Can View, Can Edit, or Full Access permissions on a project that imports that component, the user will be able to view the component's logic within the project that imports it. The user will not inherit any permissions to the component, and will not have the option to navigate back to the component source.
When a new version of a component is published, an Update available alert will appear in each project it's been imported into.
Clicking Update available will bring you to a modal with a diff view, which allows you to compare the component's latest changes with the version that you currently have imported. From here, selecting Update component will replace the existing component in your project with the latest published version.
It is possible to eject a component's cells into a project. This will untether the cells from the component, causing the cells to simply be considered part of the project you're ejecting into.
You can eject a component that's already been added to a project via its three-dot menu. If you'd like to import a component as cells straight away, you can do so from the Import component dropdown menu in the import modal.
Since ejected cells are no longer attached to the component, you will no longer have the option to update the cells if the component changes. Ejecting cells into a project allows them to be editable from the project.
View a component's project references
To see a list of projects that a component has been imported into, click View project references under the component’s title and description.
Users who have Full Access permissions to a component have the option to delete it. This is possible via the "Move to Trash" button found in the dropdown of a component's title. Components will remain in the trash for 7 days, at which point they will be permanently deleted.
When a component has been moved to trash, a warning will appear on any projects that have imported the component.
When a component is in the trash or has been permanently deleted, it is still be possible to eject the component's cells into a project that it has been imported into.