# Event rendering

> Color events by status or resource, render custom content inside event bars, add tooltips and theme the scheduler with CSS custom properties.

Out of the box, each event is a colored bar with its title. This page shows how to change the colors, put your own content in the bar, add tooltips, and restyle the scheduler to match your application.

## Colors

The bar color comes from, in order of precedence:

1. the event's `color`,
2. the resource's `color`,
3. the theme's accent color, `--lq-sched-accent`.

Any CSS color works: hex, `rgb()`, `hsl()`, named colors or `var(--your-token)`. The color is a tint, not a flat fill: the bar gets a solid 3-pixel left border in the color and a light background mixed from it, so text stays readable in both themes. The value is exposed to CSS as `--lq-sched-event-color` on the bar element.

```ts
const STATUS_COLORS = {
  scheduled: '#2563eb',
  enRoute: '#7c3aed',
  onSite: '#0f766e',
  blocked: '#dc2626',
} as const;

const events = jobs.map((job) => ({ ...job, color: STATUS_COLORS[job.status] }));

scheduler.setEvents(events);
```

Coloring by resource is a good default when each row is a person and you want their work to stay recognizable after it is dragged elsewhere. Coloring by status is better for dispatch boards where the question is "what needs attention".

## CSS classes per event

Set `className` on an event to style it with your own CSS. This keeps visual rules in your stylesheet and works well with design tokens:

```ts
const events = jobs.map((job) => ({
  ...job,
  className: [job.priority === 'urgent' && 'job-urgent', job.isTentative && 'job-tentative'].filter(Boolean).join(' '),
}));
```

```css
.job-urgent {
  box-shadow: inset 4px 0 0 #dc2626;
}

.job-tentative {
  opacity: 0.65;
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgb(255 255 255 / 0.25) 6px 12px);
}
```

## Custom event content

`eventRenderer(event, context)` returns the content of a bar: a DOM `Node` for anything structured, or a string, which is inserted as plain text (never parsed as HTML). It is called when a bar is first rendered and again when its data changes, so keep it fast and free of side effects. If the renderer throws, the error is logged with `console.error` and the bar falls back to the event's title.

| Context field | Type | Description |
| --- | --- | --- |
| `resource` | `TResource \| undefined` | The resource row the bar is in. |
| `start`, `end` | `Date` | The event's times. |
| `element` | `HTMLElement` | The bar element itself, for adding classes or data attributes. |
| `lane` | `number` | The overlap lane the bar was placed in, starting at 0. |
| `isSelected` | `boolean` | Whether the event is currently selected. |

A two-line job card with customer, work order and a time range:

```ts
import { createScheduler, type SchedulerEvent } from '@birchui/scheduler';

interface ServiceJob extends SchedulerEvent {
  customer: string;
  workOrder: string;
  priority: 'routine' | 'urgent';
}

const time = new Intl.DateTimeFormat('en-US', { timeZone: 'America/Chicago', hour: 'numeric', minute: '2-digit' });

createScheduler<ServiceJob>(container, {
  resources: technicians,
  events: jobs,
  start: '2026-12-07T06:00',
  end: '2026-12-07T20:00',
  viewPreset: 'hourAndDay',
  timeZone: 'America/Chicago',
  rowHeight: 52,
  eventRenderer: (job, { start, end, element, isSelected }) => {
    element.dataset.priority = job.priority;
    element.classList.toggle('job-selected', isSelected);

    const card = document.createElement('div');
    card.className = 'job-card';

    const title = document.createElement('strong');
    title.textContent = job.customer;

    const detail = document.createElement('span');
    detail.textContent = `${job.workOrder}, ${time.format(start)} to ${time.format(end)}`;

    card.append(title, detail);
    return card;
  },
});
```

```css
.job-card {
  display: grid;
  gap: 2px;
  padding: 4px 8px;
  line-height: 1.2;
  overflow: hidden;
}

.job-card span {
  font-size: 11px;
  opacity: 0.85;
}
```

> **Warning**
>
> Build nodes with `textContent` when content comes from your users or your database, such as customer names and notes. Never assign HTML strings built from that data to `innerHTML`.

> **Note**
>
> Keep each event's `title` meaningful even when the bar shows custom content. The title is what screen readers announce for the event, together with its time and resource. See [Keyboard and accessibility](https://docs.birchui.com/scheduler/accessibility.md).

### Use the lane

`lane` tells you where an overlapping event was placed with `eventLayout: 'stack'` or `'pack'`, which is handy for showing a conflict marker on every event after the first. With `'overlap'`, every event is in lane 0.

```ts
scheduler.update({
  eventRenderer: (job, { lane, element }) => {
    element.classList.toggle('job-conflict', lane > 0);
    return job.title;
  },
});
```

## Tooltips

Tooltips are on by default. The built-in tooltip is the event's accessible description, such as "Boiler service, Mon 8:00 AM to 10:30 AM, Amira Haddad", shown through the native `title` attribute. Set `tooltips: false` to remove them, or pass a function to choose the text yourself:

