LayoutManager
, which is a property of the AppSession
object.
Available Layout Types
The SDK currently supports the following layout types:1. TextWall
- Purpose: Displays a single block of text. This is the most basic layout and is suitable for simple messages, status updates, and short notifications.
-
Type:
LayoutType.TEXT_WALL
-
Properties:
text
: The text content to display (string).
-
Example:
2. DoubleTextWall
- Purpose: Displays two blocks of text, one above the other. This is useful for showing two related pieces of information, such as a title and a subtitle, or a before/after comparison.
-
Type:
LayoutType.DOUBLE_TEXT_WALL
-
Properties:
topText
: The text for the top section.bottomText
: The text for the bottom section.
-
Example:
3. ReferenceCard
- Purpose: Displays a card with a title and content text. This is a more structured layout, suitable for displaying important information, notifications with titles, or key data points.
-
Type:
LayoutType.REFERENCE_CARD
-
Properties:
title
: The title of the card (string).text
: The main content of the card (string).
-
Example:
4. DashboardCard
- Purpose: Displays a card with left-aligned and right-aligned text. This layout is ideal for key-value pairs, metrics, and dashboard-style displays.
-
Type:
LayoutType.DASHBOARD_CARD
-
Properties:
leftText
: Text for the left side (often a label or key).rightText
: Text for the right side (often a value or status).
-
Example:
5. BitmapView
-
Purpose: Displays bitmap images on the AR glasses. Supports monochrome bitmaps at 526x100 (576×135 when padded) pixel resolution.
Only use 526x100 images unless you know what you’re doing! (the file size should be ~7-10kb)
-
Type:
LayoutType.BITMAP_VIEW
-
Properties:
data
: Bitmap data as hex or base64 encoded string.
-
Example:
6. ClearView
- Purpose: Clears the current display, returning to a blank state. Useful for resetting the view before showing new content.
-
Type:
LayoutType.CLEAR_VIEW
- Properties: None.
-
Example:
Bitmap Animation
The LayoutManager provides animation support for bitmap sequences:Bitmap Utilities
The SDK provides utility classes for working with bitmap images:BitmapUtils
AnimationUtils
Display Duration (durationMs
)
All layout methods accept an optional options
object, which can include a durationMs
property. This property controls how long the layout is displayed on the glasses, in milliseconds.
durationMs: number
(optional): The duration, in milliseconds, to display the layout.durationMs: -1
: Indicates that the layout should be displayed persistently, until it is explicitly replaced or cleared. This is useful for content that should remain visible until further notice.- Omitting
durationMs
: If you omitdurationMs
, the behavior depends on whether you are sending interim transcription. If it’s provided, the layout will remain until replaced or cleared. If the duration is omitted the currentDisplayManager
implementation will display for 20 seconds. This behavior should not be relied upon. Always providedurationMs
in production code.
View Type
Theoptions
object in the layout methods also allows you to specify a view
property:
ViewType.MAIN
(default): The main AR view that the user sees most of the time.ViewType.DASHBOARD
: A special dashboard view. Currently, the user looks up to access the dashboard.
Layout Interfaces
The@mentra/sdk
provides TypeScript interfaces for each layout type. These interfaces ensure type safety and provide autocompletion in your IDE. You can import these directly:
Best Practices
- Keep it Concise: The glasses display has limited space. Use short, clear text. Avoid long paragraphs or complex layouts.
- Prioritize Information: Display the most important information prominently.
- Use Appropriate Layouts: Choose the layout type that best suits the content you’re displaying.
- Consider Head Position: The
head_position
event lets you know if the user is looking up (at the dashboard) or down (at the main view). You can use this to tailor the displayed content. - Avoid Flicker: Rapidly changing the display can be visually jarring. Use appropriate durations and consider debouncing or throttling updates if necessary.
- Text Wrapping: The glasses have limited width, so it is important to handle text that is longer than can fit on one line. The
@mentraos/utils
package provides awrapText
utility function to handle this.