Overview of @rocket.chat/fuselage-hooks
main@rocket.chat/fuselage-hooks provides React hooks specifically designed for Fuselage, which is Rocket.Chat's design system and UI toolkit.repository·main·Indexed 41 days ago
https://github.com/rocketchat/fuselageRocket.Chat's official design system and UI toolkit provided as a monorepo. It includes a core React components library (@rocket.chat/fuselage), design tokens (@rocket.chat/fuselage-tokens), specialized React hooks (@rocket.chat/fuselage-hooks), and utility packages for forms, icons, layout, and CSS-in-JS styling.
@rocket.chat/fuselage-hooks provides React hooks specifically designed for Fuselage, which is Rocket.Chat's design system and UI toolkit.Fuselage is a monorepo containing Rocket.Chat's design system and UI toolkit. It is composed of several specialized packages that allow developers to build consistent Rocket.Chat interfaces using React components, design tokens, and specialized hooks.
Key packages include:
@rocket.chat/fuselage: The core React Components Library.@rocket.chat/fuselage-forms: Component wrappers for improved ease of use and accessibility.@rocket.chat/fuselage-hooks: React hooks specifically designed for the Fuselage design system.@rocket.chat/fuselage-tokens: Design tokens that define the visual language of the system.@rocket.chat/css-in-js: Toolset for transpiling and using CSS at runtime.@rocket.chat/styled: A simple styled API for React components.@rocket.chat/icons: The official Rocket.Chat icon set.@rocket.chat/layout: Shared components for application layouts.@rocket.chat/toastbar: The ToastBar component for notifications.@rocket.chat/onboarding-ui: Components and functions for user onboarding experiences.Fuselage uses the rcx- prefix for its CSS classes. To simplify styling, the Box component allows you to pass props prefixed with rcx-*, which are automatically converted into class names and appended to the element's className.
This supports three patterns:
rcx-component adds rcx-component to the class list.rcx-component--bool-modifier adds rcx-component--bool-modifier.rcx-component--string-modifier='value' adds rcx-component--string-modifier-value.<Box
rcx-component
rcx-component--bool-modifier
rcx-component--string-modifier='value'
/>The package uses a provider-consumer pattern to manage field metadata (labels, hints, errors, and descriptions) and ensure accessibility (ARIA attributes).
Wrap your form or field sections in a FieldProvider to provide context for field metadata.
Use the Field component to wrap an input and its associated metadata. It uses FieldContext to coordinate between the input and its labels/hints/errors.
FieldLabel: The primary label for the input.FieldHint: Provides supplementary guidance.FieldDescription: Provides detailed descriptions.FieldError: Displays validation error messages.FieldContext allows components to interact with the field state. The FieldContextValue includes:
setDescriptor(type: LabelTypes, unregister?: boolean): Registers or unregisters a descriptor (e.g., 'hint', 'error').setLabel(label: ReactNode): Sets the field label.id: The unique identifier for the field.fieldType: The current FieldType ('wrappedByLabel' | 'referencedByLabel' | 'referencedByInput').emitAction(): Triggers an action within the field context.The Sidebar system is composed of several specialized components to build complex navigation structures:
Sidebar: The main container. Use the collapsed prop to toggle its state.SidebarItem: A single navigation item. Supports level for nesting and selected state.SidebarLink: A specialized item for navigation links, supporting icon and badge.SidebarAccordion & SidebarAccordionItem: Used to create collapsible groups of items within the sidebar.SidebarGroupTitle: Provides headings for different sections of the sidebar.SidebarDivider: A visual separator.SidebarFooter: A container for content at the bottom of the sidebar.SidebarBanner: A notification or call-to-action area within the sidebar with variants like info, success, warning, and danger.<Sidebar collapsed={false}>
<SidebarGroupTitle title="Navigation" />
<SidebarAccordion>
<SidebarAccordionItem title="Settings">
<SidebarLink icon="settings" to="/settings" />
</SidebarAccordionItem>
</SidebarAccordion>
<SidebarDivider />
<SidebarFooter>
<SidebarFooterContent>Footer Content</SidebarFooterContent>
</SidebarFooter>
</Sidebar>Box component is a primitive layout component in Fuselage. It provides normalized styles and a wide range of props designed to facilitate rapid prototyping and layout construction. It serves as a building block for more complex components.If the linter reports warnings or errors that are automatically fixable, you can run the lint-and-fix command to apply the correct formatting to your files.
yarn lint-and-fixAdd @rocket.chat/icons to your project as a dependency using npm or yarn.
npm i @rocket.chat/icons
# or, if you are using yarn:
yarn add @rocket.chat/iconsTo use @rocket.chat/fuselage-forms, you must first install its peer dependencies, then add the package itself to your project.
Ensure you have the following packages installed:
@rocket.chat/fuselage@rocket.chat/fuselage-hooksreactreact-domAdd @rocket.chat/fuselage-forms to your dependencies.
# Install peer dependencies
npm i @rocket.chat/fuselage @rocket.chat/fuselage-hooks react react-dom
# or
yarn add @rocket.chat/fuselage @rocket.chat/fuselage-hooks react react-dom
# Install the forms package
npm i @rocket.chat/fuselage-forms
# or
yarn add @rocket.chat/fuselage-formsTo use the icons, you must first import the required CSS. You can then use the icons either via the recommended Icon component or through standard HTML markup using the rcx-icon class.
/* 1. Import the CSS first */
@import url('@rocket.chat/icons/dist/rocketchat.css');<!-- 2. Use the recommended Icon Component -->
<Icon name="hash" size="x20" />
<!-- OR use standard HTML markup -->
<i class="rcx-icon">hash</i>To use @rocket.chat/layout, you must first install its peer dependencies, then add the package itself to your project.
Install the following prerequisites:
@rocket.chat/fuselage@rocket.chat/logoreactreact-domreact-i18nextAdd the layout package to your dependencies.
# Install peer dependencies
npm i @rocket.chat/fuselage @rocket.chat/logo react react-dom react-i18next
# Install the layout package
npm i @rocket.chat/layoutAdd @rocket.chat/css-in-js to your project as a dependency using npm or yarn. This package provides a toolset to transpile and use CSS at runtime.
npm i @rocket.chat/css-in-js
# or, if you are using yarn:
yarn add @rocket.chat/css-in-js