useTopBarTitle(title: string, ellipsis?: number)

Requires:
@ray-js/panel-sdk≥1.0.0

Description

Set the top navigation bar title in the mini program, with automatic truncation for long text

Parameters

ParameterTypeRequiredDescription
titlestringYesThe title text to set
ellipsisnumberNoMaximum title length in characters; adds an ellipsis when exceeded. Default is 14

Return Value

Type: (titleRes: string) => void[]
Tuple [setTitle], containing a function to manually set the title

Examples

Example

import { useTopBarTitle } from '@ray-js/panel-sdk';

function DevicePage() {
  // Automatically set the top title; longer than 14 characters will be truncated
  const [setTitle] = useTopBarTitle('Smart lighting control panel');

  // You can also update the title manually
  const handleRename = (newName: string) => setTitle(newName);
}