# Glyphs

> Small marks for status, priority, color and people.

Page: https://uicontext.com/docs/components/glyphs

Group: Primitives.

## When to use

Small marks for status, priority, color and people. Use [Avatar](https://uicontext.com/docs/components/avatar.md) instead when the mark stands for a person and needs a name or picture.

## Usage

```ts
import { GlyphView } from "./ui/uicontext/components/Glyph.ts"
import { color } from "./ui/uicontext/components/tokens.stylex.ts"

export const InProgress = <M>(h: Html.H<M>) =>
	GlyphView(h, { _tag: "Ring", color: color.caution, progress: 0.5, label: "In progress" })
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### Status, priority, labels and people

The example the page opens with: Glyphs in “Status, priority, labels and people”.

```ts title="src/demo.ts" source="www/src/examples/glyphs/demo.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { type Glyph, GlyphView } from "./ui/uicontext/components/Glyph.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({
	rows: { display: "grid", gap: space.lg },
	row: { display: "flex", flexWrap: "wrap", columnGap: space.xl, rowGap: space.sm },
	sample: { display: "inline-flex", alignItems: "center", gap: space.sm, fontSize: font.sm, color: color.fg },
})

const rows: ReadonlyArray<ReadonlyArray<{ readonly glyph: Glyph; readonly label: string }>> = [
	[
		{ glyph: { _tag: "Ring", color: color.muted, progress: 0, dashed: true, label: "Backlog" }, label: "Backlog" },
		{ glyph: { _tag: "Ring", color: color.muted, progress: 0, label: "Todo" }, label: "Todo" },
		{ glyph: { _tag: "Ring", color: color.caution, progress: 0.5, label: "In progress" }, label: "In progress" },
		{ glyph: { _tag: "Ring", color: color.done, progress: 1, mark: "check", label: "Done" }, label: "Done" },
		{ glyph: { _tag: "Ring", color: color.muted, progress: 1, mark: "cross", label: "Canceled" }, label: "Canceled" },
	],
	[
		{ glyph: { _tag: "Bars", level: 3, alert: true, label: "Urgent" }, label: "Urgent" },
		{ glyph: { _tag: "Bars", level: 3, label: "High" }, label: "High" },
		{ glyph: { _tag: "Bars", level: 2, label: "Medium" }, label: "Medium" },
		{ glyph: { _tag: "Bars", level: 1, label: "Low" }, label: "Low" },
	],
	[
		{ glyph: { _tag: "Swatch", color: color.danger }, label: "Bug" },
		{ glyph: { _tag: "Swatch", color: color.info }, label: "Feature" },
		{ glyph: { _tag: "Person", id: "maya", name: "Maya Chen", agent: false }, label: "Maya Chen" },
		{ glyph: { _tag: "Person", id: "scout", name: "Scout", agent: true }, label: "Scout (agent)" },
	],
]

export const IssueGlyphs = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.rows)).children(
		rows.map((row, i) =>
			h.div.key(String(i)).attrs(sx(styles.row)).children(
				row.map(({ glyph, label }) => h.span.key(label).attrs(sx(styles.sample)).children(GlyphView(h, glyph), label)),
			)),
	)
```

## API reference

**Options**

| Name | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | A stable id, which picks the color, so one person keeps theirs everywhere. |
| `name` (required) | `string` | The full name: the initials come from it, and it labels the avatar. |
| `agent` | `boolean` | Draws an agent: a rounded square with the agent mark. |
| `app` | `boolean` | Draws an app that isn't an agent (a poll, a build bot): a rounded square with its initials, no mark. |
| `image` | `string` | A picture's URL, shown instead of the initials. |

## Keyboard and accessibility

- A ring or bars glyph is an image named by its `label`, so a screen reader hears "In progress" or "High priority", not a shape.
- An avatar shows initials, or a picture with empty `alt`, and carries the name as a tooltip; say the name in text beside it where it matters. A swatch is decoration only.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/glyphs
```

With npm: `npx shadcn@latest add checkfu/uicontext/glyphs`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/glyphs`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/glyphs`.

It writes these files:

- `src/ui/uicontext/components/Glyph.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/domain/Format.ts`
- `src/ui/uicontext/components/domain/Glyph.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/Glyph.ts](https://github.com/checkfu/uicontext/blob/main/src/Glyph.ts)

## Used in

- [Task manager](https://uicontext.com/blocks/issue-tracker.md)
- [Helpdesk](https://uicontext.com/blocks/helpdesk.md)
- [Team assistant](https://uicontext.com/blocks/team-assistant.md)
- [Team chat](https://uicontext.com/blocks/team-chat.md)
- [Design](https://uicontext.com/blocks/design-tool.md)
- [Whiteboard](https://uicontext.com/blocks/whiteboard.md)
- [Accept invitation](https://uicontext.com/blocks/accept-invite.md)
- [Profile](https://uicontext.com/blocks/profile-settings.md)
- [Notification center](https://uicontext.com/blocks/notification-center.md)

## Related

- [Button](https://uicontext.com/docs/components/button.md) (`button`): A button, and a link that looks like one, in every tone and three sizes.
- [Toggle](https://uicontext.com/docs/components/toggle.md) (`toggle`): A button that stays pressed, such as Bold or Pin.
- [Toggle Group](https://uicontext.com/docs/components/toggle-group.md) (`toggle-group`): Buttons that stay pressed and share one value, such as text styles.
- [Input](https://uicontext.com/docs/components/input.md) (`input`): Text inputs, selects and textareas in a labeled field with a hint and an error, and their styles for controls you lay out yourself.
- [Status](https://uicontext.com/docs/components/status.md) (`status`): Status badges and tags for runs and records.
- [Action Toolbar](https://uicontext.com/docs/components/action-toolbar.md) (`action-toolbar`): A row of grouped buttons with one Tab stop, such as formatting toggles or bulk actions.
