المكوّنات · أزرار أيقونات بتلميحات
أزرار أيقونات بتلميحات
لكلٍّ اسم مسموع، والتلميح يظهر بالتركيز لا بالتمرير فقط
12 تصاميم من هذه العائلة
<div class="bt bti">
<div class="bar" role="toolbar" aria-label="تنسيق">
<button aria-label="عريض" aria-pressed="false" data-tip="عريض"><b>B</b></button>
<button aria-label="مائل" aria-pressed="false" data-tip="مائل"><i>I</i></button>
<button aria-label="تحته خطّ" aria-pressed="false" data-tip="تحته خطّ"><u>U</u></button>
<span class="vr" aria-hidden="true"></span>
<button aria-label="محاذاة للبداية" aria-pressed="true" data-tip="محاذاة للبداية">≡</button>
<button aria-label="قائمة نقطية" aria-pressed="false" data-tip="قائمة نقطية">•≡</button>
<span class="vr" aria-hidden="true"></span>
<button aria-label="رابط" data-tip="إدراج رابط">🔗</button>
</div>
<p class="lbl" data-ar="تنقّل بالمفاتيح — التلميح يظهر بالتركيز أيضًا" data-en="Tab through — the tooltip also shows on focus">تنقّل بالمفاتيح — التلميح يظهر بالتركيز أيضًا</p>
</div>
/* pt-scoped */
/* button-icon — محرّر نصوص */
.bti{width:100%;height:100%;display:flex;flex-direction:column;
align-items:center;justify-content:center;gap:9px;padding:10px;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.bti .lbl{font-size:8px;color:var(--pt-text-muted);text-align:center}
.bti button{font:inherit;cursor:pointer;display:inline-flex;align-items:center;
justify-content:center;gap:5px;white-space:nowrap;
transition:background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
border-color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
box-shadow var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.bti button:disabled{cursor:not-allowed}
.bti button:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:2px}
/* أي زرّ ينزل بمقدار بكسل عند الضغط — تأكيد لمسيّ قبل وصول الردّ */
.bti button:not(:disabled):active{transform:translateY(1px)}
@media(prefers-reduced-motion:reduce){.bti button{transition:none}
.bti button:not(:disabled):active{transform:none}
}
/* هدف اللمس 44 بكسلًا على الشاشات اللمسية دون تضخيم سطح المكتب */
@media(pointer:coarse){.bti button{min-height:44px;min-width:44px}
}
/* شكل: شريط أدوات مربّع الحواف، أزرار مربّعة صغيرة */
.bti .bar{display:flex;align-items:center;gap:2px;padding:3px;
border-radius:var(--pt-radius-xs);background:var(--pt-bg-inset);
border:1px solid var(--pt-border-subtle)}
.bti .bar button{position:relative;width:24px;height:24px;padding:0;border:0;
border-radius:var(--pt-radius-xs);background:transparent;color:var(--pt-text-muted);
font-size:10px}
.bti .bar button:hover{background:var(--pt-surface-hover);color:var(--pt-text-primary)}
.bti .bar button[aria-pressed=true]{background:var(--pt-accent-muted);color:var(--pt-accent)}
.bti .vr{width:1px;height:16px;background:var(--pt-border-default);margin:0 3px}
.bti .bar button::after{content:attr(data-tip);position:absolute;inset-block-end:calc(100% + 6px);
inset-inline-start:50%;transform:translateX(50%);white-space:nowrap;
padding:3px 7px;border-radius:var(--pt-radius-xs);background:var(--pt-bg-overlay);
border:1px solid var(--pt-border-default);color:var(--pt-text-primary);font-size:8px;
opacity:0;pointer-events:none;
transition:opacity var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
[dir=ltr] .bti .bar button::after{transform:translateX(-50%)}
.bti .bar button:hover::after, .bti .bar button:focus-visible::after{opacity:1}
@media(prefers-reduced-motion:reduce){.bti .bar button::after{transition:none}
}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.bti');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
var ar = document.documentElement.lang !== 'en';
var n = function (v) { return Number(v).toLocaleString('en-US'); };
root.querySelectorAll('.bar button[aria-pressed]').forEach(function (b) {
b.addEventListener('click', function () {
// المحاذاة اختيار واحد من ثلاثة؛ والباقي مفاتيح مستقلّة
var on = b.getAttribute('aria-pressed') === 'true';
b.setAttribute('aria-pressed', String(!on));
});
});
}
function mount() {
ac = new AbortController();
var real = window.document;
/* وسيط يمرّر كل شيء إلى المستند الحقيقي، ويعلّق كل مستمع بإشارة
تُقطع عند إعادة التركيب — فلا يبقى مستمع من نسخة ماتت. */
var doc = new Proxy(real, {
get: function (t, k) {
if (k === 'addEventListener') {
return function (type, fn, opts) {
var o = (opts && typeof opts === 'object') ? Object.assign({}, opts)
: { capture: !!opts };
o.signal = ac.signal;
return t.addEventListener(type, fn, o);
};
}
var v = t[k];
return typeof v === 'function' ? v.bind(t) : v;
}
});
function track(fn) {
return function (f, ms) { var id = fn(f, ms); timers.push(id); return id; };
}
run(host, doc, track(window.setTimeout.bind(window)),
track(window.setInterval.bind(window)));
}
function unmount() {
if (ac) ac.abort();
// المعرّفان يتشاركان فضاءً واحدًا في المتصفّح، فالإلغاء المزدوج آمن
timers.forEach(function (id) { window.clearTimeout(id); window.clearInterval(id); });
timers = [];
host.innerHTML = snapshot;
}
mount();
addEventListener('pt-lang', function () { unmount(); mount(); });
})();
# Icon Buttons with Tooltips
**Role:** You are an Arabic-first UI designer and front-end engineer. Read the whole
specification before writing a single line, then follow it literally. If two requirements
conflict, favour usability over visual effect.
**Goal:** Icon Buttons with Tooltips — Each has an accessible name, and the tooltip shows on focus, not hover alone
**Why this component matters:** An icon-only button is invisible to a screen reader without aria-label, and its tooltip must appear on keyboard focus too — hover-only tooltips exclude every keyboard user.
**Direction:** Genuine RTL — not a mirrored Latin layout. Use logical properties
(`margin-inline-start`, `padding-inline`, `inset-inline-start`, `text-align: start`),
never physical ones (`margin-left`, `left`). The layout must flip with `dir` on its own,
with no duplicated rules.
**Typography:** Cairo for Arabic, IBM Plex Sans for Latin. Arabic line-height must be
`0.18` higher than the Latin equivalent — dots, hamzas and maddas need more vertical room.
Arabic font-size runs `1.06×` the Latin size at the same optical weight.
**Numerals:** Western digits in both languages (`1,234.50`). Only the currency changes:
`ر.س` **after** the number in Arabic, `$` **before** it in English. Jordanian dinar
uses **three** decimal places, not two.
**Colors:** Dark mode — background `#0D142B` · surfaces `#211F54` · borders `#545C91` · text `#918FC2`.
Accent `#ADA9E8` must never exceed 8% of the screen area.
**Language:** Bilingual — every string carries both Arabic and English, and the layout
flips with `dir` automatically.
**States:** `default` · `hover` · `focus` · `active` · `disabled` · `loading` · `error`.
Do not design the resting state alone.
**Accessibility:** Contrast ratio at least `4.5:1`, complete keyboard navigation,
visible focus rings, and honour `prefers-reduced-motion`.
**Output:** Clean HTML and CSS in two separate files. No frameworks, no libraries,
no external dependencies.