# InfoSign

## Introduction

InfoSign is a compact tooltip-trigger component that displays a small question-mark icon. When users hover over or focus on the icon, a tooltip appears with supplementary information. It is designed to provide contextual help without cluttering the interface -- ideal for explaining form fields, settings options, table column headers, and complex metrics.

The component accepts a `message` prop for the tooltip content and a `placement` prop to control where the tooltip appears relative to the icon. InfoSign keeps the main UI clean while ensuring that detailed guidance is always one interaction away.

```tsx
<InfoSign
  message={"Sarah Davis, John Doe\nJohn Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John DoeJohn Doe, John Doe, John Doe, John Doe, John Doe"}
  placement="top"
/>
```

| Field     | Description | Default |
| --------- | ----------- | ------- |
| placement | —           | "top"   |

## Usage

```tsx
import { InfoSign } from '@ceed/cds';

function MyComponent() {
  return (
    <label>
      Complex Setting
      <InfoSign message="This setting affects overall system performance. Consult an administrator before making changes." />
    </label>
  );
}
```

## Basic

The default InfoSign displays a question-mark icon that reveals a tooltip on hover or focus.

```tsx
<InfoSign
  message={"Sarah Davis, John Doe\nJohn Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John Doe, John DoeJohn Doe, John Doe, John Doe, John Doe, John Doe"}
  placement="top"
/>
```

## Common Use Cases

### Form Field Help

```tsx
import { InfoSign } from '@ceed/cds';
import { FormControl, FormLabel, Input } from '@ceed/cds';

function PasswordField() {
  return (
    <FormControl>
      <FormLabel>
        Password
        <InfoSign
          message="Must be at least 8 characters and include uppercase, lowercase, number, and special character."
          placement="top"
        />
      </FormLabel>
      <Input type="password" />
    </FormControl>
  );
}
```

### Table Column Header

```tsx
import { InfoSign } from '@ceed/cds';

function TableHeader() {
  return (
    <thead>
      <tr>
        <th>
          User ID
          <InfoSign message="Auto-generated unique identifier assigned by the system." />
        </th>
        <th>
          Last Activity
          <InfoSign message="The most recent login or action timestamp for this user." />
        </th>
        <th>Status</th>
      </tr>
    </thead>
  );
}
```

### Dashboard Metric Explanation

```tsx
import { InfoSign, Typography, Stack } from '@ceed/cds';

function MetricCard() {
  return (
    <Stack spacing={1}>
      <Typography level="title-md">
        Throughput
        <InfoSign
          message="Average requests per minute over the last 24 hours. Higher values indicate greater system load."
          placement="right"
        />
      </Typography>
      <Typography level="h2">1,234 req/min</Typography>
    </Stack>
  );
}
```

## Props and Customization

### Key Props

| Prop        | Type                                                           | Default     | Description                           |
| ----------- | -------------------------------------------------------------- | ----------- | ------------------------------------- |
| `message`   | `string`                                                       | (required)  | Tooltip message text                  |
| `placement` | `TooltipPlacement`                                             | `'top'`     | Tooltip position relative to the icon |
| `color`     | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'neutral'` | Icon color                            |
| `size`      | `'sm' \| 'md' \| 'lg'`                                         | `'md'`      | Icon size                             |
| `sx`        | `SxProps`                                                      | -           | Custom styles                         |

## Best Practices

- **Keep messages concise.** Tooltip messages should be 1-2 sentences that quickly answer "what does this mean?" Avoid paragraphs of text.
  - ✔ "Maximum file size per upload. Files exceeding this limit will be rejected."
  - ✘ A multi-paragraph explanation with examples and edge cases

- **Place InfoSign directly adjacent to the element it explains.** Position it immediately after a label or header text so users can easily associate the help icon with the relevant field.

- **Do not overuse InfoSign.** Adding a help icon to every single field creates visual noise and suggests the interface itself is too confusing. Reserve it for genuinely complex or ambiguous items.

- **Choose placement that avoids overlap.** Use `placement="top"` or `placement="right"` for fields near the bottom of a viewport, and `placement="bottom"` for elements near the top.

- **Use InfoSign for supplementary information only.** Critical instructions or warnings should be displayed inline (e.g., with FormHelperText or Alert), not hidden behind a tooltip.

## Accessibility

- InfoSign is keyboard-focusable, allowing users to trigger the tooltip using **Tab** navigation without requiring a mouse.
- The tooltip content is announced by screen readers when the InfoSign receives focus, thanks to built-in ARIA attributes.
- The question-mark icon serves as a universally recognized visual cue for "more information," making it intuitive for all users.
- Ensure that the `message` text provides the same information available through other channels -- do not make the tooltip the only way to learn critical information.
