Tooltip
عرض شاملimport { Tooltip, TooltipAlign, TooltipPlacement, TooltipSide } from '@nili/ui';هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.
الأحجام
ثلاثة أحجام للفقاعة. ويجب أن يكون المُشغِّل قابلًا للتركيز — فالتلميح على span عادي غير مرئي لمستخدمي لوحة المفاتيح، لذا لُفّ النص بزر.
import { Tooltip, Button } from "@nili/ui"
export function Example() {
return (
<>
<Tooltip size="2xs" content={t('copyLink')}>
<Button appearance="stroke">2X-Small</Button>
</Tooltip>
<Tooltip size="xs" content={t('copyLink')}>
<Button appearance="stroke">X-Small</Button>
</Tooltip>
<Tooltip size="lg" content="Copy link" description="Anyone with the link can view.">
<Button appearance="stroke">Large</Button>
</Tooltip>
</>
)
}الجهات والمحاذاة
side منطقي: فـstart وend يتبعان اتجاه القراءة. ويأخذ top وbottom محاذاة align أيضًا، بخلاف start وend — والنوع يجعل ذلك غير قابل للتمثيل بدل قبول خاصية لا تفعل شيئًا.
import { Tooltip, Button } from "@nili/ui"
export function Example() {
return (
<>
<Tooltip side="top" content="Top" />
<Tooltip side="bottom" align="start" content="Bottom start" />
<Tooltip side="start" content="Start" />
<Tooltip side="end" content="End" />
</>
)
}فقاعة فاتحة وسهم وأيقونة متقدّمة
التلميح معكوس مقابل سطحه، فـdarkMode خيار لكل تلميح لا قرار سمة. وهو مفعّل افتراضيًا — الفقاعة الداكنة على صفحة فاتحة.
import { Tooltip, CompactButton, Icon } from "@nili/ui"
import { RiInformationLine } from "@remixicon/react"
export function Example() {
return (
<>
<Tooltip content={t('style.dark')}>
<CompactButton aria-label="Info"><Icon icon={RiInformationLine} /></CompactButton>
</Tooltip>
<Tooltip darkMode={false} content={t('style.light')}>
<CompactButton aria-label="Info"><Icon icon={RiInformationLine} /></CompactButton>
</Tooltip>
<Tooltip arrow={false} content={t('style.noTail')}>
<CompactButton aria-label="Info"><Icon icon={RiInformationLine} /></CompactButton>
</Tooltip>
<Tooltip
content="With a leading icon"
startIcon={<Icon icon={RiInformationLine} />}
>
<CompactButton aria-label="Info"><Icon icon={RiInformationLine} /></CompactButton>
</Tooltip>
</>
)
}التأخير والإغلاق
يؤخّر delay الفقاعة عند المرور، أما التركيز فيفتحها فورًا دائمًا. ويمكن للتلميح الكبير أن يحمل زر إغلاق — احتفظ به لمحتوى يحتاج القارئ إلى لحظة معه.
import { Tooltip, Button } from "@nili/ui"
export function Example() {
return (
<>
<Tooltip delay={600} content={t('delay.waited')}>
<Button appearance="stroke">Slow</Button>
</Tooltip>
<Tooltip
size="lg"
dismissible
dismissLabel="Close"
content="Keyboard shortcuts"
description="Press ⌘K to open the command palette from anywhere."
>
<Button appearance="stroke">{t('delay.dismissible')}</Button>
</Tooltip>
<Tooltip disabled content={t('delay.offBody')}>
<Button appearance="stroke" disabled>Disabled</Button>
</Tooltip>
</>
)
}Tooltip
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | 2xs | xs | lg | xs | |
| darkMode | 'true' | 'false' | true | |
| side | top | bottom | start | end | top | |
| align | start | center | end | center |
TooltipArrow
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| darkMode | 'true' | 'false' | true | |
| side | top | bottom | start | end | top |
TooltipArrowSurface
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| darkMode | 'true' | 'false' | true |
TooltipBase
داخليextends Omit< ComponentPropsWithoutRef<'div'>, 'content' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children* | ReactNode | — | The trigger. A single element, which receives the hover, focus and `aria-describedby` wiring — so it must be able to take focus. Wrap plain text in a `<button>` or a focusable element; a tooltip on a `<span>` is invisible to keyboard users. |
| aria-label | string | — | |
| content* | ReactNode | — | Tooltip text. Keep it to a phrase and keep it non-essential: a tooltip is unreachable on touch and can be missed entirely, so anything the user *must* read belongs in the page. |
| description | ReactNode | — | Second line under the text. Figma's "Edit Description". |
| startIcon | ReactNode | — | Leading slot inside the bubble. Figma's "Left Icon". |
| size | lg | xs | 2xs | — | |
| arrow | boolean | — | Figma's "Tail". |
| darkMode | boolean | — | Figma's "Dark Mode". A tooltip is inverted against its surface, so this is a per-tooltip choice rather than something the theme decides. On by default, which is the dark bubble on a light page. |
| open | boolean | — | Controlled visibility. |
| defaultOpen | boolean | — | |
| onOpenChange | (open: boolean) => void | — | |
| delay | number | — | Milliseconds before it appears on hover. Focus opens it immediately. |
| disabled | boolean | — | Turns the tooltip off without unmounting the trigger. |
| dismissible | boolean | — | Figma's large tooltip carries a close (×) button. |
| onDismiss | () => void | — | |
| dismissLabel | string | — | Accessible name for the close button. |
| contentClassName | string | — | Class for the bubble. Use `className` for the wrapper. |
TooltipSurface
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | 2xs | xs | lg | xs | |
| darkMode | 'true' | 'false' | true |