OneScript

Label

Pair a title with an icon.

A title next to an icon, laid out the way the system expects. Lists, menus, toolbars, and buttons adapt how a Label looks. children is the title.

import { Label } from "onescript/views"

<Label symbol="star.fill">Favorites</Label>
PropTypeDescription
symbolstringSF Symbol or Pika icon name used as the icon.
source"sf" | "pika"Icon source for symbol. Defaults to "sf".
iconViewChildAny view used as the icon, such as an Image.
childrenViewChildThe title.

Pass exactly one of symbol or icon. source is only allowed with symbol.

Custom icons

import { Image, Label, Modifier } from "onescript/views"
import avatar from "./assets/avatar.png"

<Label
  icon={
    <Image
      url={new URL(avatar)}
      resizable
      modifier={Modifier
        .scaledToFit()
        .frame({ width: 20, height: 20 })}
    />
  }
>
  Profile
</Label>

Use labelStyle to show only the title or only the icon. Also accepts Modifiers. It is available in App, Action, and Widget views.

How is this guide?

Last updated on

On this page