```ts
createScheduler<ServiceJob>(container, {
  resources: technicians,
  events: jobs,
  start: '2026-12-07',
  end: '2026-12-12',
  tooltips: (job, technician) => `${job.customer} (${job.workOrder}), assigned to ${technician?.name ?? 'nobody'}`,
});
```

## Resource column content

The left pane uses `resourceColumns`. Each column's `renderer(resource)` returns a string or a `Node`, the same way `eventRenderer` does. See [Resource columns](https://docs.birchui.com/scheduler/resources-and-events.md#resource-columns).

## Theming

The scheduler uses the same theme system as the grid.

- `theme: 'light'`, `'dark'` or `'auto'` picks a bundled theme. `'auto'` follows the operating system's `prefers-color-scheme`.
- Without `theme`, the scheduler inherits the page's theme: an ancestor with the class `lq-theme-dark` switches it to dark, the same as for the grid.
- Colors, fonts, borders and radii come from the shared `--lq-*` custom properties, such as `--lq-bg`, `--lq-fg`, `--lq-border`, `--lq-header-bg`, `--lq-accent`, `--lq-focus-ring`, `--lq-font-family`, `--lq-font-size` and `--lq-radius`. Set them on the scheduler element or any ancestor and the grid and scheduler change together.
- Scheduler-only tokens use the `--lq-sched-*` prefix. Each one defaults to the matching shared token, so set them only when the scheduler should differ from your grids.
- Classes use the `lq-sched` prefix, and selectors are kept to a single class so your overrides win without `!important`.

```css
.dispatch-board {
  --lq-font-family: 'Inter', system-ui, sans-serif;
  --lq-font-size: 13px;
  --lq-accent: #0f766e;
  --lq-focus-ring: #0f766e;
  --lq-header-bg: #f1f5f4;
  --lq-radius: 4px;
}
```

```ts
createScheduler(container, { ...options, theme: 'auto' });
container.classList.add('dispatch-board');
```

### Scheduler tokens

| Token | Controls |
| --- | --- |
| `--lq-sched-accent` | Default event color. Falls back to `--lq-accent`. |
| `--lq-sched-bg`, `--lq-sched-fg`, `--lq-sched-muted-fg` | Background, text and secondary text. |
| `--lq-sched-border`, `--lq-sched-radius` | Outer border and corner radius. |
| `--lq-sched-header-bg`, `--lq-sched-header-fg` | Time header and resource column header. |
| `--lq-sched-row-alt`, `--lq-sched-row-hover` | Alternate and hovered rows. |
| `--lq-sched-selection-bg`, `--lq-sched-focus-ring` | Selection and keyboard focus. |
| `--lq-sched-tick-line`, `--lq-sched-major-line`, `--lq-sched-row-line` | Grid lines between ticks, major ticks and rows. |
| `--lq-sched-nonworking-bg` | Shading of non-working time. |
| `--lq-sched-now-color` | The now line. |
| `--lq-sched-invalid-color` | The drag preview when a move is rejected by validation. |
| `--lq-sched-event-text` | Text color inside event bars. |
| `--lq-sched-font-family`, `--lq-sched-font-size` | Typography. |

### Class names

| Class | Element |
| --- | --- |
| `lq-sched` | Root element. Gets `lq-theme-light`, `lq-theme-dark` or `lq-theme-auto` when `theme` is set, and `lq-sched--readonly`, `lq-sched--dragging` or `lq-sched--resizing` while those states apply. |
| `lq-sched-event` | An event bar. Modifiers: `--selected`, `--draggable`, `--dragging`, `--clip-start` and `--clip-end` (the event continues outside the visible range). |
| `lq-sched-event-content`, `lq-sched-event-title` | Content wrapper and default title inside a bar. |
| `lq-sched-handle--start`, `lq-sched-handle--end` | Resize handles. |
| `lq-sched-ghost`, `lq-sched-ghost--invalid` | The drag preview, and its rejected state. |
| `lq-sched-res`, `lq-sched-res--group` | A resource row in the left pane, and a group row. |
| `lq-sched-lane`, `lq-sched-lane--group` | A resource row in the timeline. |
| `lq-sched-hcell` | A time header cell. |
| `lq-sched-shade`, `lq-sched-now` | Non-working shading and the now line. |

Restyle selected bars, for example:

```css
.lq-sched-event--selected {
  box-shadow: 0 0 0 2px var(--lq-sched-focus-ring);
}
```

The scheduler respects `prefers-reduced-motion` (no transitions unless motion is allowed) and Windows high-contrast mode, where bars get system-colored borders.

The [theming guide](https://docs.birchui.com/grid/theming.md) lists every shared token and shows how to build a brand theme for all Birch UI components at once.

## Next steps

- [Keyboard and accessibility](https://docs.birchui.com/scheduler/accessibility.md)
- [API and events](https://docs.birchui.com/scheduler/api.md)
