Tooltip
Genel görünümimport { Tooltip, TooltipAlign, TooltipPlacement, TooltipSide } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Boyutlar
Üç baloncuk boyutu. Tetikleyici odaklanabilir olmalı — düz bir span üzerindeki ipucu klavye kullanıcılarına görünmez, bu yüzden metni bir düğmeye sarın.
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>
</>
)
}Yönler ve hizalama
side mantıksaldır: start ve end okuma yönünü izler. top ve bottom ayrıca bir align alır; start ve end almaz ve tür bunu, hiçbir işe yaramayan bir prop’u kabul etmek yerine ifade edilemez kılar.
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" />
</>
)
}Açık baloncuk, ok ve öndeki simge
Bir ipucu, üzerinde durduğu yüzeye göre terstir; bu yüzden darkMode tema kararı değil, ipucu başına bir seçimdir. Varsayılan açıktır — açık bir sayfadaki koyu baloncuk.
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>
</>
)
}Gecikme ve kapatma
delay baloncuğu üzerine gelmede geciktirir; odak onu her zaman hemen açar. Büyük ipucu bir kapatma düğmesi taşıyabilir — bunu okuyucunun biraz vakit ayırması gereken içerik için saklayın.
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
Varyant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | 2xs | xs | lg | xs | |
| darkMode | 'true' | 'false' | true | |
| side | top | bottom | start | end | top | |
| align | start | center | end | center |
TooltipArrow
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| darkMode | 'true' | 'false' | true | |
| side | top | bottom | start | end | top |
TooltipArrowSurface
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| darkMode | 'true' | 'false' | true |
TooltipBase
dahiliextends Omit< ComponentPropsWithoutRef<'div'>, 'content' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| 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
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | 2xs | xs | lg | xs | |
| darkMode | 'true' | 'false' | true |